Unable to connect to postgres DB running in container from WSL1

  Kiến thức lập trình

My setup,

  1. windows 10/ WSL1 (It’s my work laptop, and it has VPN)
  2. Ubuntu 22.04
  3. VScode with Postgres extension / pgadmin4

I managed to build the docker postgres image, and start up the container. And I am able to log into database from my laptop by using psql, within WSL1

enter image description here

But If I try to setup the connection using the postgres extension in VScode, or in pgadmin4, using the following connection details, I always get a timeout error.

enter image description here

If I disable the VPN, and try to setup the connection in either VScode or pgadmin4, it both works, seems like something to do with my VPN.
But I don’t understand why using psql within WSL1 doesn’t get affected at all. Whether VPN is on or not, I am always able to connect to the postgres DB from my laptop using psql.

Any suggestion to fix this issue? Thanks.

LEAVE A COMMENT