In the windows Linux Subsystem, I installed ubuntu 18.04

In there, I installed postgresql 11 using sudo apt-get install postgresql-11

I got this back

Ver Cluster Port Status Owner Data directory Log file 11 main 5432 down postgres /var/lib/postgresql/11/main /var/log/postgresql/postgresql-11-main.log

When I run "psql", I get the 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"?

Then I tried to specify a folder, like this

psql -h /var/lib/postgresql/11/main

and I get this error...

psql: could not connect to server: Permission denied Is the server running locally and accepting connections on Unix domain socket "/var/lib/postgresql/11/main/.s.PGSQL.5432"?

Any hint?


  • Instead of Status =down you want Status=online. When it's down, the instance may be started with pg_ctlcluster 11 main start. apt-get install does it by default normally but maybe it encountered an error. – Daniel Vérité Feb 16 '19 at 14:00
  • According to the documentation, I should start the server using postgres -D ... but postgres is not found... whereis postgres only reports the man pages... Bizarre? – Eric Mamet Feb 16 '19 at 15:55
  • That's just one way of starting the server, when you want to ignore the infrastructure brought by the package and do all by yourself. The doc you want is more like this one: manpages.ubuntu.com/manpages/trusty/en/man8/… – Daniel Vérité Feb 16 '19 at 16:58
  • Silly me, I had missed an instruction /usr/lib/postgresql/11/bin/pg_ctl -D /var/lib/postgresql/11/main -l logfile start But now I get "waiting for server to start..../bin/sh: 1: cannot create logfile: Permission denied" and the log file exists but is empty... – Eric Mamet Feb 16 '19 at 17:23
  • 1
    Looks like I should have replaced "logfile" by the actual name of that logfile: "/var/log/postgresql/postgresql-11-main.log" Now, I get something meaningful in that logfile: "postgres: could not access the server configuration file "/var/lib/postgresql/11/main/postgresql.conf": No such file or directory" – Eric Mamet Feb 16 '19 at 17:41

I had missed an instruction to start the server...

It finally started with the following instruction

sudo -u postgres /usr/lib/postgresql/11/bin/pg_ctl -D /etc/postgresql/11/main -l /var/log/postgresql/postgresql-11-main.log start
| improve this answer | |
  • Indeed, actually silly that the installation says this usr/lib/postgresql/11/bin/pg_ctl -D /var/lib/postgresql/11/main -l logfile start instead of the default /var/log/postgresql/... location for the logfile. – peter_v Nov 15 '19 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.