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"?
Christian Rau
  • 45,360
  • 10
  • 108
  • 185
ramya
  • 928
  • 5
  • 14
  • 30
  • 1
    If you run `/etc/init.d/postgresql status` does it tell you its running? – Sam Dolan Nov 28 '11 at 09:17
  • It says "No such file or directory" – ramya Nov 28 '11 at 09:19
  • 1
    If you `ls -l /etc/init.d/ | grep postgres`, do you see see anything? – Sam Dolan Nov 28 '11 at 09:23
  • No I am able to see only postgresql-8.4.dpkg-dist – ramya Nov 28 '11 at 09:25
  • Looks like you messed up some part of the installation process. Try removing then reinstalling. http://stackoverflow.com/questions/2748607/how-to-thoroughly-purge-and-reinstall-postgresql-on-ubuntu may be helpfull. – Sam Dolan Nov 28 '11 at 09:30
  • Hi,I installed and reinstalled again using apt-get install postgresql postgresql-client postgresql-contrib pgadmin3. Still I am not able to see /etc/init.d/postgresql status -bash: /etc/init.d/postgresql: No such file or directory – ramya Nov 28 '11 at 09:38
  • The postgres startup script would be /etc/init.d/postgresql-8.4. What do you see now from `ls -l /etc/postgres*`? Also what version of Ubuntu are you running? – Karlson Dec 16 '11 at 14:25

5 Answers5

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
caleb
  • 2,687
  • 30
  • 25
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)

Community
  • 1
  • 1
FireDragon
  • 9,325
  • 4
  • 27
  • 34
0

You can also get in the CLI via this command:

psql -U postgres -p 5432 -h localhost

Hrishikesh Choudhari
  • 11,617
  • 18
  • 61
  • 74
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

0

try the following

psql template0

vijikumar
  • 1,805
  • 12
  • 16