Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HEROKU POSTGRES error: Connection refused Is the server running on host "..compute-1.amazonaws.com..." and accepting TCP/IP connections on port 5432?

I have been trying for weeks to figure out what's the issue, but I cannot seem to fix this.

I am developing a web app, and I have deployed to production using Heroku. I'm using Heroku Postgres for my database, and I'd like to psql into that hosted database from my local machine to make changes to it. I have tried from both Mac OS X and Linux Mint.

However, no matter what I try, I keep getting the following error:

---> Connecting to HEROKU_POSTGRESQL_ORANGE_URL (DATABASE_URL)
psql: could not connect to server: Connection refused
    Is the server running on host "ec2-***-**-***-**.compute-1.amazonaws.com" (***.**.***.**) and accepting
    TCP/IP connections on port 5432?

I'm starting to think that I may have to SSH into the Amazon EC2 instance and change the Postgres configuration? Would that even be possible?

like image 552
Brian Avatar asked Jul 23 '15 04:07

Brian


People also ask

How do I connect to my Heroku Postgres database?

The quickest method is right through your app dashboard on Heroku. Go to your app page, from here you can click the "Heroku Postgres" link, that will take you to the database settings page at data.heroku.com. You can also go directly to https://data.heroku.com/ and choose your correct database.


1 Answers

You can't connect directly to the EC2 instance where the Heroku Postgres instance is running; it is managed by Heroku and normal users aren't allowed to connect to it.

If your application is running fine in Heroku, and you're running heroku pg:psql to attempt to connect to the DB, then most likely there is some issue with your local network that is preventing you from connecting to the Postgres database, like a firewall blocking outbound connections. Heroku Postgres databases are open to the public without any restriction on IP ranges.

like image 120
Ken Liu Avatar answered Nov 10 '22 19:11

Ken Liu