From a8384455a53fdfa4bb93685ee410213bf6c6c63d Mon Sep 17 00:00:00 2001 From: Alexander Manzyuk Date: Tue, 7 May 2024 12:04:49 +0200 Subject: [PATCH] [PostgreSQL] fix pg_hba.conf for GitHub Codespaces At Github Codespaces, `psql` was failing: ``` $ psql psql: error: connection to server at "localhost" (::1), port 5432 failed: FATAL: no pg_hba.conf entry for host "::1", user "postgres", database "postgres", SSL encryption connection to server at "localhost" (::1), port 5432 failed: FATAL: no pg_hba.conf entry for host "::1", user "postgres", database "postgres", no encryption ``` Apparently, the reason is that pg_hba.conf was only expecting IPv4 connections. This adds support for IPv6-configured dev containers, by adding corresponding line into pg_hba.conf --- src/postgresql/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/postgresql/install.sh b/src/postgresql/install.sh index 32ef21f..6ddc451 100644 --- a/src/postgresql/install.sh +++ b/src/postgresql/install.sh @@ -65,6 +65,7 @@ chown -R postgres:postgres $PGDATA \ && echo "listen_addresses = '*'" >> /etc/postgresql/${version_major}/main/postgresql.conf \ && echo "data_directory = '$PGDATA'" >> /etc/postgresql/${version_major}/main/postgresql.conf \ && echo "host all all 0.0.0.0/0 trust" > /etc/postgresql/${version_major}/main/pg_hba.conf \ + && echo "host all all ::/0 trust" >> /etc/postgresql/${version_major}/main/pg_hba.conf \ && sudo -H -u postgres sh -c "/usr/lib/postgresql/${version_major}/bin/initdb -D $PGDATA --auth-local trust --auth-host scram-sha-256" \ && sudo /etc/init.d/postgresql start \ && pg_isready -t 60