简体   繁体   中英

Unable to connect to server: postgresql on ubuntu in windows subsystem for linux

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM