Supabase Edge Function container cannot connect to local auth service (ETIMEDOUT)
Hello, I am having a persistent networking issue with my local Supabase development environment. My Edge Function container is unable to make a network request to the local Supabase auth service.
What I'm trying to do: An Edge Function needs to validate the user by calling supabaseClient.auth.getUser().
The Problem: This call consistently fails with a Connection timed out (os error 110) or ECONNREFUSED error, depending on the URL I use. The function is unable to resolve the connection to the auth service.
My Setup: I am running the latest Supabase CLI. I am running Docker on [Your Operating System, e.g., Ubuntu, Windows with WSL2, etc.]. Here is what I have tried for the Supabase URL inside the function's .env file: http://localhost:54321: Fails with Connection refused (os error 111). http://host.docker.internal:54321: Fails with Connection timed out (os error 110). Using the Docker network gateway IP (<your_ip_here>): Also fails with Connection timed out (os error 110).
Here is a sample error log from my supabase functions serve terminal: [Error] TypeError: error sending request for url (http://...): client error (Connect): tcp connect error: Connection timed out (os error 110)
This seems to be a fundamental Docker networking issue with how the function container is set up by the CLI on my machine. Could you please advise on the correct networking configuration?
Thank you.
If you are setting the Supabase url manually, use this instead Deno.env.get("SUPABASE_URL") Dont set this in your env file or use the localhost/127.0.0.1 address.
Thanks @brettahale . I was having the same issue and your solution worked here.
@brettahale Thank you!! This was driving me up the wall - can't believe the fix was so simple!