Guide's password advice (openssl rand -base64) produces credentials that break DATABASE_URL #324

Closed
opened 2026-08-04 10:49:23 +02:00 by fable-5 · 0 comments
Collaborator

Reported by Stefan from a manual clean install per docs/self-hosting/README.md (v0.14.0, Docker CE / Compose v2, Debian 13).

The guide (docs/self-hosting/README.md, Install step 2) recommends openssl rand -base64 32 for POSTGRES_PASSWORD and COLLAB_TOKEN_SECRET. base64 output regularly contains /, + and =, but the compose file interpolates the password UNESCAPED into a connection URL:

DATABASE_URL: postgresql://dorfteich:${POSTGRES_PASSWORD:?set in .env}@db:5432/dorfteich

A / (and depending on the parser +/=) makes the URL invalid.

Symptom -- and why it misleads: db becomes healthy (Postgres receives the password only as an env variable, no URL involved), while api, collab and backup exit 1 into a restart loop. A healthy database with all database clients dying points the diagnosis in the wrong direction first.

Repro: fill .env per the guide until POSTGRES_PASSWORD contains a / (with -base64 32 almost immediately), docker compose up -d, docker compose ps -> api/collab/backup restarting, db healthy.

Fix outline (from the report):

  • Docs minimal: recommend URL-safe generation (openssl rand -hex 24) for POSTGRES_PASSWORD in README and .env.example. COLLAB_TOKEN_SECRET never enters a URL, but unify both recommendations for simplicity.
  • Code, more robust (optional): percent-encode the password where DATABASE_URL is assembled, or use discrete PG* variables instead of a URL -- then arbitrary passwords are valid.
  • Troubleshooting section: add the symptom line "api/collab/backup restart-looping while db is healthy -> special characters in POSTGRES_PASSWORD break DATABASE_URL".
Reported by Stefan from a manual clean install per docs/self-hosting/README.md (v0.14.0, Docker CE / Compose v2, Debian 13). The guide (docs/self-hosting/README.md, Install step 2) recommends `openssl rand -base64 32` for POSTGRES_PASSWORD and COLLAB_TOKEN_SECRET. base64 output regularly contains `/`, `+` and `=`, but the compose file interpolates the password UNESCAPED into a connection URL: DATABASE_URL: postgresql://dorfteich:${POSTGRES_PASSWORD:?set in .env}@db:5432/dorfteich A `/` (and depending on the parser `+`/`=`) makes the URL invalid. Symptom -- and why it misleads: `db` becomes healthy (Postgres receives the password only as an env variable, no URL involved), while api, collab and backup exit 1 into a restart loop. A healthy database with all database clients dying points the diagnosis in the wrong direction first. Repro: fill .env per the guide until POSTGRES_PASSWORD contains a `/` (with -base64 32 almost immediately), `docker compose up -d`, `docker compose ps` -> api/collab/backup restarting, db healthy. Fix outline (from the report): - Docs minimal: recommend URL-safe generation (`openssl rand -hex 24`) for POSTGRES_PASSWORD in README and .env.example. COLLAB_TOKEN_SECRET never enters a URL, but unify both recommendations for simplicity. - Code, more robust (optional): percent-encode the password where DATABASE_URL is assembled, or use discrete PG* variables instead of a URL -- then arbitrary passwords are valid. - Troubleshooting section: add the symptom line "api/collab/backup restart-looping while db is healthy -> special characters in POSTGRES_PASSWORD break DATABASE_URL".
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: stwaidele/dorfteich#324
No description provided.