Demo, all content is generated
Question

GitHub Action can't reach Supabase: 'Network is unreachable'

Solved · 692 views · asked by pedro_the_pm · edited

I added a workflow that runs supabase db push on merge to main. It fails:

failed to connect to postgres: dial tcp [2a05:d014:...]:5432: connect: network is unreachable

Same command works from my laptop. The DB URL is the one I got from the dashboard, db.<ref>.supabase.co.

What I’ve tried

Re-created the database password secret in GitHub, double checked there are no typos. Cursor suggested adding a retry step.

Comment

2 answers

Marked as helpful by the asker
jonas_k · edited

The direct connection host (db.<ref>.supabase.co) only has an IPv6 address. Your laptop has IPv6, GitHub-hosted runners don't. That address in brackets in the error is the giveaway.

Use the session pooler connection string instead (host aws-0-<region>.pooler.supabase.com, port 5432, user postgres.<ref>). It's IPv4 and session mode is fine for migrations. Or use the IPv4 add-on if you really need the direct connection.

- run: supabase db push --db-url "$SUPABASE_DB_URL"
  env:
    SUPABASE_DB_URL: ${{ secrets.SUPABASE_SESSION_POOLER_URL }}
Comment
green build. The bracket thing is a good tip, I'd never have noticed pedro_the_pm · edited
Same fix for Railway and some Docker setups that are IPv4-only by default. deploydan · edited
sarah_k_dev · edited

While you're in that workflow: add a job on pull requests that runs supabase db push --dry-run against production. You see which migrations would be applied before you merge, not after.

Comment
Added that too, nice. pedro_the_pm · edited