Leaving this here for info,
This error can also be caused if PostgreSQL server is on another machine and is not listening on external interfaces.
To debug this specific problem, you can follow theses steps:
sudo vim /etc/postgresql/9.3/main/postgresql.conf
listen_addresses = '*'
sudo /etc/init.d/postgresql restart
(Note, the commands above are for ubuntu. Other linux distro or OS may have different path to theses files)
Note: using '*'
for listening addresses will listen on all interfaces. If you do '0.0.0.0'
then it'll listen for all ipv4 and if you do '::'
then it'll listen for all ipv6.
http://www.postgresql.org/docs/9.3/static/runtime-config-connection.html