Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

createuser could not connect to database postgres

Please don't move this question to askubuntu as I think this question is not OS-specific.

When I invoke the createuser postgres command (for now it doesn't matter if I provide any parameters or not), I'm getting this error:

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 "/tmp/.s.PGSQL.5432"?

Normally it means that the postgres server is down but not this time:

pg_lsclusters
Ver Cluster Port Status Owner    Data directory               Log file
9.4 main    5432 online postgres /var/lib/postgresql/9.4/main /var/log/postgresql/postgresql-9.4-main.log

sudo service postgresql status
9.4/main (port 5432): online

But it's true that there is no /tmp/.s.PGSQL.5432 file because my configuration file (/etc/postgresql/9.4/main/postgresql.conf) has this line:

unix_socket_directories = '/var/run/postgresql'

So I don't really understand why createuser whants to access /tmp/.s.PGSQL.5432? Can this path can be hardcoded into the createuser binary? I don't see any command line argument to specify the settings file location for createuser...

like image 266
mnowotka Avatar asked Jul 25 '26 10:07

mnowotka


1 Answers

Have you started the service?

service postgresql start
like image 81
Deming Avatar answered Jul 28 '26 05:07

Deming



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!