postgrest icon indicating copy to clipboard operation
postgrest copied to clipboard

Admin API live and ready endpoints fail if one of ipv4/ipv6 fails

Open steve-chavez opened this issue 1 year ago • 1 comments

Problem

Having an instance listening on both ipv4 and ipv6:

PGRST_ADMIN_SERVER_PORT=3001 PGRST_SERVER_HOST='*6' postgrest-with-postgresql-15 postgrest-run

And a disabled ipv6:

sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1

# note disable later with
# sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0

Causes the live and ready endpoints to fail:

$ curl localhost:3001/live -i
HTTP/1.1 503 Service Unavailable

$ curl localhost:3001/ready -i
HTTP/1.1 503 Service Unavailable

When ipv4 requests are working normally:

$ curl localhost:3000/projects -4 -I
HTTP/1.1 200 OK

# though ipv6 doesn't work
$ curl localhost:3000/projects -6 -I
curl: (7) Couldn't connect to server

Proposal

Since *6 is any ipv4 or ipv6 (preferred) address the live and ready endpoints should succeed.

Notes

Instead of failing, a hangup effect can be achieved with

$ sudo ip -6 addr del ::1 dev lo

$ curl localhost:3001/live -i
# stuck...

# To undo this change 
# $ sudo ip -6 addr add ::1 dev lo

steve-chavez avatar Feb 02 '24 19:02 steve-chavez

Windows release is also affected per #3128

develop7 avatar Feb 20 '24 11:02 develop7