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

Dinesh
  • 281

5 Answers5

28

Just try to restart

sudo /etc/init.d/postgresql restart

this worked for me :)

Talal
  • 899
3

Ubuntu16.04 and 9.3

sudo systemctl restart postgresql-9.3.service

Maybe you find out service before restarting server

service --status-all
0

I had the same problem. after running

systemctl status postgresql@9.6-main.service

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 postgresql@9.6-main.service

running sudo systemctl restart postgresql@9.6-main.service 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.

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