简体   繁体   English

出于开发目的,无法从本地主机连接到 AWS RDS Postgresql

[英]Cannot connect to AWS RDS Postgresql from local host for dev purposes

I am developing an application to learn AWS.我正在开发一个应用程序来学习 AWS。 I am using react and nodejs as a backend.我使用 react 和 nodejs 作为后端。 I created AWS RDS Postgresql database and able to connect to it using pgadmin, and nodejs on a local host( I assume it is connected bc pgAdmin shows 2 connections when localhost port is running).我创建了 AWS RDS Postgresql 数据库,并能够使用 pgadmin 和本地主机上的 nodejs 连接到它(我假设它已连接 bc pgAdmin 在 localhost 端口运行时显示 2 个连接)。 Using pgAdmin I am able to create tables and put data into the tables using SQL queries.使用 pgAdmin,我可以使用 SQL 查询创建表并将数据放入表中。

However, I am NOT able to make Post or Get requests from the database using react and/or nodejs with proxy and without proxy.但是,我无法使用带有代理和不带代理的 react 和/或 nodejs 从数据库发出 Post 或 Get 请求。 It seems that it does not allow it to bc of security issues?似乎它不允许它解决安全问题? I also set the security group to public and All Access.我还将安全组设置为 public 和 All Access。

Is it possible to make a Post request and a Get request to the database from localhost with proxy or without?是否可以使用代理或不使用代理从本地主机向数据库发出 Post 请求和 Get 请求? So far it either gives me 404 Not Found or ERR_Connection Refused.到目前为止,它要么给我 404 Not Found 要么 ERR_Connection Refused。

If not, then how one develops an application using AWS RDS on one's own computer?如果不是,那么如何在自己的计算机上使用 AWS RDS 开发应用程序?

I had similar issues using mySQL.我在使用 mySQL 时遇到了类似的问题。 This solved my issue.这解决了我的问题。 By default AWS does not allow other services outside it's VPC connect to db instances.默认情况下,AWS 不允许其 VPC 之外的其他服务连接到数据库实例。 to enable remote access,启用远程访问,

  • Go to your RDS tab and click on the db instance Go 到您的 RDS 选项卡,然后单击数据库实例
  • Under security, click on Vpc security group (click on the one with active beneath it)在安全下,点击Vpc security group (点击下面有活动的那个)
  • You should be on another page now.您现在应该在另一个页面上。 The security group should be selected by default.默认情况下应选择安全组。
  • Click on the Actions dropdown menu and click on Edit Inbound rules单击Actions下拉菜单,然后单击Edit Inbound rules
  • Add a new rule.添加新规则。 type should be All traffic , source should be custom , then you can enter the IP address of your local machine. type 应该是All traffic traffic , source应该是custom ,然后你可以输入你本地机器的 IP 地址。 you can select anywhere if you're not sure what you IP is or if your IP is not static.如果您不确定 IP 是什么,或者如果您的 IP 不是 ZA81247291CEF8E959D26

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM