16

My problem is after postgresql installed try to configure postgresql database it's show error message like below:

dineshlap@ss-laptop:~$ sudo -u postgres psql postgres
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"?

and i tried lot of solutions from internet. but, nothing worked for me! :(

if you know the solution for this problem please, answer this post!

Note : I'm using ubuntu 14.04 (64 bit) and postgresql 9.3

4
  • Did you modify the postgresql.conf file in /etc/postgresql/9.3? The line listen_addresses = 'localhost' must be uncommented (without #).
    – xunilk
    May 21, 2015 at 12:57
  • @xunilk thanks for your response! i tried but, same problem occurs!
    – Dinesh
    May 22, 2015 at 5:47
  • Uninstall postgresql with purge and clean and try to install it again. I had a similar problem in Debian and I solved it in this way.
    – xunilk
    May 22, 2015 at 16:11
  • I solved my issue after correcting the pg_hba.conf file. I had removed the CIDR block info from the bindings section. Sep 12, 2016 at 17:48

5 Answers 5

28

Just try to restart

sudo /etc/init.d/postgresql restart

this worked for me :)

2
  • its asking for password. what's the default password here? Oct 7, 2016 at 8:57
  • 1
    @PranavSingh that's your sudo password nothing to do with psql
    – Talal
    Oct 8, 2016 at 12:10
3

Ubuntu16.04 and 9.3

sudo systemctl restart postgresql-9.3.service

Maybe you find out service before restarting server

service --status-all
2
  • 3
    This question is about 14.04, so you can't call systemctl. The other answer recommends restart. Seems very odd to include a version number in the command also - is this really needed?
    – Zanna
    Jan 11, 2017 at 3:53
  • 1
    My ubuntu is 16.04 on ubuntu 14.* try like "sudo service xyz start" Jan 11, 2017 at 14:48
0

In some case you may have permission issue. I create a shell script like this:

#!/bin/bash

chown -R $User:$User /var/run/postgresql
sudo /etc/init.d/postgresql restart

replace $User with your username, and execute the file (assuming the file name is postgresql.sh):

sudo ./postgresrun.sh
0

I had the same problem. after running

systemctl status [email protected]

It showed the following error

data directory "/var/lib/postgresql/9.6/main" has group or world access


SOLUTION

so I ran:

sudo chmod 0700 /var/lib/postgresql/9.6/main

Then I restarted:

sudo systemctl restart [email protected]

running sudo systemctl restart [email protected] showed my service active and running!

0

Try this one sir,

Edited your pg_hba.conf and add your host address :

local    all    postgres                     peer
host     all    all         127.0.0.1/24     md5

and also edited your postgres.confadd your queue with :

listen_addresses = " * "

and then restart your service :

sudo service postgresql restart

see your log output said what the miracled:

sudo tail -f /var/log/postgresql/postgresql-9.6-main.log

Hope this helps sir.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .