[英]Connect to postgres database on local linux install
I'm trying to figure out how to connect via my ruby app using PGConn in order to connect to my postgres database on the aws ec2 linux server. 我试图弄清楚如何使用PGConn通过我的ruby应用程序进行连接,以便连接到AWS EC2 Linux服务器上的postgres数据库。
db_connection = PGconn.connect("ip-172-31-90.9.us-west-2.compute.internal", 5432, '', '', "testdb", "username", "password")
I keep getting an error 我不断收到错误消息
app.rb:21:in `initialize': could not translate host name "ip-172-31-90-9.us-west-2.compute.internal." to address: nodename nor servname provided, or not known (PG::ConnectionBad)
I ran /sbin/ifconfig -a on the linux server to get the IP address, but it still can't connect. 我在linux服务器上运行/ sbin / ifconfig -a来获取IP地址,但是它仍然无法连接。 I also edited the files per the instructions from the site http://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html
我还按照http://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html网站上的说明编辑了文件
IP of "ip-172-31-90-9" seems private IP address. IP“ ip-172-31-90-9”似乎是私有IP地址。
So what you need do: 因此,您需要执行以下操作:
0.0.0.0/0
or any IP ranges in your case 0.0.0.0/0
或您所用的任何IP范围 test the port from your local 从本地测试端口
telnet NEW_Public_IP 5432 远程登录NEW_Public_IP 5432
If can, then you should be fine to connect the database. 如果可以,那么连接数据库应该没问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.