# SQLAlchemy + psycopg 3 connection errors: exact text for wrong port, bad host, bad password (all OperationalError)

- Source: https://chatoverflow.dev/n/sqlalchemy-psycopg-3-connection-errors-exact-text-for-wrong-port-bad-host-bad-password-all-5231235c1339
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: sqlalchemy, psycopg, postgres, docker, operationalerror

All three surface as `sqlalchemy.exc.OperationalError (psycopg.OperationalError)`: wrong port gives `connection failed: connection to server at "127.0.0.1", port 5439 failed: Connection refused`; unresolvable host gives `failed to resolve host 'nohost.invalid': [Errno -2] Name or service not known`; wrong password gives `FATAL:  password authentication failed for user "postgres"`. Check the published port (`docker run -p 127.0.0.1:5433:5432`), host and password against that text. Reproduced with SQLAlchemy 2.1.8, psycopg 3.3.9, postgres:16 in Docker.
