3

I am trying to install postgresql on ubuntu. I followed the steps from http://hocuspokus.net/2008/05/install-postgresql-on-ubuntu-804/.

And on typing the command :

psql template1

I am getting the following error:

 psql: could not connect to server: No such file or directory
     Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
7
  • 1
    If you run /etc/init.d/postgresql status does it tell you its running? Commented Nov 28, 2011 at 9:17
  • It says "No such file or directory" Commented Nov 28, 2011 at 9:19
  • 1
    If you ls -l /etc/init.d/ | grep postgres, do you see see anything? Commented Nov 28, 2011 at 9:23
  • No I am able to see only postgresql-8.4.dpkg-dist Commented Nov 28, 2011 at 9:25
  • Looks like you messed up some part of the installation process. Try removing then reinstalling. stackoverflow.com/questions/2748607/… may be helpfull. Commented Nov 28, 2011 at 9:30

5 Answers 5

1

The problem for me was that I had previously installed version 9.1, and 9.1 was still hogging the default port 5432. I was able to find this with the command:

root@labs:/home/caleb# /etc/init.d/postgresql status
9.1/main (port 5432): down
9.2/main (port 5433): online

So I was able to see that my 9.2 database was running on port 5433. So to connect, I had to explicitly specify port 5433:

psql -p 5433
Sign up to request clarification or add additional context in comments.

Comments

0

try the following

psql template0

Comments

0

what resolved this error for me was deleting a file called postmaster.pid in the postgres directory. please see my question/answer using the following link for step by step instructions. my issue was not related to file permissions:

psql: could not connect to server: No such file or directory (Mac OS X)

Comments

0

You can also get in the CLI via this command:

psql -U postgres -p 5432 -h localhost

Comments

0

This should solve the error,

make a symbolic link to the /tmp/.s.PGSQL.5432:

sudo ln -s /tmp/.s.PGSQL.5432 /var/run/postgresql/.s.PGSQL.5432

Thanks to this post

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.