The root cause may be that pg15 modified the default authentication rules.
Configuration file path: /etc/postgresql/15/main/pg_hba.conf
File content is as follows:
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 0.0.0.0/0 md5
# IPv6 local connections:
host all all ::/0 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 scram-sha-256
host replication all ::1/128 scram-sha-256
The command executed for backup is as follows:
pg_dump --schema=public -T public.pg_* --file=‘/src/tmp/backups/default/2026-02-02-063003/dump.sql.gz’ --no-owner --no-privileges --verbose --compress=4 --username=postgres discourse_development
The command above reports an error because of the rule local all postgres peer: Peer authentication failed for user "postgres"
Solution idea: Change peer to trust to allow all local environment commands. This means no further authentication (and no password input) is required for any command.
Specific steps:
- Copy
/etc/postgresql/15/main/pg_hba.conffrom the container to local
sudo docker cp discourse_dev:/etc/postgresql/15/main/pg_hba.conf ~/discourse/data/pg_hba.conf
Grant permissions 644
sudo chmod 644 ~/discourse/data/pg_hba.conf
Modify the configuration in data/pg_hba.conf
# Database administrative login by Unix domain socket
local all postgres trust
- Modify the
d/boot_devfile to mountdata/pg_hba.confinto the container, overwriting the defaultpgconfiguration file.
docker run -d \
-p $local_publish:8025:8025 \
-p $local_publish:3000:3000 \
-p $local_publish:4200:4200 \
-p $local_publish:9292:9292 \
-p $local_publish:9405:9405 \
-v "$DATA_DIR:/shared/postgres_data:delegated" \
# The line below is newly added, mounting the configuration file into the container, and only giving the container read-only permission
-v "$SOURCE_DIR/data/pg_hba.conf:/etc/postgresql/15/main/pg_hba.conf:ro" \
-v "$SOURCE_DIR:/src:delegated" \
-e UNICORN_BIND_ALL=true \
$mount_plugin_symlinks \
$ENV_ARGS \
--hostname=discourse \
--name=discourse_dev \
--restart=always \
discourse/discourse_dev:release /sbin/boot
- Stop and remove the current container, then rebuild the new container
d/shotdown_dev
d/boot_dev
- After rebuilding, start the frontend and backend applications, and test if the backup is normal
d/rails s
# Execute in another command line
d/ember-cli
On the backup page, click backup, wait a few seconds, and then view the backup file list.


