What you will set up
Uptime Kuma checks your websites and servers every minute, shows how long each has been up, warns before a certificate expires, and sends an alert when something goes down, to Matrix, email, Telegram, ntfy and many more.
Here it runs from its official rootless image in a Compose project under a user of its own called kuma, behind Caddy from the rootless Docker guide. Its alerts go to a room on the Matrix server from the Matrix guide. The Docker setup follows that tested base; the app results below come from the tested Podman guide on a Melonslab server and were not re-measured under Docker.
The app-specific results below were recorded in the Podman test on a Melonslab server with Debian 13:
- Uptime Kuma 2.5.5 checked a site elsewhere, an app on the same server and a ping to Quad9, and showed all three as up, with the site's certificate expiry.
- When a web app on the server was stopped, Kuma posted a Down alert in a Matrix room, and an Up alert when it came back.
- Kuma logged each login with the visitor's real address, and everything came back by itself after a reboot.
Uptime Kuma used about 130 MB of memory.
A monitor on the same server as the sites it watches cannot tell you that the server itself is down. For that, run Uptime Kuma on another server, and point it at this one.
Before you start
You need:
- a server set up as in the rootless Docker guide, with Caddy running;
- an A record and an AAAA record for
status.example.compointing at your server; - for alerts in Matrix, a Matrix server as in the Matrix guide, and your own account on it.
The examples use status.example.com for Uptime Kuma, matrix.example.com for the Matrix server and @anna:example.com for your own Matrix account. Replace them throughout.
1. Create the user
As root:
useradd -m -s /bin/bash -U kuma
loginctl enable-linger kuma
Do not add the user to the docker group. The daemon is rootless and belongs to this user.
Everything up to step 4 runs as kuma.
2. Let Kuma reach this server
A check of an app on this server, such as https://matrix.example.com, must reach Caddy rather than Kuma itself. Add a host mapping to the Compose service so the container can call the server by name:
extra_hosts:
- "host.docker.internal:host-gateway"
host-gateway is an address that leads to the server outside the container. Use http://host.docker.internal for checks of apps on this server; the apps behind Caddy use their HTTPS names as usual. Checks to the internet are unaffected. This setting was not re-tested under Docker.
3. Describe the Compose service
As kuma, create the app directory and Compose file:
mkdir -p /home/kuma/uptime-kuma/data
cat > /home/kuma/uptime-kuma/compose.yaml <<'YAML'
services:
uptime-kuma:
image: docker.io/louislam/uptime-kuma:2-rootless
ports:
# Only Caddy, on this server, can reach Uptime Kuma: the port is not open to the internet.
- "127.0.0.1:8095:3001"
volumes:
- ./data:/app/data
# ping needs raw sockets
cap_add:
- NET_RAW
extra_hosts:
- "host.docker.internal:host-gateway"
restart: always
YAML
chown -R kuma:kuma /home/kuma/uptime-kuma
The 2-rootless image runs Uptime Kuma as an ordinary user inside the container too, and the tag follows every release of Uptime Kuma 2. NET_RAW lets its ping checks send ICMP. ./data holds the SQLite database with your monitors and settings.
Start it:
uid=$(id -u kuma)
runuser -u kuma -- env HOME=/home/kuma XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/kuma/uptime-kuma && docker compose pull && docker compose up -d"
Add the weekly docker-update.service and docker-update.timer from the rootless Docker guide, with WorkingDirectory=/home/kuma/uptime-kuma, then enable the timer as kuma. The service pulls a new image and recreates the service.
4. Put Caddy in front
As root, add this block to the end of /home/caddy/Caddyfile:
status.example.com {
reverse_proxy 127.0.0.1:8095
}
Restart Caddy:
uid=$(id -u caddy)
runuser -u caddy -- env HOME=/home/caddy XDG_RUNTIME_DIR=/run/user/$uid \
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$uid/bus PATH=/usr/bin:/bin \
bash -lc "export DOCKER_HOST=unix:///run/user/$uid/docker.sock; cd /home/caddy/caddy && docker compose restart caddy"
5. Set it up
Open https://status.example.com. Uptime Kuma first asks which database to use: choose SQLite, a single file in ./data, which suits a few dozen monitors, and Next. Then create your account, with a Username, a Password and Repeat Password, and choose Create.
Next, let Kuma see visitors' real addresses behind Caddy: open the profile menu at the top right, then Settings, Reverse Proxy, set Trust Proxy to Yes, and Save. Under Security in the same settings, you can also turn on two-factor authentication for your account.
6. Add monitors
Choose Add New Monitor. The ones you will use most:
- HTTP(s), for a website or web app: a Friendly Name and the URL. Kuma also shows when the site's certificate expires. To be warned 21, 14 and 7 days before, tick Certificate Expiry Notification under Advanced, which is off for new monitors. Settings, Notifications changes the days.
- Ping, for a server: its Hostname or address.
- TCP Port, for a service such as mail or SSH: a hostname and a port.
Choose Save. Kuma checks each monitor every 60 seconds, which Heartbeat Interval changes.
7. Get alerts in Matrix
Kuma posts its alerts with a Matrix account of its own. As root, run this as the matrix user with that user's DOCKER_HOST; check the container name in docker ps if it is not matrix-synapse. Answer no to the admin question:
uid=$(id -u matrix)
runuser -u matrix -- env HOME=/home/matrix XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
docker exec -it matrix-synapse register_new_matrix_user -c /data/homeserver.yaml http://localhost:8008
docker compose exec -it matrix-synapse register_new_matrix_user -c /data/homeserver.yaml http://localhost:8008
Name it kumabot. Then, from any computer, log in as it to get its access token, with the password you just set in place of BOT_PASSWORD:
curl -s -X POST https://matrix.example.com/_matrix/client/v3/login \
-H 'Content-Type: application/json' \
-d '{"type": "m.login.password", "identifier": {"type": "m.id.user", "user": "kumabot"}, "password": "BOT_PASSWORD", "initial_device_display_name": "Uptime Kuma"}'
Copy the value of access_token, and use it in place of ACCESS_TOKEN to create a room for the alerts, with yourself invited:
curl -s -X POST https://matrix.example.com/_matrix/client/v3/createRoom \
-H 'Authorization: Bearer ACCESS_TOKEN' -H 'Content-Type: application/json' \
-d '{"name": "Alerts", "invite": ["@anna:example.com"], "preset": "private_chat"}'
The answer has the room's room_id, which starts with !. Accept the invitation in Element. Then, in Uptime Kuma, open Settings, Notifications, and choose Set Up Notification:
- Set Notification Type to Matrix, and give it a Friendly Name.
- Enter
https://matrix.example.comas Homeserver URL, theroom_idas Internal Room ID, and the token as Access Token. - Turn on Default enabled, so that new monitors use it, and Apply on all existing monitors.
- Choose Test. A test message arrives in the room. Then choose Save.
From now on, Kuma posts a message such as [Zabbix] [🔴 Down] Request failed with status code 502 when a monitor goes down, and another when it is up again. The account can only post in the rooms it is in, and the room is not encrypted, so keep the alerts free of secrets. For email or another service, choose it as the Notification Type instead.
8. Back up
As root, stop the service for a few seconds so the copy is consistent:
uid=$(id -u kuma)
runuser -u kuma -- env HOME=/home/kuma XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/kuma/uptime-kuma && docker compose stop"
umask 077
mkdir -p /home/kuma/backup
tar czf /home/kuma/backup/uptime-kuma.tgz -C /home/kuma/uptime-kuma data
uid=$(id -u kuma)
runuser -u kuma -- env HOME=/home/kuma XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/kuma/uptime-kuma && docker compose up -d"
That saves the monitors, their history, your account and the notification settings, with the Matrix token. Copy /home/kuma/backup to another machine, and keep it private.
Troubleshooting
A Ping monitor is down with spawn EPERM. The cap_add: NET_RAW line from step 3 is missing from /home/kuma/uptime-kuma/compose.yaml.
A monitor for an app on this server is down, while the app works in your browser. The extra_hosts line from step 2 is missing, or the monitor still points at the public name. Use http://host.docker.internal for apps on this server, and restart the service:
uid=$(id -u kuma)
runuser -u kuma -- env HOME=/home/kuma XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/kuma/uptime-kuma && docker compose restart"
No alerts arrive. The notification is not on for that monitor. Edit the monitor, and tick the notification under Notifications, or edit the notification, and turn on Apply on all existing monitors.