Skip to content

Commit

Permalink
[PostgreSQL] fix pg_hba.conf for GitHub Codespaces
Browse files Browse the repository at this point in the history
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
  • Loading branch information
admsev committed May 7, 2024
1 parent b596067 commit a838445
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/postgresql/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a838445

Please sign in to comment.