S
Supabase2mo ago
Almopt

"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
garyaustin
garyaustin2mo ago
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.
Almopt
AlmoptOP2mo ago
ive tried the session pooler and still have the same issue
garyaustin
garyaustin2mo ago
Same error? Did you make sure to use the right user.instanceID for user?
Almopt
AlmoptOP2mo ago
whad do you mean by user.instanceID?
garyaustin
garyaustin2mo ago
Supavisor uses postgres.xxxxxxxxxxxxxxxxx for the user where xxxxxxxxx is your instance/project id. The connection tab would show this.
Almopt
AlmoptOP2mo ago
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
garyaustin
garyaustin2mo ago
Looks right as long as [] is also removed.
Almopt
AlmoptOP2mo ago
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)
garyaustin
garyaustin2mo ago
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.
Almopt
AlmoptOP2mo ago
i already checked and yes its a different error
Almopt
AlmoptOP2mo ago
do i have to buy it?
No description
garyaustin
garyaustin2mo ago
And it works from other networks than your hotspot? You are not using the pooler port.
Almopt
AlmoptOP2mo ago
yes this morning i did some migrations but now im travelling and i need to do an urgent migration
Almopt
AlmoptOP2mo ago
No description
Almopt
AlmoptOP2mo ago
no IP Bans
garyaustin
garyaustin2mo ago
Not sure. Using session pooler would solve IPv6 issue which is very possible with different devices, providers and routers. This seems odd:
No description
Almopt
AlmoptOP2mo ago
what that mean?
garyaustin
garyaustin2mo ago
54322 instead of 5432
Almopt
AlmoptOP2mo ago
but the command Im running is the one ive sent should i change the port?
garyaustin
garyaustin2mo ago
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.
Almopt
AlmoptOP2mo ago
im trying to dif from my online instance but ive done this several times before
garyaustin
garyaustin2mo ago
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.
Almopt
AlmoptOP2mo ago
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)"
garyaustin
garyaustin2mo ago
Right. And that could be because of IPv6 support.
Almopt
AlmoptOP2mo ago
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)
garyaustin
garyaustin2mo ago
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.
Almopt
AlmoptOP2mo ago
but i havent change anything, this morning did some migrations
garyaustin
garyaustin2mo ago
For some reason you are not using the session pooler connection.
Almopt
AlmoptOP2mo ago
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"
garyaustin
garyaustin2mo ago
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?
Almopt
AlmoptOP2mo ago
yes
inder
inder2mo ago
Try this command with --db-url CONNECTION STRING Also if password contain special chars, they must be percent-encoded
garyaustin
garyaustin2mo ago
@inder any idea why the error would be for local connect versus session pooler? Versus direct connect showing direct connect error as expected?
inder
inder2mo ago
Could be unhealthy container. Can't think of any other reason Also this is ipv6 address
garyaustin
garyaustin2mo ago
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.
inder
inder2mo ago
I think --db-url with pooler string should solve this
garyaustin
garyaustin2mo ago
K. Thanks.
Beyond the IPv6 stuff and correct connection port, just not up on CLI.
Almopt
AlmoptOP2mo ago
For the session poller? Because I’ve never worried about that, I’ve run hundreds of migrations without worrying about that
inder
inder2mo ago
Have you tried running diff command with --db-url flag?
Almopt
AlmoptOP2mo ago
Where should I put that flag?
inder
inder2mo ago
supabase db diff -f lap2go_view_results --db-url "postgresql://postgres.PROJECTID:PASSWORD@aws-0-eu-central-1.pooler.supabase.com:5432/postgres"
supabase db diff -f lap2go_view_results --db-url "postgresql://postgres.PROJECTID:PASSWORD@aws-0-eu-central-1.pooler.supabase.com:5432/postgres"
Almopt
AlmoptOP2mo ago
Let me try no still the same error
inder
inder2mo ago
I can reproduce the error when I don't use --db-url flag. Adding the flag solves the issue for me
inder
inder2mo ago
When I don't use flag
No description
Almopt
AlmoptOP2mo ago
oh sorry it worked thank you!!! you're the man!
inder
inder2mo ago
Are you sure you were not using this flag before? I think it shouldn't have worked before as well
Almopt
AlmoptOP2mo ago
i dont remember but now im trying to do the push at its not working
inder
inder2mo ago
What command are you running
Almopt
AlmoptOP2mo ago
sorry i was using the ipv6 connection string i changed to session poller and it worked

Did you find this page helpful?