How to fix Supabase Connection Refused

If you're not able to connect to the Supabase database and see the error

connect ECONNREFUSED or psql: error: connection to server at "" (, port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections?

This could be because there are banned IPs on your project caused by Fail2ban as it kicks in when attempting 2 wrong passwords in a row.

These bans will clear after 30mins but you can unban the IPs using the Supabase CLI following the commands below.

How to list the banned IPs:

supabase network-bans get --project-ref <project_reference_id> --experimental

How to unban the IPs:

supabase network-bans remove --db-unban-ip <ip_address> --project-ref <project_reference_id> --experimental