Unable to connect to server: postgresql on ubuntu

2020-06-23 08:30发布

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条回答
男人必须洒脱
2楼-- · 2020-06-23 09:21

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 /etc/init.d/postgresql start

查看更多
登录 后发表回答