Unable to connect to Postgres on Vagrant Box - Connection refused
- by Ben Miller
First off, I'm new to Vagrant and Postgres.
I created my Vagrant instance using http://files.vagrantup.com/lucid32.box with out any trouble. I am able to run vagrant up and vagrant ssh with out issue.
I followed the instructions http://blog.crowdint.com/2011/08/11/postgresql-in-vagrant.html with one minor alteration. I installed "postgresql-8.4-postgis" package instead of "postgresql postgresql-contrib"
I started the server using:
postgres@lucid32:/home/vagrant$ /etc/init.d/postgresql-8.4 start
While connected to the vagrant instance I can use psql to connect to the instance with out issue.
In my Vagrantfile I had already added:
config.vm.forward_port 5432, 5432
but when I try to run psql from localhost I get:
psql: could not connect to server: Connection refused
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
I'm sure I am missing something simple. Any ideas?
Update:
I found a reference to an issue like this and the article suggested using:
psql -U postgres -h localhost
with that I get:
psql: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.