Monitoring behind NAT
Keep track of private servers and home labs without opening ports.
Guide
A small container can send periodic HTTPS requests from your Docker host. Use it to observe the container’s ability to run and reach the internet.
This example runs a dedicated curl container. It can stay Online even if a database, website or Home Assistant container next to it has failed. A running heartbeat container is not a health check of the whole Compose project.
For application monitoring, send only after the application’s own check succeeds, from the application or a checker that actually observes it. For Home Assistant, prefer the automation inside Core.
Replace YOUR_DEVICE_KEY with the value after v= in your device’s heartbeat URL, including the account and device identifiers. The TurnIt endpoint is already filled in. Keep your personal URL private.
You need Docker with Compose available. The example waits 60 seconds after each request and uses a five-second request timeout. If you select another device interval, use the generated Compose example in the dashboard.
Save this as compose.yaml and run docker compose up -d. This check reports connectivity from the heartbeat container.
services:
turnit-heartbeat:
image: curlimages/curl:8.23.0
restart: unless-stopped
environment:
TURNIT_HEARTBEAT_URL: "https://api.turnit.app/api/send?v=YOUR_DEVICE_KEY"
entrypoint: ["/bin/sh", "-c"]
command:
- |
while :; do
curl --fail --silent --show-error --max-time 5 "$$TURNIT_HEARTBEAT_URL" >/dev/null
sleep 60
donedocker compose up -d turnit-heartbeatThe doubled dollar sign in $$TURNIT_HEARTBEAT_URL preserves the variable for the shell inside the container. It prevents Compose from replacing it with a variable from the host. Keep this spelling when copying the example.
The restart policy asks Docker to bring the sender back after an unexpected exit or daemon restart, unless you stopped it. Docker itself still needs to be running. A sleeping Docker Desktop host or a powered-off server cannot send heartbeats.
docker compose logs --tail=50 turnit-heartbeatCheck Last heartbeat after starting. A 429 response suggests an interval mismatch or duplicate sender. This simple loop does not parse Retry-After; keep the saved interval aligned and leave margin in the alert delay.
After saving new timing settings, update the Compose file and rerun the start command to recreate the service. To stop it, target only the heartbeat service rather than bringing down the whole project.
docker compose stop turnit-heartbeatReference: Docker Compose variable interpolation.
Create a device to get your own heartbeat URL and setup instructions.