Skip to content

Listen on both loopback addresses, and name them - #4

Merged
marcos-mendez merged 2 commits into
mainfrom
fix/listen-on-both-loopbacks
Sep 27, 2026
Merged

marcos-mendez merged 2 commits into
mainfrom
fix/listen-on-both-loopbacks

Conversation

@marcos-mendez

Copy link
Copy Markdown
Contributor

The layer shipped a database an appliance built on it could not reach
over IPv6, which is the address family this project builds for.

conf.d/main asserted Debian's default, listen_addresses = 'localhost',
on the grounds that it is the loopback of both families. It is not.
Debian's /etc/hosts maps ::1 to ip6-localhost and ip6-loopback and never
to localhost, so getaddrinfo("localhost") answers 127.0.0.1 alone and the
cluster binds the IPv4 loopback only. Measured on a container booted from
the published layer:

# ss -lntH 'sport = :5432'
LISTEN 0  200  127.0.0.1:5432  0.0.0.0:*

with ::1 up on lo and pg_hba.conf already carrying its scram-sha-256 line
for ::1/128, ready for a connection that could never arrive. That is what
failed firstboot.d/36pgsqlverify on the gate, and the hook was right:
35pgsqlpass had set the password over the unix socket and the database
was still unreachable at the address this layer says it serves.

The fix is two literal addresses, '::1,127.0.0.1', the same pair the
MariaDB layer writes into its bind-address. A literal address cannot
resolve into something else, which is the point: the previous line was
not wrong about what it wanted, it was wrong about what a name meant on
this machine. What it binds is now proved on the booted machine by the
boot test rather than assumed by a grep of the setting here, which is the
lesson of the defect: asserting the configuration is not asserting the
behaviour.

Measured on the build host, on a container booted from the published
chain with the line in place:

# ss -lntH 'sport = :5432'
LISTEN 0  200  127.0.0.1:5432  0.0.0.0:*
LISTEN 0  200      [::1]:5432     [::]:*

$ psql --username=postgres --host=::1 --port=5432 --no-password \
    --command='SELECT 1, current_user, inet_server_addr()'
1|postgres|::1

with the declared password in PGPASSWORD, and with the wrong one

FATAL:  password authentication failed for user "postgres"

The layer ships this, so the changelog gains an entry and the layer needs
a rebuild before its gate can go green.

The layer shipped a database an appliance built on it could not reach
over IPv6, which is the address family this project builds for.

conf.d/main asserted Debian's default, listen_addresses = 'localhost',
on the grounds that it is the loopback of both families. It is not.
Debian's /etc/hosts maps ::1 to ip6-localhost and ip6-loopback and never
to localhost, so getaddrinfo("localhost") answers 127.0.0.1 alone and the
cluster binds the IPv4 loopback only. Measured on a container booted from
the published layer:

    # ss -lntH 'sport = :5432'
    LISTEN 0  200  127.0.0.1:5432  0.0.0.0:*

with ::1 up on lo and pg_hba.conf already carrying its scram-sha-256 line
for ::1/128, ready for a connection that could never arrive. That is what
failed firstboot.d/36pgsqlverify on the gate, and the hook was right:
35pgsqlpass had set the password over the unix socket and the database
was still unreachable at the address this layer says it serves.

The fix is two literal addresses, '::1,127.0.0.1', the same pair the
MariaDB layer writes into its bind-address. A literal address cannot
resolve into something else, which is the point: the previous line was
not wrong about what it wanted, it was wrong about what a name meant on
this machine. What it binds is now proved on the booted machine by the
boot test rather than assumed by a grep of the setting here, which is the
lesson of the defect: asserting the configuration is not asserting the
behaviour.

Measured on the build host, on a container booted from the published
chain with the line in place:

    # ss -lntH 'sport = :5432'
    LISTEN 0  200  127.0.0.1:5432  0.0.0.0:*
    LISTEN 0  200      [::1]:5432     [::]:*

    $ psql --username=postgres --host=::1 --port=5432 --no-password \
        --command='SELECT 1, current_user, inet_server_addr()'
    1|postgres|::1

with the declared password in PGPASSWORD, and with the wrong one

    FATAL:  password authentication failed for user "postgres"

The layer ships this, so the changelog gains an entry and the layer needs
a rebuild before its gate can go green.
@marcos-mendez
marcos-mendez merged commit 10c09af into main Sep 27, 2026
2 of 3 checks passed
@marcos-mendez
marcos-mendez deleted the fix/listen-on-both-loopbacks branch September 27, 2026 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant