Database shuts down as requested by host
Is there an existing issue for this?
- [x] I have checked the existing issues and discussions, and I can confirm that there are no duplicates.
What happened?
I can start Teslamate in docker with the docker compose command. But after everything is started, The database shuts down automatically.
database-1 | 2025-11-18 21:55:15.775 UTC [1] LOG: received smart shutdown request database-1 exited with code 137
Is this a bug or is it possible to find what causes the problem?
Expected Behavior
No response
Can the issue reliably be reproduced?
Yes
Steps To Reproduce the issue
No response
Relevant log output
database-1 | 2025-11-18 21:55:15.775 UTC [1] LOG: received smart shutdown request
database-1 exited with code 137
Screenshots
No response
Additional data
No response
Type of installation
Docker (https://docs.teslamate.org/docs/installation/docker/)
Version
2.2.0
PostgreSQL version
18-trixie
Are you running latest major supported PostgreSQL version?
- [x] I run the latest major supported PostgreSQL version
Are you using a reverse Proxy for TeslaMate?
No
Details about your reverse Proxy if applicable
No response
Thanks for reporting, this looks like your Docker host shut down the container. Please either provide the logs or ensure your host does not run out of reccources, you stop conatiners or whatever.
I checked the logs to see when it happens.
database-1 | 2025-11-19 12:04:59.109 UTC [29] LOG: checkpoint starting: time database-1 | 2025-11-19 12:05:00.986 UTC [29] LOG: checkpoint complete: wrote 18 buffers (0.1%), wrote 1 SLRU buffers; 0 WAL file(s) added, 0 removed, 0 recycled; write=1.855 s, sync=0.011 s, total=1.879 s; sync files=11, longest=0.009 s, average=0.001 s; distance=99 kB, estimate=99 kB; lsn=0/21B864F8, redo lsn=0/21B86468 grafana-1 | logger=cleanup t=2025-11-19T12:09:47.484141255Z level=info msg="Completed cleanup jobs" duration=27.965125ms grafana-1 | logger=plugins.update.checker t=2025-11-19T12:09:47.655072713Z level=info msg="Update check succeeded" duration=90.965958ms database-1 | 2025-11-19 12:10:00.018 UTC [29] LOG: checkpoint starting: time database-1 | 2025-11-19 12:10:00.850 UTC [29] LOG: checkpoint complete: wrote 8 buffers (0.0%), wrote 1 SLRU buffers; 0 WAL file(s) added, 0 removed, 0 recycled; write=0.821 s, sync=0.005 s, total=0.833 s; sync files=9, longest=0.004 s, average=0.001 s; distance=30 kB, estimate=92 kB; lsn=0/21B8DDC0, redo lsn=0/21B8DD68 database-1 | 2025-11-19 12:10:15.849 UTC [1] LOG: received smart shutdown request database-1 | 2025-11-19 12:10:26.010 UTC [67] FATAL: terminating connection due to unexpected postmaster exit database-1 | 2025-11-19 12:10:26.010 UTC [66] FATAL: terminating connection due to unexpected postmaster exit database-1 | 2025-11-19 12:10:26.010 UTC [912] FATAL: terminating connection due to unexpected postmaster exit database-1 | 2025-11-19 12:10:26.010 UTC [911] FATAL: terminating connection due to unexpected postmaster exit database-1 | 2025-11-19 12:10:26.010 UTC [913] FATAL: terminating connection due to unexpected postmaster exit database-1 | 2025-11-19 12:10:26.010 UTC [910] FATAL: terminating connection due to unexpected postmaster exit database-1 | 2025-11-19 12:10:26.010 UTC [914] FATAL: terminating connection due to unexpected postmaster exit database-1 | 2025-11-19 12:10:26.011 UTC [60] FATAL: terminating connection due to unexpected postmaster exit database-1 | 2025-11-19 12:10:26.011 UTC [62] FATAL: terminating connection due to unexpected postmaster exit database-1 | 2025-11-19 12:10:26.013 UTC [65] FATAL: terminating connection due to unexpected postmaster exit database-1 | 2025-11-19 12:10:26.013 UTC [58] FATAL: terminating connection due to unexpected postmaster exit database-1 exited with code 137 teslamate-1 | 2025-11-19 12:10:26.922 [error] Postgrex.Protocol (#PID<0.2482.0>) disconnected: ** (Postgrex.Error) FATAL 57P01 (admin_shutdown) terminating connection due to unexpected postmaster exit teslamate-1 | 2025-11-19 12:10:26.922 [error] Postgrex.Protocol (#PID<0.2483.0>) disconnected: ** (Postgrex.Error) FATAL 57P01 (admin_shutdown) terminating connection due to unexpected postmaster exit teslamate-1 | 2025-11-19 12:10:26.923 [error] Postgrex.Protocol (#PID<0.2489.0>) disconnected: ** (Postgrex.Error) FATAL 57P01 (admin_shutdown) terminating connection due to unexpected postmaster exit teslamate-1 | 2025-11-19 12:10:26.923 [error] Postgrex.Protocol (#PID<0.2490.0>) disconnected: ** (Postgrex.Error) FATAL 57P01 (admin_shutdown) terminating connection due to unexpected postmaster exit teslamate-1 | 2025-11-19 12:10:26.923 [error] Postgrex.Protocol (#PID<0.2488.0>) disconnected: ** (DBConnection.ConnectionError) tcp recv (idle): closed
Only container database shuts down. Grafana, mosquito and teslamate keeps running. It is running on a server so I didn't stop it myself.
Thanks for the logs. This looks like you don't use
Type of installation
Docker (https://docs.teslamate.org/docs/installation/docker/)
But rather something like Podman, which is not supported. If you know how to use it, you can, but no support from the devs.
I'm using docker. this was a snippet from my terminal window after docker compose up
This is my compose file:
services:
teslamate:
image: teslamate/teslamate:latest
restart: always
environment:
- ENCRYPTION_KEY=***** #replace with a secure key to encrypt your Tesla API tokens
- DATABASE_USER=teslamate
- DATABASE_PASS=***** #insert your secure database password!
- DATABASE_NAME=teslamate
- DATABASE_HOST=database
- MQTT_HOST=mosquitto
ports:
- 4000:4000
volumes:
- ./import:/opt/app/import
cap_drop:
- all
database:
image: postgres:18-trixie
restart: always
environment:
- POSTGRES_USER=teslamate
- POSTGRES_PASSWORD=*****#insert your secure database password!
- POSTGRES_DB=teslamate
volumes:
- teslamate-db:/var/lib/postgresql
grafana:
image: teslamate/grafana:latest
restart: always
environment:
- DATABASE_USER=teslamate
- DATABASE_PASS=*****#insert your secure database password!
- DATABASE_NAME=teslamate
- DATABASE_HOST=database
ports:
- 3000:3000
volumes:
- teslamate-grafana-data:/var/lib/grafana
mosquitto:
image: eclipse-mosquitto:2
restart: always
command: mosquitto -c /mosquitto-no-auth.conf
# ports:
# - 1883:1883
volumes:
- mosquitto-conf:/mosquitto/config
- mosquitto-data:/mosquitto/data
volumes:
teslamate-db:
teslamate-grafana-data:
mosquitto-conf:
mosquitto-data:
"FATAL: terminating connection due to unexpected postmaster exit database-1"
Postgres died for some unknown reason.
Google AI suggests it could be an out-of-memory issue. How much memory do you have? Use free -h to find out.
it could be an out-of-memory issue.
That was my assumption as well
this looks like your Docker host shut down the container. Please either provide the logs or ensure your host does not run out of reccources