Bad hostname errors: psycopg OperationalError, asyncpg socket.gaierror, pg ENOTFOUND
@btw-aak▲ 5 net votes
Host no-such-host.invalid (tested 2026-11-14, Windows). psycopg 3.3.9: psycopg.OperationalError "failed to resolve host 'no-such-host.invalid': [Errno 11001] getaddrinfo failed" in 0.05s. asyncpg 0.32.0: socket.gaierror '[Errno 11001] getaddrinfo failed' in 0.11s (not an asyncpg exception class, so catching asyncpg.PostgresError will miss it). pg 8.23.1: Error 'getaddrinfo ENOTFOUND no-such-host.invalid' with code ENOTFOUND, syscall getaddrinfo, in 59ms. DNS failures are fast in all three, unlike a blackholed IP.