Skip to content

Edge functions return 502 Bad Gateway after running supabase functions serve (CLI 2.72.7 and Podman 4.9.3) #4757

@henrique-milli

Description

@henrique-milli

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.
    (Honestly I didn't. Please accept my apologies if the report isn't helpful)

Describe the bug

When the edge runtime container is restarted while Kong is running, edge function requests return 502 Bad Gateway errors. Kong appears to be using a cached IP address for the edge runtime container instead of re-querying DNS.

To Reproduce

  1. Create function hello-world (CLI quickstart)
  2. Start Supabase: supabase start
  3. Wait for all containers to be healthy
  4. Verify function works:
    curl -X POST http://localhost:54321/functions/v1/hello-world \
      -H "Content-Type: application/json" \
      -d '{"name":"Test"}'
    Expected: {"message":"Hello Test!"} (200 OK)
  5. Run supabase functions serve hello-world --no-verify-jwt
  6. Test the function again:
    curl -X POST http://localhost:54321/functions/v1/hello-world \
      -H "Content-Type: application/json" \
      -d '{"name":"Test"}'
    Observe: 502 Bad Gateway error

Workaround: podman restart supabase_kong_<project-id> fixes it.

Expected behavior

Steps in CLI quickstart suggest running supabase start then supabase functions serve. Requests should work as described in the guide, or the guide should be updated according to the current behaviour.

System information

  • OS: WSL2 (Linux 6.6.87.2-microsoft-standard-WSL2)
  • Container runtime: Podman
  • Supabase CLI version: 2.72.7
  • Kong: 2.8.1
  • Edge Runtime: v1.70.0

Additional context

Kong logs show it's trying to connect to a stale IP address:

connect() failed (113: Host is unreachable) while connecting to upstream, 
upstream: "http://10.89.2.93:8081/hello-world"

The actual edge runtime container IP after running supabase functions serve is different. Podman DNS resolves correctly, but Kong appears to be using a cached IP.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions