Traefik Healthcheck Fix¶
Problem¶
Traefik container shows as unhealthy even though: - HTTPS is working (certificates are valid) - Services are routing correctly - Traefik is functioning properly
Root Cause¶
The healthcheck command traefik healthcheck --ping requires the ping endpoint to be explicitly enabled in Traefik configuration. Without --ping=true, the healthcheck fails.
Fix¶
Added two configuration changes:
-
Enable ping endpoint:
-
Add start period to healthcheck:
Complete Configuration¶
command:
- --api.dashboard=true
- --api.insecure=true
- --ping=true # Enable ping endpoint for healthcheck
# ... other configuration ...
healthcheck:
test: ["CMD", "traefik", "healthcheck", "--ping"]
interval: 10s
timeout: 5s
retries: 3
start_period: 10s # Wait 10s before first healthcheck
Why This Works¶
--ping=true: Enables the/pingendpoint that the healthcheck command usesstart_period: 10s: Gives Traefik time to fully initialize before healthchecks begin, preventing false negatives during startup
Verification¶
After applying the fix:
# On VPS
cd /opt/po-platform
# Pull latest changes
git pull origin main
# Restart Traefik
docker compose -f infrastructure/compose/shared.yml --env-file infrastructure/compose/.env.shared restart traefik
# Wait a few seconds
sleep 10
# Check health status
docker ps | grep traefik
# Should show: Up (healthy) not (unhealthy)
# Test ping endpoint manually
docker exec po-traefik traefik healthcheck --ping
# Should exit with code 0 (success)
Expected Result¶
- ✅ Traefik shows as healthy in
docker ps - ✅ Healthcheck passes consistently
- ✅ No impact on functionality (Traefik was already working)
Related¶
- Traefik Unhealthy Fix - General unhealthy container troubleshooting
- Traefik Fixes - Complete Traefik fix documentation