I'm running the new Windows Subsystem for Linux 2 (WSL-2), with Ubuntu 18.04. It is really fast, and running great, except I can't seem to connect to an external PostgreSQL database using Python. It just hangs, never responding. Here's a minimal reproduction:
$ python3.6
Python 3.6.8 (default, Jan 14 2019, 11:02:34)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> psycopg2.connect(host="my-pg-server.mydomain.com", port=5432, user="my_user", dbname="my_db", password="")
[...crickets... doesn't time out, just hangs forever (at least an hour)...]
It isn't a firewall issue, as I can connect with telnet to the same host:
$ telnet my-pg-server.mydomain.com 5432
Trying 123.456.789.100...
Connected to my-pg-server.mydomain.com.
Escape character is '^]'.
The other weird part is that I can connect to an external SQL Server database. I'm sure the credentials are correct for both servers, they're directly from a Django settings file that I'm using just fine on other systems. Any ideas? Is there something I have to do with psycopg2 specifically for WSL-2?