🐛 Bug Report: Cannot connect to postgres db #164

Closed
opened 2025-10-07 23:55:56 +03:00 by OVERLORD · 0 comments
Owner

Originally created by @ezcafe on GitHub.

Reproduction steps

Hi team, I cannot make it work with postgres
It always said "connection refused"

This is my docker file

services:

  pocket-id:
    image: ghcr.io/pocket-id/pocket-id
    container_name: pocket-id
    restart: unless-stopped
    env_file: .env
    ports:
      - ${PORT}:1411
    healthcheck:
      test: "curl -f http://localhost:1411/healthz"
      interval: 1m30s
      timeout: 5s
      retries: 5
      start_period: 10s
    volumes:
      - pocket-id:/app/data
    depends_on:
      - db

  db:
    image: postgres:16.1
    container_name: pocket-id-db
    restart: unless-stopped
    env_file: .env
    healthcheck:
      test:
        ['CMD-SHELL', 'pg_isready -d "$${POSTGRES_DB}" -U $${POSTGRES_USER}']
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - data:/var/lib/postgresql/data/

volumes:
  pocket-id:
  data:

Expected behavior

It could connect to postgres

Actual Behavior

It's showing error like this

dial error: dial tcp 0.0.0.0:5432: connect: connection refused

Version and Environment

PORT=19945

APP_URL=https://auth.example.com
TRUST_PROXY=true
MAXMIND_LICENSE_KEY=
PUID=1000
PGID=1000

DB_PROVIDER=postgres
DB_CONNECTION_STRING=postgresql://pocket-id:secret@0.0.0.0:5432/pocketid-db

POSTGRES_USER=pocket-id
POSTGRES_PASSWORD=secret
POSTGRES_DB=pocketid-db
POSTGRES_HOST=0.0.0.0
POSTGRES_PORT=5432

Log Output

...
2025/06/15 16:50:24 github.com/pocket-id/pocket-id/backend/internal/bootstrap/db_bootstrap.go:106
[error] failed to initialize database, got error failed to connect to `user=pocket-id database=pocketid-db`:
	0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused
	0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused
2025/06/15 16:50:27 failed to connect to database: failed to connect to `user=pocket-id database=pocketid-db`:
	0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused
	0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused
2025/06/15 16:51:27 Attempt 1: Failed to initialize database. Retrying...

2025/06/15 16:51:27 github.com/pocket-id/pocket-id/backend/internal/bootstrap/db_bootstrap.go:106
[error] failed to initialize database, got error failed to connect to `user=pocket-id database=pocketid-db`:
	0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused
	0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused

2025/06/15 16:51:30 github.com/pocket-id/pocket-id/backend/internal/bootstrap/db_bootstrap.go:106
2025/06/15 16:51:30 Attempt 2: Failed to initialize database. Retrying...
[error] failed to initialize database, got error failed to connect to `user=pocket-id database=pocketid-db`:
	0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused
	0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused

2025/06/15 16:51:33 github.com/pocket-id/pocket-id/backend/internal/bootstrap/db_bootstrap.go:106
[error] failed to initialize database, got error failed to connect to `user=pocket-id database=pocketid-db`:
	0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused
	0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused
2025/06/15 16:51:33 Attempt 3: Failed to initialize database. Retrying...
2025/06/15 16:51:36 failed to connect to database: failed to connect to `user=pocket-id database=pocketid-db`:
	0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused
	0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused
Originally created by @ezcafe on GitHub. ### Reproduction steps Hi team, I cannot make it work with postgres It always said "connection refused" This is my docker file ```yml services: pocket-id: image: ghcr.io/pocket-id/pocket-id container_name: pocket-id restart: unless-stopped env_file: .env ports: - ${PORT}:1411 healthcheck: test: "curl -f http://localhost:1411/healthz" interval: 1m30s timeout: 5s retries: 5 start_period: 10s volumes: - pocket-id:/app/data depends_on: - db db: image: postgres:16.1 container_name: pocket-id-db restart: unless-stopped env_file: .env healthcheck: test: ['CMD-SHELL', 'pg_isready -d "$${POSTGRES_DB}" -U $${POSTGRES_USER}'] interval: 10s timeout: 5s retries: 5 volumes: - data:/var/lib/postgresql/data/ volumes: pocket-id: data: ``` ### Expected behavior It could connect to postgres ### Actual Behavior It's showing error like this dial error: dial tcp 0.0.0.0:5432: connect: connection refused ### Version and Environment ```env PORT=19945 APP_URL=https://auth.example.com TRUST_PROXY=true MAXMIND_LICENSE_KEY= PUID=1000 PGID=1000 DB_PROVIDER=postgres DB_CONNECTION_STRING=postgresql://pocket-id:secret@0.0.0.0:5432/pocketid-db POSTGRES_USER=pocket-id POSTGRES_PASSWORD=secret POSTGRES_DB=pocketid-db POSTGRES_HOST=0.0.0.0 POSTGRES_PORT=5432 ``` ### Log Output ```bash ... 2025/06/15 16:50:24 github.com/pocket-id/pocket-id/backend/internal/bootstrap/db_bootstrap.go:106 [error] failed to initialize database, got error failed to connect to `user=pocket-id database=pocketid-db`: 0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused 0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused 2025/06/15 16:50:27 failed to connect to database: failed to connect to `user=pocket-id database=pocketid-db`: 0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused 0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused 2025/06/15 16:51:27 Attempt 1: Failed to initialize database. Retrying... 2025/06/15 16:51:27 github.com/pocket-id/pocket-id/backend/internal/bootstrap/db_bootstrap.go:106 [error] failed to initialize database, got error failed to connect to `user=pocket-id database=pocketid-db`: 0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused 0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused 2025/06/15 16:51:30 github.com/pocket-id/pocket-id/backend/internal/bootstrap/db_bootstrap.go:106 2025/06/15 16:51:30 Attempt 2: Failed to initialize database. Retrying... [error] failed to initialize database, got error failed to connect to `user=pocket-id database=pocketid-db`: 0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused 0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused 2025/06/15 16:51:33 github.com/pocket-id/pocket-id/backend/internal/bootstrap/db_bootstrap.go:106 [error] failed to initialize database, got error failed to connect to `user=pocket-id database=pocketid-db`: 0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused 0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused 2025/06/15 16:51:33 Attempt 3: Failed to initialize database. Retrying... 2025/06/15 16:51:36 failed to connect to database: failed to connect to `user=pocket-id database=pocketid-db`: 0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused 0.0.0.0:5432 (0.0.0.0): dial error: dial tcp 0.0.0.0:5432: connect: connection refused ```
OVERLORD added the bug label 2025-10-07 23:55:56 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pocket-id-pocket-id-1#164