4
votes

I have installed postgresql 9.5.13, but it seems not to work. I get continiosly this message:

createuser: could not connect to database postgres: 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"?

when i try to create user. I have seen that this is common problem, but i can't find solution for this.

4
is postgres'es process running?m.antkowicz
I don't know, how i can check it?Bozidar Milivojevic
ps -aef | grep postgres and look for something with postmasterm.antkowicz
No, i only got this: bozo 22936 22734 0 17:33 pts/1 00:00:00 grep --color=auto postgresBozidar Milivojevic
then the process is dead you need to run postgresqlm.antkowicz

4 Answers

7
votes

See if the service is running

systemctl status postgresql

If PostgreSQL is running, you'll see output that includes the text Active: active (exited).

If you see Active: inactive (dead), start the PostgreSQL service using the following command:

systemctl start postgresql

PostgreSQL also needs to be enabled to start on reboot. Do that with this command:

systemctl enable postgresql

Run

pg_lsclusters

Ver Cluster Port Status Owner    Data directory               Log file
9.5 main 5433 online postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log
Status - online - fine
1
votes

Start the server using the default database path by typing this :

sudo -i -u postgres

/usr/lib/postgresql/9.5/bin/pg_ctl -D /var/lib/postgresql/9.5/main/ -l logfile start

than try:

psql

Done !

0
votes

Due to comments - you need to run the database process - take a look at the documentation


In a nutshell it should be something like

    postgres -D /usr/local/pgsql/data >logfile 2>&1 &

depending on what log file you want to create

0
votes

One thing I discovered to get this to work is to:

sudo chmod 777 /var/run/postgresql

and then restart like in the above comments.