© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago
Kuldar

Invoking a local edge function from local SQL editor

Hello, I have a question about local supabase development. I have spun up a local Supabase instance with
supabase start
supabase start
and created an edge function that I've spun up locally as well with
supabase functions serve my-function
supabase functions serve my-function
.

I'm trying to invoke the function through the Postgres HTTP extension, using the authorization header provided in the curl example, at the end of the generated Edge Function. But I'm getting back "Failed to connect to localhost port 54321: Connection refused".

select status
  from
    http((
      'POST',
      'http://localhost:54321/functions/v1/',
      array[
        http_header('Authorization','Bearer MY_KEY')
      ],
      '',
      'application/json'
    )::http_request)
select status
  from
    http((
      'POST',
      'http://localhost:54321/functions/v1/',
      array[
        http_header('Authorization','Bearer MY_KEY')
      ],
      '',
      'application/json'
    )::http_request)


(By the way this method works fine when I deploy my function and call it the same way on the hosted Supabase SQL editor).

So my question is: should it even be possible to invoke a locally served edge function through a locally running Supabase SQL editor?

As a secondary question - is there any way to reference the SERVICE_KEY in a SQL Editor, without actually writing the key into the SQL statement? Similar to how the SERVICE_KEY is automatically provided through env variables when working in Edge Functions.

Thanks!
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Invoking Edge Function from Browser
SupabaseSSupabase / help-and-questions
4y ago
Webhook not invoking Edge Function
SupabaseSSupabase / help-and-questions
3y ago
403 when invoking sb edge function from vercel function
SupabaseSSupabase / help-and-questions
5mo ago
Invoking an edge function via Supabase trigger/function
SupabaseSSupabase / help-and-questions
3y ago