Problem
I was trying to use $ db dump with the supabase-cli after setting up Supabase local development environment, but was unable to connect to the remote database. I hadn’t configured something correctly during setup. This issue about failed SASL auth (invalid SCRAM server-final-message received from server lead me down the rabbit hole.
Firstly, the ‘link’ command
The cli list of functions only shows $ supabase link as an option and it’s often only referred to as ‘supabase link’. It’s easy to miss the docs saying use the following flag and there is no warning to say the flag is missing in the terminal. The correct use of flag is…
$ supabase link --project-ref <REFERENCE ID>
Even if the link has not succeeded the following suggests it went well…
$ Enter your database password (or leave blank to skip): $ Finished supabase link.
Note: Do not copy and paste, type out the password.
Getting the Reference ID
Reference ID is in the URL
https://supabase.com/dashboard/project/XXXXXXXXX
On the cloud Studio UI, this in General Settings (this doesn’t appear on local studio!)
Most of this was pulled from this Closed issue on github
failed SASL – IPV4 – IPV6 migration broke supabase-cli
This changelog post explains the impact of the IPV6 migration underway with Supabase cloud infra. Some commands worked, some didn’t.
My Connection details in supabase Studio showed IP4 connections with Supavisor and session pooling.
Testing the connection with
$ npx supabase link --project-ref XXXXXXX --debug
I consistently got
dial error (dial tcp [6a03:d044:1c06:3f04:7920:d6hb:29b7:f3S]:5432: connect: no route to host)
Testing if my network has IPV6 enabled… it didn’t.
https://test-ipv6.com/
I got it working, I don’t know how.
I noted that I had been using the npm and brew versions of supabase-cli interchangeably without realising. It was late.
Besides that running
$ supabase link
Selecting the project and pressing return may have reset the local project config. This doesn’t make sense as a solution as the project was created locally with CLI version 1.15.0 way after the cli version that was impacted by migration.
Anyway the following now work well
$ supabase status $ supabase test db --linked $ supabase pull $ supabase migration up $ supabase db dump --data-only > supabase/dump-data.sql