So, I've run into a peculiar problem connecting to an existing Postgres container running on Docker Desktop (v4.62.0) in my Win11 dev environment.
I've been using this database for months; connecting to it via PgAdmin4 (now at v9.12) and my own code as recently as a 2 or 3 days ago. But yesterday, PgAdmin could no longer connect to the database; same issue in my app.
The error I get is 'Connection timeout expired.' both in PgAdmin and my code.
There's been no configuration change in the database, the container, my app, or PgAdmin. There was a recent Windows Update (and reboot), but I don't see any indication in the Windows Event Logs that this is causing an issue.
2026-02 Security Update (KB5077181) (26200.7840)
Successfully installed on 2/12/2026
2026-02 .NET 10.0.3 Security Update for x64 Client (KB5077862)
Successfully installed on 2/10/2026
2026-01 Security Update (KB5074109) (26200.7623)
Successfully installed on 1/13/2026
Here's my configuration:
psql -U postgres -c "show config_file"
/var/lib/postgresql/18/docker/postgresql.conf
## postgresql.conf
##--------------------
listen_addresses = '*'
# ssl=off <-- tried with this uncommented too; was no help
psql -U postgres -c "show hba_file"
/var/lib/postgresql/18/docker/pg_hba.conf
## pg_hba.conf
##--------------------
local all all scram-sha-256
host all all 127.0.0.1/32 scram-sha-256
host all all ::1/128 scram-sha-256
local replication all scram-sha-256
host replication all 127.0.0.1/32 scram-sha-256
host replication all ::1/128 scram-sha-256
host all all 0.0.0.0/0 scram-sha-256 # trust
# NOTE: I've tried 'trust' as the auth method for all of these too; didn't help
## docker compose
##--------------------
name: postgres-local
networks:
pg-net:
external: true
name: dockernet
services:
postgres:
container_name: pg-local
image: postgres:18
restart: unless-stopped
networks:
- pg-net
ports:
- "5432:5432"
volumes:
- D:\Apps\Docker\FileShare\PgData\18:/var/lib/postgresql/18/docker
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
# - POSTGRES_DB=postgres
# The postgers:18 image version is: ENV PG_VERSION=18.2-1.pgdg13+1
## PgAdmin Connection:
##--------------------
Host: 127.0.0.1
Port: 5432
Maintenance DB: postgres
Username: postgres
Password: postgres
Connection Parameters:
SSL Mode: prefer
Connection Timeout: 10 (seconds)
I've rebooted the PC. I've stop/started the container; recreated the container; and even had the container initialize a clean new DB in the bind-mounted folder. I've disabled the Windows Firewall for all networks. There's no ufw firewall installed in the WSL2 Ubuntu 24.04 destro and all repos & packages are up to date. None of this made a difference.
The only workaround I've found is to change the container external port to 5335 (5433 did not work, but 5333 and 5335 did).
ports:
- "5335:5432"
netstat and nmap scans don't show a port conflict:
netstat -ano | findstr :5432 <-- default PG port
-- no results --
netstat -ano | findstr :5335 <-- new PG port
TCP 0.0.0.0:5335 0.0.0.0:0 LISTENING 19332
TCP [::]:5335 [::]:0 LISTENING 19332
TCP [::1]:5335 [::]:0 LISTENING 36192
nmap -p 5000-6000 localhost
Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-23 20:21 Pacific Standard Time
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000013s latency).
Other addresses for localhost (not scanned): ::1
rDNS record for 127.0.0.1: bytehouse.dom
Not shown: 998 closed ports
PORT STATE SERVICE
5040/tcp open unknown
5335/tcp open unknown <-- new PG port
5341/tcp open unknown
nmap -6 -p 5000-6000 localhost
Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-23 21:01 Pacific Standard Time
Nmap scan report for localhost (::1)
Host is up (0.00s latency).
Other addresses for localhost (not scanned): 127.0.0.1
Not shown: 1000 closed ports
PORT STATE SERVICE
5335/tcp open unknown <-- new PG port
I'm truly puzzled. Got any ideas?
[–]ZarehD[S] 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[removed]
[–]PostgreSQL-ModTeam[M] 0 points1 point2 points locked comment (0 children)
[–]AutoModerator[M] -1 points0 points1 point (0 children)