I am using serverless framework and AWS Aurora PostgreSQL with node-express.
When i am trying connect with PostgreSQL locally it is working fine, but when i am deploying the app on aws (lambda function), it's not working.
Log error is like :
ECONNREFUSED 127.0.0.1:5000
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16) {
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 5000
}
here is my code :
const { Pool, Client } = require("pg");
const client = new Client({
user: "postgres",
host: "my_cluster.us-east-1.rds.amazonaws.com",
database: "postgres",
password: "passwor",
port: 5000,
});
client.connect().then(
(data) => {
console.log("Successfully connected to Postgres");
},
(err) => {
console.log("Error While Connecting to Postgres", err);
}
);
question from:
https://stackoverflow.com/questions/65840333/unable-to-connect-with-aws-aurora-postgresql 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…