Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
936 views
in Technique[技术] by (71.8m points)

amazon web services - Unable to connect with AWS Aurora PostgreSQL?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...