"failed to connect to postgres: failed to connect to" using supabase cli
Hey guys,
When using the command supabase db diff -f using my hotspot internet im getting the following error: "failed to connect to postgres: failed to connect to
host=db.************ user=postgres database=postgres
: dial error (dial tcp [2a05:d014:1c06:5f12:b565:554e:2ccc:8d80]:5432: connect: no route to host)". Does anyone knows how to fix this?49 Replies
My guess is there is not IPv6 support. I don't know though how the CLI determines when to use the db....co connection IPv6 only conneciton and the IPv4 supavisor session port ending in .com.
ive tried the session pooler and still have the same issue
Same error? Did you make sure to use the right user.instanceID for user?
whad do you mean by user.instanceID?
Supavisor uses postgres.xxxxxxxxxxxxxxxxx for the user where xxxxxxxxx is your instance/project id. The connection tab would show this.
supabase db diff -f lap2go_view_results "postgresql://postgres.projectId:[password]@aws-0-eu-central-1.pooler.supabase.com:5432/postgres"
this is what im doing
projectId is replaced by my projectId and same for password
Looks right as long as [] is also removed.
yes it is
but still having the same error: failed to connect to postgres: failed to connect to
host=127.0.0.1 user=postgres database=postgres
: dial error (dial tcp 127.0.0.1:54322: connect: connection refused)You could check Settings/Database at very bottom of page to see if your IP is banned for some reason, but I think that would be a different error.
i already checked and yes its a different error
do i have to buy it?

And it works from other networks than your hotspot?
You are not using the pooler port.
yes this morning i did some migrations
but now im travelling and i need to do an urgent migration

no IP Bans
Not sure. Using session pooler would solve IPv6 issue which is very possible with different devices, providers and routers.
This seems odd:

what that mean?
54322 instead of 5432
but the command Im running is the one ive sent
should i change the port?
The port should be 5432. Just thought maybe you had a typo.
Also though 127.0.0.1 seems like you went to your device itself? Do you have a local instance also? Yeah that is trying to connect to your local supabase I assume.
im trying to dif from my online instance
but ive done this several times before
But your last error message seems to be pointing to your local instance.
OK. You'll have to see if someone else comes along with ideas. Your strings for both modes seem right to me. And testing both eliminates IPv6 being the issue.
this is the error running with direct connection : "failed to connect to postgres: failed to connect to
host=db.xpqalhchqfazkejnumkn.supabase.co user=postgres database=postgres
: dial error (dial tcp [2a05:d014:1c06:5f12:b565:554e:2ccc:8d80]:5432: connect: no route to host)"Right. And that could be because of IPv6 support.
and this is the error when running on session polller: failed to connect to postgres: failed to connect to
host=127.0.0.1 user=postgres database=postgres
: dial error (dial tcp 127.0.0.1:54322: connect: connection refused)That is going to the remote instance also in your error. (first one)
The 2nd one is going to your local instance.
127.0.0.1:54322 is local address and port number.
but i havent change anything, this morning did some migrations
For some reason you are not using the session pooler connection.
so what would be the command to run migration from session pooler?
isnt this one: supabase db diff -f lap2go_view_results "postgresql://postgres.PROJECTID:PASSWORD@aws-0-eu-central-1.pooler.supabase.com:5432/postgres"
Is it possible the remote part of the link is connecting and then it is trying to do the local part and that is failing.
Is your local instance on this device you are using?
yes
Try this command with
--db-url CONNECTION STRING
Also if password contain special chars, they must be percent-encoded@inder any idea why the error would be for local connect versus session pooler? Versus direct connect showing direct connect error as expected?
Could be unhealthy container. Can't think of any other reason
Also this is ipv6 address
So my guess is two connections are involved. First to remote which fails for direct, maybe IPv6 as new connection for OP.
Then the 2nd time using the session pooler gets thru the first step to the remote but fails on the local connection it needs to do the operation.
I think
--db-url
with pooler string should solve thisK. Thanks.
Beyond the IPv6 stuff and correct connection port, just not up on CLI.
Beyond the IPv6 stuff and correct connection port, just not up on CLI.
For the session poller?
Because I’ve never worried about that, I’ve run hundreds of migrations without worrying about that
Have you tried running diff command with --db-url flag?
Where should I put that flag?
Let me try
no still the same error
I can reproduce the error when I don't use --db-url flag. Adding the flag solves the issue for me
When I don't use flag

oh sorry it worked
thank you!!!
you're the man!
Are you sure you were not using this flag before?
I think it shouldn't have worked before as well
i dont remember
but now im trying to do the push at its not working
What command are you running
sorry i was using the ipv6 connection string
i changed to session poller and it worked