Node function on AWS Lambda can't connect to database with node-pg - node.js

My function works locally, but, when I deploy to AWS Lambda, it can't seem to connect to my postgres database. Here's the error:
{ [Error: connect ECONNREFUSED] code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect' }, isOperational: true, code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect' }
My database is hosted on an Azure virtual machine, and I'm not having problems connecting to it from any other app nor from this app when run locally. What could be causing the connection to fail when running on Lambda?

It turned out to be something dumb. I am using node-lambda and thought the .env file it creates was propagated to the function's environment. Logging my DB connection string showed this wasn't the case. Once I set that, everything was golden.

Related

heroku postgres ETIMEDOUT when conencting through localhost

I have a website which uses the free tier of heroku postgres I was running it on localhost and it was working just fine till today no changes were made to the code and the database url and everything is just fine
Error: connect ETIMEDOUT 3.224.164.189:5432
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1246:16) {
errno: -4039,
code: 'ETIMEDOUT',
syscall: 'connect',
address: '3.224.164.189',
port: 5432
}
This is the error which I get and this error is only shown on localhost, when the same code is deployed to heroku, it works just fine
Also, one thing which I've noticed is that it works just fine when I use my mobile network and this issue only occurs when I use my ethernet connection.
Can Someone help me out with this sticky situation?

Gcloud Postgres wont connect with App Engine

Having a bit of trouble with this. Trying out Google Cloud at the moment and cant my GCloud Postgres db to link to my app engine app.
I'm following everything here :
https://cloud.google.com/appengine/docs/flexible/nodejs/using-cloud-sql-postgres
However, when I try to run the createTables.js process I get the following issue:
Failed to create 'visits' table: { Error: connect ECONNREFUSED 127.0.0.1:5432
at Object._errnoException (util.js:1026:11)
at _exceptionWithHostPort (util.js:1049:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1174:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 5432 }
Databases aren't really my strong point so I'm a bit stumped.
These are both running in the same GCloud Project also.
Let me know if you need me to supply any more info (not sure exactly what is useful)
Cheers,
Jay
To establish a connection between Google Cloud Postgres and App Engine, try these steps:
Enable the API
Install the proxy client on your local machine
Decide who will authenticate the proxy
Create a service account, in case your authentication method demands it
Decide how you will specify instances for your proxy
Start the proxy
Update your app and connect it to Googe Cloud Postgres

Sails rejecting PostgreSQL connection with sails-postgresql module

I have a sails web app in an intranet environment. An average of ~12 users are logged in at the same time. Eventually I get the classic connection refused message from sails-postgresql that lasts for at least 3 minutes, denying all http requests made to the app.
Error creating a connection to Postgresql using the following settings:
{
...
schema: true,
ssl: false,
adapter: 'sails-postgresql',
poolSize: 50
...
}
I either get { [Error: write ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'write' } or { [Error: write ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }.
My PostgreSQL logs the following message:
No connection could be made because the target machine actively refused it.
As you can see, my poolSize in sails.config.connections is set to 50 and my max_connections in postgresql.conf is set to 100. I'm not using this database for something else.
Is my poolsize set ok? Is it a problem from Sails or is it Postgres'?
Try increasing max_connections in postgres config file postgresql.conf, in my Ubuntu 15.04 linux it is located in this path:
/etc/postgresql/9.4/main/postgresql.conf

zoho email imap connection using node-imap is getting timeout in aws instance

I am using node-imap to connect and read zoho mail from my nodejs application, I am getting timeout err as below in AWS ubuntu instance, But in my local it is getting connected fine.
{ [Error: connect ETIMEDOUT]
code: 'ETIMEDOUT',
errno: 'ETIMEDOUT',
syscall: 'connect',
source: 'socket' }
Do i need to open any socket in AWS to use imap?
If so how i can do that?
You help regarding this is highly appreciated.
Thanks.

Error while running node-solr client

guys I am trying to run the example given on github in the following link.
https://github.com/lbdremy/solr-node-client
My port on which Solr runs is 8080.
Any of the files given in the examples directory I run gives the following error
{ [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect' }
Please help me out with this.
check this source code - https://github.com/lbdremy/solr-node-client/blob/master/lib/solr.js
solr uses 8983 port by default
create client with 8080 port, something like......
createClient('127.0.0.1', 8080, '', '/solr')

Resources