fix(dev): resolve postgres port conflict with local PostgreSQL installations#9
fix(dev): resolve postgres port conflict with local PostgreSQL installations#9deangoodmanson wants to merge 4 commits into
Conversation
macOS developers with a local PostgreSQL installation experienced
"role kruxiaflow does not exist" errors when running tests, because
both the Docker container and the local server bound port 5432 and
host TCP connections landed on the local server.
Changes:
- docker-compose.yml: expose Docker postgres on ${POSTGRES_PORT:-5433}:5432
so it no longer conflicts with a local postgres on 5432
- scripts/test.sh: load .env before setup so POSTGRES_PASSWORD and
POSTGRES_PORT are available; use ${POSTGRES_PORT:-5433} for DB_PORT
- .env.example: document POSTGRES_PORT with updated default and rationale
Container-internal references (postgres:5432) are unchanged — those
communicate over Docker's internal network and are unaffected.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| - "log_min_duration_statement=100" | ||
| ports: | ||
| - "5432:5432" | ||
| - "${POSTGRES_PORT:-5433}:5432" |
There was a problem hiding this comment.
I'd rather default to 5432 but I agree with having an override to other ports.
There was a problem hiding this comment.
The defaults are now reset to 5432
The ports environment variable overrides are still included
The potential conflict between local and docker PostgreSQL is noted in the documentation
Per review feedback, 5432 is the standard port and should remain the default. Developers with a local PostgreSQL installation can set POSTGRES_PORT=5433 (or any free port) in their .env to avoid conflicts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Updated in d7898d9 — reverted default back to 5432, kept the |
…ting CI runners have no local PostgreSQL so the example should use the standard 5432. Added a troubleshooting section explaining the port conflict scenario and how to resolve it with POSTGRES_PORT. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Sonnet PR review 3/20/26: PR #9 Review — fix(dev): resolve postgres port conflict with local PostgreSQL Core fix is correct. The ${POSTGRES_PORT:-5432}:5432 approach in docker-compose and the .env loading in test.sh Medium
Low
Info
The platform: linux/amd64 addition is the thing I'd push back on hardest before approving — it's the kind of |
Summary
5432:5432to${POSTGRES_PORT:-5432}:5432to allow overriding the host-side port via environment variable.envloading toscripts/test.shsoPOSTGRES_PORTandPOSTGRES_PASSWORDare picked up automatically.env.exampleto document how to usePOSTGRES_PORT=5433when a local PostgreSQL installation conflicts on port 5432Problem
On developer machines with a local PostgreSQL installation, both the local server and Docker bind to port 5432. TCP connections from the host (used by
cargo testandscripts/test.sh) silently hit the local server instead of Docker, causingrole "kruxiaflow" does not existerrors.This was discovered via
lsof -i :5432showing two processes on the same port.Test plan
docker-compose up -d postgres./scripts/test.sh --skip-db-setup(withDATABASE_URLpointing to port 5432)./scripts/test.shtest_invalidate_cache_key_requires_authand related cache handler tests passPOSTGRES_PORT=5433in.env, restart the postgres container (docker-compose up -d postgres), run./scripts/test.sh, confirm tests pass with norole "kruxiaflow" does not existerror🤖 Generated with Claude Code