#50486·supabase

Self-Hosted: JWT config applied to wrong database when using custom POSTGRES_DB

Author: mandar1045Created Sep 16, 2026Updated Sep 17, 2026
Labelsbugself-hostedpr-openedexternal-issue

Bug description

I was setting up a self-hosted instance and wanted to use a custom database name instead of the default postgres. After changing POSTGRES_DB in my .env file, I noticed that auth and RLS weren't working correctly.

I dug into the Docker initialization scripts and found the culprit: docker/volumes/db/jwt.sql completely ignores the POSTGRES_DB environment variable and hardcodes the database name:

ALTER DATABASE postgres SET "app.settings.jwt_exp" TO :'jwt_exp';
If anyone overrides POSTGRES_DB (which is officially supported in CONFIG.md), their JWT configs get applied to the wrong database and auth fails silently.

Expected behavior
jwt.sql should read the POSTGRES_DB environment variable and apply the settings to that database.

Reproducing steps

Change POSTGRES_DB=custom_db in .env. Run docker compose up -d. Check custom_db for app.settings.jwt_exp — it will be missing because it was applied to postgres instead.