Back to articles
Technology Insight

Advanced Uptime Kuma Configuration: Automated Self-Healing VPS via SSH Webhooks

May 29, 2026

Introduction: Moving from Passive Monitoring to Active Self-Healing

In the realm of modern infrastructure management, maintaining high availability is a cornerstone of operational excellence. Traditional monitoring setups follow a familiar, reactive pattern: a service goes down, an alert is triggered, an engineer is notified, and manual intervention eventually resolves the issue. While this approach keeps teams informed, it introduces critical delays, driving up the Mean Time to Resolution (MTTR).

By leveraging the advanced capabilities of Uptime Kuma—a popular, open-source monitoring tool—combined with secure webhooks and remote SSH execution, you can transition from passive monitoring to automated self-healing. This comprehensive guide walks you through configuring an advanced pipeline where Uptime Kuma detects a website outage and immediately triggers a remote SSH command via a webhook to restart the failing service on your Virtual Private Server (VPS), restoring operations within seconds without human intervention.

The Architecture of Automated Remediation

Before diving into the configuration, it is essential to understand how the components interact. The self-healing ecosystem relies on three core layers:

  • The Monitoring Layer (Uptime Kuma): Continuously pings or checks the HTTP/HTTPS status of your target website.
  • The Automation Bridge (Webhook Receiver): A secure microservice running on or alongside your infrastructure that accepts incoming webhook payloads and translates them into system actions.
  • The Execution Layer (Target VPS): The server hosting your application, configured to safely accept authorized commands to restart services like Nginx, Apache, or Docker containers.
Security Note: Exposing direct SSH capabilities to webhooks requires stringent access controls. We will implement token authentication and restricted command execution to ensure this automation layer does not become a security vulnerability.

Step 1: Setting Up the Webhook Automation Bridge

Uptime Kuma natively supports webhook notifications, but it cannot directly log into an SSH session. To bridge this gap, we use a lightweight webhook server (such as the open-source adnanh/webhook tool) or a custom Node.js/Python script on the target server to listen for Uptime Kuma's trigger.

Installing the Webhook Service

On your target VPS (or a dedicated management server), install the webhook utility. For Ubuntu/Debian systems, execute:

sudo apt update
sudo apt install webhook -y

Defining the Hook Configuration

Create a configuration file named hooks.json. This file defines the endpoint that Uptime Kuma will hit and specifies the exact script to execute when triggered.

[
  {
    "id": "restart-web-service",
    "execute-command": "/opt/scripts/restart_service.sh",
    "command-working-directory": "/opt/scripts",
    "response-message": "Restart command initiated.",
    "trigger-rule": {
      "and": [
        {
          "match": {
            "type": "value",
            "value": "down",
            "parameter": {
              "source": "payload",
              "name": "heartbeat.status"
            }
          }
        }
      ]
    }
  }
]

This configuration defines a specific rule: the execution script will only fire if the incoming JSON payload from Uptime Kuma explicitly states that the heartbeat status is down. This prevents accidental restarts during routine up status updates.

Step 2: Creating the Secure SSH and Service Restart Script

Now we must create the actual script that handles the service remediation. If your webhook server runs on a separate management instance, it will use an SSH key to connect to the production VPS. If it runs locally on the same VPS, it will execute the command via scoped sudo privileges.

Writing the Remediation Script

Create the file at /opt/scripts/restart_service.sh and ensure it has executable permissions:

#!/bin/bash
# Automated Service Recovery Script

TARGET_IP="your_vps_ip"
SSH_USER="recovery-user"
SSH_KEY="/home/webhook/.ssh/id_rsa_recovery"

echo "[$(date)] Outage detected by Uptime Kuma. Initiating remote SSH recovery..." >> /var/log/auto_recovery.log

# Execute the restart command over remote SSH securely
ssh -i "$SSH_KEY" -o StrictHostKeyChecking=accept-new "$SSH_USER"@"$TARGET_IP" "sudo systemctl restart nginx"

if [ $? -eq 0 ]; then
    echo "[$(date)] Success: Nginx service restarted successfully on remote VPS." >> /var/log/auto_recovery.log
else
    echo "[$(date)] Error: Failed to execute restart command via SSH." >> /var/log/auto_recovery.log
fi

Securing the SSH Layer

To follow the principle of least privilege, do not use the root user for this automation. Instead, create a dedicated recovery-user on the target VPS and restrict their sudo capabilities using visudo:

recovery-user ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart nginx

This configuration ensures that even if the SSH key is compromised, the attacker can only execute that one specific restart command, neutralizing broader threats to your infrastructure.

Step 3: Configuring Advanced Webhooks in Uptime Kuma

With the receiving infrastructure secured and prepared, you can now link Uptime Kuma to your automation bridge.

  1. Log into your Uptime Kuma dashboard.
  2. Navigate to Settings > Notification and click Setup Notification.
  3. Select Webhook from the Notification Type dropdown menu.
  4. Name the notification configuration (e.g., Auto-Recovery Webhook).
  5. Enter your Post URL: http://your-webhook-server-ip:9000/hooks/restart-web-service.
  6. Ensure the request method is set to POST and the Content Type is application/json.
  7. Click Save.

To apply this to your specific website monitor, edit the desired monitor, toggle your newly created notification under the "Setup Notification" section, and save the changes.

Step 4: Testing and Validating the Self-Healing Pipeline

An untested backup plan is not a backup plan. To validate that your advanced setup works seamlessly under pressure, simulate a live failure:

  1. Manually stop your web server service on the target VPS: sudo systemctl stop nginx.
  2. Monitor the Uptime Kuma dashboard. Depending on your configured retry intervals, the monitor will turn red and mark the site as Down.
  3. Immediately tail the logs on your webhook server: tail -f /var/log/auto_recovery.log.
  4. Verify that Uptime Kuma successfully triggered the webhook, the SSH authentication succeeded, and the service was automatically brought back online.

Best Practices for Production Environments

While automated remediation drastically improves availability, running it blindly in production can lead to unintended consequences like infinite loops during fatal application errors. Implement these advanced safeguards:

  • Implement Rate Limiting: Configure your webhook server or recovery script to exit if it has run more than three times within a ten-minute window to prevent looping on persistent codebase errors.
  • Set Up Secondary Alerts: Ensure Uptime Kuma sends a high-priority Discord, Slack, or email notification alongside the webhook so your engineering team remains aware that an automated recovery event occurred.
  • Enforce Strict Firewalls: Use iptables or your cloud provider's security groups to restrict incoming traffic on the webhook port (e.g., 9000) exclusively to the IP address of your Uptime Kuma instance.

Conclusion

By transforming Uptime Kuma from an alerting engine into an automated orchestration trigger, you remove human latency from the initial stages of incident response. This architecture ensures that standard runtime glitches, memory exhaustion events, or transient service crashes are resolved within seconds—keeping your web applications operational and your users satisfied while giving your operations team the freedom to focus on root-cause analysis rather than midnight emergency calls.

Advanced Uptime Kuma Configuration: Automated Self-Healing VPS via SSH Webhooks | DPTCloud