postgresqldnsipv6supabase

Use an IPv6-only domain name in a PSQL connection string


I am specifically trying to avoid connecting to the pooler/Supavisor and instead want to use a direct connection.

Supabase gives me a hostname like: db.MY_ID.supabase.co

It has no ipv4 IP, but I can dig the AAAA record:

% dig AAAA db.MY_ID.supabase.co

; <<>> DiG 9.10.6 <<>> AAAA db.MY_ID.supabase.co
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59725
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;db.MY_ID.supabase.co. IN   AAAA

;; ANSWER SECTION:
db.MY_ID.supabase.co. 30    IN AAAA dead:beef:IPV6:IPV6::IPV6:IPV6:dead:beef

;; Query time: 44 msec
;; SERVER: 192.168.20.1#53(192.168.20.1)
;; WHEN: Sat Mar 08 09:49:28 AEDT 2025
;; MSG SIZE  rcvd: 92

But I can't get psql to connect to it by either domain or IP:

% psql "postgresql://db.MY_ID.supabase.co:5432/postgres?sslmode=require" -U myuser
psql: error: could not translate host name "db.MY_ID.supabase.co" to address: nodename nor servname provided, or not known
% psql "postgresql://[dead:beef:IPV6:IPV6::IPV6:IPV6:dead:beef]:5432/postgres?sslmode=require" -U myuser
psql: error: connection to server at "dead:beef:IPV6:IPV6::IPV6:IPV6:dead:beef", port 5432 failed: No route to host
    Is the server running on that host and accepting TCP/IP connections?

What am I doing wrong? Is there something wrong here at the Postgres level that I can fix?

Update: grawity is correct. My router did not have ipv6 enabled. I have been using ipv6 addresses that point to localhost for dev purposes so I assumed I had ipv6 working. But I didn't have it working on the Internet, only on localhost.


Solution

  • Your second error message says: No route to host. This suggests that the client system which you're connecting from has no IPv6 connectivity to begin with.

    There can be other causes for the message – none of them Postgres-related, all of them caused by lack of routing in one place or another – but the client machine lacking IPv6 would be consistent with the IPv6-only domain issue in the first error message.

    Specifically, if the client system has no default route for IPv6 (no ::/0 route), then its Libc DNS resolver will not even try to resolve AAAA records when asked for "any address family" – it's a commonly used feature in getaddrinfo() called AI_ADDRCONF, which the psql tool probably sets – and you will indeed see symptoms like in the first example.

    If the client is Linux, run ip -6 route get <the_ipv6_address> (with or without the fibmatch keyword), or ip -6 route show match <the_ipv6_address> table all, to check what the system's routing table has.