cli icon indicating copy to clipboard operation
cli copied to clipboard

Database URL in CLI from supabase status is wrong

Open UliPrantz opened this issue 3 months ago • 4 comments

Bug report

  • [x] I confirm this is a bug with Supabase, not with my own application.
  • [x] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

The Supabase Database URL printed in supabase status and the one populated through the environment variable SUPABASE_DB_URL in the local edge functions runtime are completely different in the local setup!

CLI prints for Database URL: postgresql://postgres:[email protected]:54322/postgres Env variable SUPABASE_DB_URL: postgresql://postgres:postgres@db:5432/postgres

Note the different host (127.0.0.1 vs. db - later being the docker internal DNS name for the postgres instance) and the different ports (54322 vs. 5432)

To Reproduce

  1. Create a Supabase project or use a working one in the latest Supabase version (v2.51.0)
  2. Create an edge function supabase functions new test
  3. Add the test code from below to the new index.ts file
  4. Make sure you set verify_jwt=false in the config.toml for this function
  5. Serve the functions using supabase functions serve
  6. Trigger it using e.g. curl like curl http://127.0.0.1:54321/functions/v1/test
  7. You will get the SUPABASE_DB_URL env variable content as return (it will also show up in the logs of supabse functions serve)
  8. In the CLI enter supabase status to retrieve the Database URL
  9. You will see postgresql://postgres:[email protected]:54322/postgres (Database URL) != postgresql://postgres:postgres@db:5432/postgres (SUPABASE_DB_URL env variable)

Expected behavior

The variables should be the same and show the correct connection string, which is the SUPABASE_DB_URL env variable. The Database URL from supabase status is incorrect and not working!

System information

  • OS: macOS
  • Version of supabase CLI: v2.51.0

Additional context

Hope I could save at least some people some debugging trouble :)

UliPrantz avatar Oct 15 '25 22:10 UliPrantz

Move over from supabase repo.

Hallidayo avatar Oct 19 '25 19:10 Hallidayo

Move over from supabase repo.

@Hallidayo thank you :D wasn't aware of this repo

UliPrantz avatar Oct 19 '25 19:10 UliPrantz

From my research this is a feature not a bug, one thing that could be done is to return both env variables. Meaning when you run supabase status it returns the URL of database that is accessable from you machine, but since edge functions run on a same network as database it is showing the URL of database that edge function can access

thealish avatar Nov 15 '25 17:11 thealish

@thealish could you link your research or your insights? Because I came across this issue exactly through edge functions where I couldn't connect to the database.

Or please give a working example :D

UliPrantz avatar Nov 15 '25 20:11 UliPrantz