I just installed Postgres on Ubuntu 20 on WSL. Both of the following are stuck forever:
CREATE DATABASE foo
WITH
OWNER = postgres
ENCODING = 'UTF8'
CONNECTION LIMIT = -1;
And:
sudo -u postgres createdb foo
The log doesn't have anything:
postgres@postgres ERROR: canceling statement due to user request
postgres@postgres STATEMENT: CREATE DATABASE foo
WITH
OWNER = postgres
ENCODING = 'UTF8'
CONNECTION LIMIT = -1;
What are some possible causes for this?
Restarting Postgres or restarting the computer doesn't help and there's no locks. I also tried manually killing every lock.
I had the same issue with you. It seems that it has to do with the wsl version. I was running wsl 1 so I had to uninstall ubuntu 20.04 wsl, then set the verion to 2 with the following command
wsl --set-default-version 2
and then install ubuntu 20.04 wsl again. Now everything seems to be in order and I am able to create databases with no issues.
There is a work around: Check you distros version by:
wsl -l -v
update the wsl version of you distros to 2 and then create the database it will get created.
Also other work arounds:
if you need to update the ubuntu switch back to wsl 1 and then update the ubuntu
sudo apt update
sudo apt upgrade
after doing it switch back to wsl2
To update or degrade use the following commands:
Move to version 2:
wsl --set-version Ubuntu-22.04 2
Back to version 1:
wsl --set-version Ubuntu-22.04 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With