[英]Pool connection timeout - connecting to AWS RDS from EC2
I am trying to connect to an Amazon RDS (Postgres) instance from an EC2 server via a NodeJS application using the pg npm package.我正在尝试使用 pg npm 包通过 NodeJS 应用程序从 EC2 服务器连接到 Amazon RDS (Postgres) 实例。 The error I am receiving an error (note i'm hitting my node backend via a react app): OPTIONS /users/login 200 0.424 ms - 2 Error fetching client from pool Error: Connection terminated due to connection timeout我收到错误的错误(注意我正在通过反应应用程序访问我的节点后端): OPTIONS /users/login 200 0.424 ms - 2 Error fetching client from pool Error:连接因连接超时而终止
I have tested the app locally and everything works perfectly (including connecting to RDS), but as soon as I run the app on the server I can't connect.我已经在本地测试了该应用程序并且一切正常(包括连接到 RDS),但是一旦我在服务器上运行该应用程序,我就无法连接。
To simplify the problem, I have just typed my credentials explicitly into the NodeJS route file so I know there's no issues with environment variables etc. I then pushed my code to the server, pulled it as-is, and ran it.为了简化问题,我刚刚在 NodeJS 路由文件中明确输入了我的凭据,所以我知道环境变量等没有问题。然后我将我的代码推送到服务器,按原样提取并运行它。 No luck.没运气。 From a connection perspective, I just create a pool (require pool from pg) and then use pool.connect and client.query to make the request.从连接的角度来看,我只是创建了一个池(需要来自 pg 的池),然后使用 pool.connect 和 client.query 来发出请求。
I feel like given that it works locally that the issue is an AWS one with my networking/security groups, but I feel like I have tried everything:我觉得考虑到它在本地工作,问题是我的网络/安全组的 AWS 问题,但我觉得我已经尝试了一切:
Any help would be much appreciated.任何帮助将非常感激。 I am going insane我快疯了
Connect to your server and try to debug the connection with telnet or a PostgreSQL client.连接到您的服务器并尝试使用 telnet 或 PostgreSQL 客户端调试连接。
The most common mistakes for this error are:此错误最常见的错误是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.