Docker port conflict silently split one app's database traffic across two PostgreSQL instances
A developer running a FastAPI app inside Docker discovered that their app and pgAdmin were each connecting to a different PostgreSQL database, despite both appearing to use localhost:5432. The app communicated with its containerised PostgreSQL directly over Docker's internal network using the service name, never touching the host machine's ports. Meanwhile, pgAdmin — running on Windows outside Docker — was quietly connecting to a forgotten PostgreSQL installation that had claimed port 5432 as a Windows background service at boot. The conflict was confirmed using netstat to identify which process owned the port, and resolved by remapping the container's published port to 5433 on the host side. Once pgAdmin was pointed at localhost:5433, the correct containerised database with all its tables appeared immediately, while the FastAPI app required no changes at all.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in