9

I'm using WSL with an ubuntu 18.04 distribution, in the bash I hit sudo -u postgres psql I get the following 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.5433"?

Then I tried other postgres operations like: sudo -u createdb mydb only to get the same error.

Please advise.

1
  • Hi, did you ever figure this out? Commented Apr 20, 2020 at 20:36

1 Answer 1

13

When running PostgreSQL on Ubuntu in Windows Subsystem for Linux, you may have to manually start the db server before you can connect. Use the command below to start your db server and then try connecting.

sudo service postgresql start

OR

sudo /etc/init.d/postgresql start

You can also check the status of the db server with:

sudo service postgresql status

Sign up to request clarification or add additional context in comments.

1 Comment

I'm having the same problem as the OP. The service is running, but connecting to it isn't possible even with the same setting that were working the day before. I think Postgres is just borked on WSL, or requires some kind of hacky workaround. Just go full Linux folks, nothing like the real thing...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.