psql: server closed the connection unexepectedly
Solution 1:
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:
- Look at your postgresql.conf,
sudo vim /etc/postgresql/9.3/main/postgresql.conf
- Add this line:
listen_addresses = '*'
- Restart the service
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
Solution 2:
It turns out it is because there was a mismatch between the postgre SQL version between my local and the server, installing the same version of PostgreSQL in my computer fixed the issue. Thanks!