Why am I seeing "psql: could not connect to server: Connection timed out"?

Issue

When trying to run heroku pg commands I am seeing the following error:


--> Connecting to postgresql-example-12345
psql: could not connect to server: Connection timed out (0x0000000C/10000)
Is the server running on host "ec2-123-45-678-910.compute-1.amazonaws.com" (123.45.67.89) and accepting
TCP/IP connections on port 5432?

Resolution

This error is because the heroku command line tools are unable to use the required ports. This is often because a corporate firewall is blocking the following ports:

  • 5432 - this is required for communicating with Postgres database
  • 5000 - this is required for communication with one-off dynos (e.g. heroku run bash)

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support