I have started to develop a Flask app using VSCode/WSL1 and have then migrated from WSL1 to WSL2.
Since then, I cannot connect to my the database running on windows using "localhost"
DATABASE_URI = 'postgresql://sysadmin:mypassword@localhost/db_dev'
I can only connect if use the ip address found in "cat /etc/resolv.conf"
DATABASE_URI = 'postgresql://sysadmin:mypassword@172.31.96.1:5432/db_dev'
But that IP address changes on every reboot, so that is not convenient at all. It looks like networking has changed quite a bit between WSL and WSL2, but I cannot find an acceptable solution to this I would say rather basic issue.
There are no problems with my Postgres config, as I can connect using the ip address.