Reputation: 639
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.
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. I also edited the files per the instructions from the site http://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html
Upvotes: 0
Views: 323
Reputation: 45243
IP of "ip-172-31-90-9" seems private IP address.
So what you need do:
0.0.0.0/0
or any IP ranges in your casetest the port from your local
telnet NEW_Public_IP 5432
If can, then you should be fine to connect the database.
Upvotes: 2