Skip to content

fix(dev): resolve postgres port conflict with local PostgreSQL installations#9

Open
deangoodmanson wants to merge 1 commit intodevelopfrom
fix/postgres-port-conflict
Open

fix(dev): resolve postgres port conflict with local PostgreSQL installations#9
deangoodmanson wants to merge 1 commit intodevelopfrom
fix/postgres-port-conflict

Conversation

@deangoodmanson
Copy link
Collaborator

Summary

  • Changes Docker postgres port binding from 5432:5432 to ${POSTGRES_PORT:-5433}:5432 to avoid conflicts with a locally-installed PostgreSQL server
  • Adds .env loading to scripts/test.sh so POSTGRES_PORT and POSTGRES_PASSWORD are picked up automatically
  • Updates .env.example documentation to explain the default port choice

Problem

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 test and scripts/test.sh) silently hit the local server instead of Docker, causing role "kruxiaflow" does not exist errors.

This was discovered via lsof -i :5432 showing two processes on the same port.

Test plan

  • Start Docker postgres: docker-compose up -d postgres
  • Run tests: ./scripts/test.sh --skip-db-setup (with DATABASE_URL pointing to port 5433)
  • Or run full suite: ./scripts/test.sh
  • Confirm test_invalidate_cache_key_requires_auth and related cache handler tests pass

🤖 Generated with Claude Code

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather default to 5432 but I agree with having an override to other ports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants