Uncontrolled shutdown of the PostgreSQL container

Hi! From time to time I am facing a problem like this:

pg-gvm-1 | 2026-01-27 01:32:00.527 UTC [1] LOG: received smart shutdown request
pg-gvm-1 | 2026-01-27 01:32:01.727 UTC [178231] gvmd@gvmd FATAL: the database system is shutting down
pg-gvm-1 | 2026-01-27 01:32:01.729 UTC [178232] gvmd@gvmd FATAL: the database system is shutting down
pg-gvm-1 | 2026-01-27 01:32:06.737 UTC [178233] gvmd@gvmd FATAL: the database system is shutting down
pg-gvm-1 | Removed stale pid file.
pg-gvm-1 | Error: /usr/lib/postgresql/17/bin/pg_ctl /usr/lib/postgresql/17/bin/pg_ctl start -D /var/lib/postgresql/17/main -l /var/log/postgresql/postgresql-17-main.log -s -o -c config_file=“/etc/postgresql/17/main/postgresql.conf” -k /var/run/postgresql -c listen_addresses=‘’ exited with status 1:
pg-gvm-1 | 2026-01-27 01:32:20.135 UTC [29] LOG: starting PostgreSQL 17.7 (Debian 17.7-0+deb13u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 14.2.0-19) 14.2.0, 64-bit
pg-gvm-1 | 2026-01-27 01:32:20.138 UTC [29] LOG: listening on IPv4 address “0.0.0.0”, port 5432
pg-gvm-1 | 2026-01-27 01:32:20.138 UTC [29] LOG: listening on IPv6 address “::”, port 5432
pg-gvm-1 | 2026-01-27 01:32:20.187 UTC [29] FATAL: lock file “/var/run/postgresql/.s.PGSQL.5432.lock” already exists
pg-gvm-1 | 2026-01-27 01:32:20.187 UTC [29] HINT: Is another postmaster (PID 1) using socket file “/var/run/postgresql/.s.PGSQL.5432”?
pg-gvm-1 | 2026-01-27 01:32:20.189 UTC [29] LOG: database system is shut down
pg-gvm-1 | pg_ctl: could not start server
pg-gvm-1 | Examine the log output.
pg-gvm-1 | Error: /usr/lib/postgresql/17/bin/pg_ctl /usr/lib/postgresql/17/bin/pg_ctl start -D /var/lib/postgresql/17/main -l /var/log/postgresql/postgresql-17-main.log -s -o -c config_file=“/etc/postgresql/17/main/postgresql.conf” -k /var/run/postgresql -c listen_addresses='
’ exited with status 1:
pg-gvm-1 | 2026-01-27 01:32:21.205 UTC [29] LOG: starting PostgreSQL 17.7 (Debian 17.7-0+deb13u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 14.2.0-19) 14.2.0, 64-bit
pg-gvm-1 | 2026-01-27 01:32:21.205 UTC [29] LOG: listening on IPv4 address “0.0.0.0”, port 5432
pg-gvm-1 | 2026-01-27 01:32:21.206 UTC [29] LOG: listening on IPv6 address “::”, port 5432
pg-gvm-1 | 2026-01-27 01:32:21.237 UTC [29] FATAL: lock file “/var/run/postgresql/.s.PGSQL.5432.lock” already exists
pg-gvm-1 | 2026-01-27 01:32:21.237 UTC [29] HINT: Is another postmaster (PID 1) using socket file “/var/run/postgresql/.s.PGSQL.5432”?
pg-gvm-1 | 2026-01-27 01:32:21.239 UTC [29] LOG: database system is shut down
pg-gvm-1 | pg_ctl: could not start server
pg-gvm-1 | Examine the log output.

There were no scans, updates, or any other changes at this time.

P.S. I’d like to describe the problem in as much detail as possible, but that’s really all I have right now.

1 Like

You can try to delete the psql_socket_vol volume to fix the issue. It gets recreated on startup again automatically.

2 Likes

i’ve got the same problem. i can delete file and start the container. but after a reboot i got the same again

The same issue after the server rebooted on Ubuntu 25.04 clear fresh install of greenbone

docker logs greenbone-community-edition-pg-gvm-1

Error: /usr/lib/postgresql/17/bin/pg_ctl /usr/lib/postgresql/17/bin/pg_ctl start -D /var/lib/postgresql/17/main -l /var/log/postgresql/postgresql-17-main.log -s -o -c config_file=“/etc/postgresql/17/main/postgresql.conf” -k /var/run/postgresql -c listen_addresses=‘*’ exited with status 1:
2026-01-28 16:22:50.974 UTC [30] LOG: starting PostgreSQL 17.7 (Debian 17.7-0+deb13u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 14.2.0-19) 14.2.0, 64-bit
2026-01-28 16:22:50.974 UTC [30] LOG: listening on IPv4 address “0.0.0.0”, port 5432
2026-01-28 16:22:50.974 UTC [30] LOG: listening on IPv6 address “::”, port 5432
2026-01-28 16:22:50.976 UTC [30] FATAL: lock file “/var/run/postgresql/.s.PGSQL.5432.lock” already exists
2026-01-28 16:22:50.976 UTC [30] HINT: Is another postmaster (PID 1) using socket file “/var/run/postgresql/.s.PGSQL.5432”?
2026-01-28 16:22:50.981 UTC [30] LOG: database system is shut down
pg_ctl: could not start server
Examine the log output.

Please provide how to fix this issue

when adding this command and restart container socket removed and then againe restart and container is up. but after server reboot - the same

Perhaps you have an old psql_socket_vol (with a different prefix in the name) among docker volumes (docker volume ls). I deleted them all, and then I raised the containers again (docker compose down, docker volume rm psql_socket_vol, docker compose up -d) everything still seems to be working without errors.

P.S. If the error suddenly appears again, I will write here.

I don’t have a clue what’s happening on a reboot differently form a container restart. Somebody from the community needs to do some investigation. Maybe the containers are not shut down correctly and postgres can’t remove the lock?

Until that there is a workaround by removing the pg docker volume.

It seems to me just restarting docker causes the same issue.

I’m confirmed too. Here the logs

Please provide any decision how to fix this issue.

Have you tried removing psql_socket_vol as @bricks wrote and starting the containers again? At least it helped me and it still works.

Sure. docker-compose down and then delete posgresql-socket volume, run docker-compose up -d. It starts, but, againe after restart docker or reboot the server got the same issue.

Do you have another psql_socket_vol (may be with another prefix) in your docker volumes (docker volume ls)?

As I wrote we have a workaround.

If you have a high demand for a fix, please investigate the issue and let me know about the error cause. In that case I can fix it. Currently investigation of this issue is not on my prio list.

No, only one, wich created by default

I’ve just had this problem come back on its own. I think you should still consider it serious enough to fix it soon)

As I wrote earlier, there is no additional information other than the logs I provided. The containers have also not been rebooted since the last time I resorted to your temporary solution and reported the completion of the problem.

1 Like

I need to know why the postgres lock file is not removed automatically and what we are doing wrong. That needs some investigation. I am not able to spend time on this at the moment.

1 Like

I’m using Ubuntu 25.04, Docker version 29.2.0, Docker Compose version v5.0.2.

Maybe problem that 2 containers with psql socket

pg-gvm:
image: registry.community.greenbone.net/community/pg-gvm:stable
restart: on-failure:10
volumes:

  • psql_data_vol:/var/lib/postgresql
  • psql_socket_vol:/var/run/postgresql
    depends_on:
    pg-gvm-migrator:
    condition: service_completed_successfully

pg-gvm-migrator:
image: registry.community.greenbone.net/community/pg-gvm-migrator:stable
restart: no
volumes:

  • psql_data_vol:/var/lib/postgresql
  • psql_socket_vol:/var/run/postgresql

docker volume ls

image

but container pg migrator aren’t running

I commented the pg-gvm-migrator out in the yml-file and then pg-gvm-container starts normaly.

This can’t be the solution. If the migration is done, the container actually does nothing on startup.

Do the same and got the same error Error: /usr/lib/postgresql/17/bin/pg_ctl /usr/lib/postgresql/17/bin/pg_ctl start -D /var/lib/postgresql/17/main -l /var/log/postgresql/postgresql-17-main.log -s -o -c config_file=“/etc/postgresql/17/main/postgresql.conf” -k /var/run/postgresql -c listen_addresses=‘*’ exited with status 1:
2026-02-03 09:15:19.346 UTC [29] LOG: starting PostgreSQL 17.7 (Debian 17.7-0+deb13u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 14.2.0-19) 14.2.0, 64-bit
2026-02-03 09:15:19.347 UTC [29] LOG: listening on IPv4 address “0.0.0.0”, port 5432
2026-02-03 09:15:19.347 UTC [29] LOG: listening on IPv6 address “::”, port 5432
2026-02-03 09:15:19.349 UTC [29] FATAL: lock file “/var/run/postgresql/.s.PGSQL.5432.lock” already exists
2026-02-03 09:15:19.349 UTC [29] HINT: Is another postmaster (PID 1) using socket file “/var/run/postgresql/.s.PGSQL.5432”?
2026-02-03 09:15:19.354 UTC [29] LOG: database system is shut down

Looks life socket doesn’t normally deleted after container with posgres stops/restarts