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
Related
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?
I am using memcached locally to store user sessions.
To work with memcached I use the npmjs.com/package/memcached
After upgrading nodes to version v18.7.0, the server stopped connecting to memcached at localhost:11211
However, when the address is changed to 127.0.0.1:11211, the connection proceeds normally, but an error still occurs during further work:
Error: connect ECONNREFUSED ::1:11211
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1247:16) {
[stack]: 'Error: connect ECONNREFUSED ::1:11211\n' +
' at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1247:16)',
[message]: 'connect ECONNREFUSED ::1:11211',
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 11211
}
What could be causing this and how to fix it?
The problem was that memcached was configured to accept connections only via IPv4.
After adding in the settings for receiving connections via IPv6, everything worked.
I have 3 servers which run a MongoDB replicaset, 1 primary, 1 secondary, 1 arbiter. And I have problem connecting to this replicaset. Tested with a test.js file which runs on localhost and a spare server.
Connect from localhost, node 6.5.0: OK
Connect from localhost, node 10.15.1: FAILED
Connect from the spare server, node 6.5.0: OK
Connect from the spare server, node 10.15.1: OK
Here's my test.js file:
const MongoClient = require("mongodb").MongoClient;
const url = "mongodb://root:password"+
"#mgdb1.mydomain,mgdb2.mydomain/vApp?replicaSet=rs0&authSource=admin";
console.log("Connecting...");
MongoClient.connect(url,(err,client)=>{
if (err!=null){
console.log("Error:",err);
return;
}
console.log("Connected.");
process.exit();
});
The strange thing is that it shows ECONNREFUSED error, but not at the IP of the 3 servers in the replicaset, it's the IP in range of my ISP. So why does it fail afterConnect? It shows TCPConnectWrap.afterConnect, does it mean the connection is already made?
The error is this way:
Connecting...
(node:1412) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
Error: { Error: connect ECONNREFUSED 125.235.4.59:27017
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1104:14)
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '125.235.4.59',
port: 27017 }
Edit:
My current work-around is connecting directly to the primary server without replicaset=rs0, however, this is not the desired manner.
I found out the problem. When created the replica set on a group of machines on cloud, the addresses to the servers are server names which are known only by other machines on the same server LAN. On localhost in office, there are no such server names.
Work-around 1:
Connect only to the primary or secondary server
Work-around 2:
Edit /etc/hosts file (or c:\windows\system32\drivers\etc\hosts)
Point the name of the servers to their appropriate IPs
I am trying to connect to a Firebase db from behind a corporate proxy.
Getting below error
error: { Error: connect ECONNREFUSED 35.201.97.85:443
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1198:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '35.201.97.85',
port: 443 }
statusCode: undefined
body: undefined
It works perfectly if I connect to my personal hotspot. Any way to make it work on corporate network.
You need to set proxy inside the .npmrc file
for Windows
1. Go to C:/Users/Username
2. Create or find .npmrc file
3. Add proxy entry inside the file
for linux
Execute following command to find .npmrc file and add the proxy entry inside it. Use following command to list the file:
npm config ls -l | grep config
or you can try following command:
npm config set proxy "http://domain\username:password#servername:port/"
or
npm config set proxy "http://domain%5Cusername:password#servername:port/"
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.