Automate Self-Hosted Instance Updates with Version Checking and Portainer - n8n Workflow

Use this essential n8n workflow to automatically check for new n8n versions using a schedule n8n trigger, compare against the local install, and securely trigger updates via a Portainer webhook.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

DevOps specialists and system administrators managing self-hosted infrastructure.
Users running n8n via Docker/Portainer who require automated maintenance.


  • Anyone looking for robust n8n templates for self-monitoring and lifecycle management.

Overview

Maintaining a self-hosted n8n instance requires keeping it up-to-date to benefit from new features and security patches. This sophisticated n8n workflow eliminates the need for manual version checks and deployment procedures. By utilizing a scheduled n8n trigger, the system periodically checks the official npm registry for the latest n8n version, compares it against the locally installed version (extracted via the local metrics endpoint), and if a discrepancy is found, it automatically executes a deployment webhook (such as a Portainer stack webhook).

This robust n8n automation ensures your instance is always running the newest software, simplifying your maintenance routine and providing a high-value example of advanced n8n node usage in a production environment.

How it Works

This powerful n8n workflow operates on a recurring schedule to enforce automatic updates:


  1. Scheduled Execution (n8n Trigger): The process begins with the Schedule Trigger n8n node, set to run every 16 hours at minute 8.

  2. Fetch Latest Version: An HTTP Request n8n node queries the npm registry to retrieve the version number of the absolute latest n8n release.

  3. Fetch Local Metrics: A second HTTP Request n8n node hits the local instance's /metrics endpoint (assuming the n8n instance is accessible locally, e.g., via 127.0.0.1) to pull current system information.

  4. Extract Local Version (Custom Code): A Code n8n node processes the raw metrics data, using regex to precisely extract the installed n8n version number, ensuring only the numerical value is isolated.

  5. Conditional Check: The If n8n node compares the externally fetched latest version (Step 2) with the locally installed version (Step 4). The flow only proceeds if these two values are not equal, indicating an update is required.

  6. Trigger Portainer Update: If an update is necessary, an HTTP Request n8n node sends a POST request to a pre-configured Portainer Stack Webhook URL. This action automatically instructs Portainer to pull the newest Docker image and redeploy the n8n container, completing the automated update process.

Installation Guide

To deploy this comprehensive n8n workflow, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON and import it directly into your self-hosted n8n instance via the Workflows section. This provides the full framework of this valuable n8n template.

  2. Configure Local Metrics Node:

Locate the 'Get local n8n metrics' n8n node.
Ensure the URL field points correctly to your local n8n instance's metrics endpoint (e.g., https://127.0.0.1/metrics). If your instance uses self-signed certificates, ensure 'Allow Unauthorized Certificates' is enabled.

  1. Configure Portainer Webhook:

Locate the 'Portainer Webhook' n8n node.
Replace the placeholder URL (https://portainer.tld.com/...) with the actual Portainer stack webhook URL you configured for your n8n deployment. This webhook is the key n8n trigger for the deployment action.

  1. Activate: Save and activate the n8n workflow. The Schedule Trigger will now initiate version checks automatically.

Node Details

Schedule Trigger: Serves as the primary n8n trigger. It is configured to initiate the workflow every 16 hours at minute 8, ensuring regular checks without overloading the system.
Get the latest n8n version (HTTP Request n8n node): Fetches version data from https://registry.npmjs.org/n8n/latest. This provides the benchmark for the required version update.
Get local n8n metrics (HTTP Request n8n node): Accesses the local n8n metrics endpoint (/metrics) to retrieve the currently running version.
local n8n version (Code n8n node): Crucial for data manipulation. This n8n node uses a JavaScript snippet and regex (/n8nversioninfo{[^}]version="(v[\d.]+)"/) to parse the complex metrics output and extract a clean, usable installed n8n version number (versionCli).
If (n8n node): Performs the version control logic. It checks if the latest version from npm is not equal to the versionCli extracted locally. Only if this condition is met does the n8n workflow proceed.


  • Portainer Webhook (HTTP Request n8n node): The final action n8n node. Sends a POST request to the Portainer webhook URL to signal the Docker stack to pull the new n8n image and restart the container.

Related n8n Workflows

Free

Nodes: 5 Nodes
Updated: December 26 2025
View all
Created by

Featured*