Database URL in CLI from supabase status is wrong
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
- Create a Supabase project or use a working one in the latest Supabase version (v2.51.0)
- Create an edge function
supabase functions new test - Add the test code from below to the new
index.tsfile - Make sure you set
verify_jwt=falsein theconfig.tomlfor this function - Serve the functions using
supabase functions serve - Trigger it using e.g. curl like
curl http://127.0.0.1:54321/functions/v1/test - You will get the
SUPABASE_DB_URLenv variable content as return (it will also show up in the logs ofsupabse functions serve) - In the CLI enter
supabase statusto retrieve theDatabase URL - 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 :)
Move over from supabase repo.
Move over from supabase repo.
@Hallidayo thank you :D wasn't aware of this repo
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 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