<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by The Minh Nguyen | NextGrowth.AI on Medium]]></title>
        <description><![CDATA[Stories by The Minh Nguyen | NextGrowth.AI on Medium]]></description>
        <link>https://medium.com/@nextgrowth.ai?source=rss-3c7c7f9c1149------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*gRTqcGf6U1H5loan</url>
            <title>Stories by The Minh Nguyen | NextGrowth.AI on Medium</title>
            <link>https://medium.com/@nextgrowth.ai?source=rss-3c7c7f9c1149------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 17:36:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nextgrowth.ai/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Scaling n8n with Queue Mode: Automated Deployment Script]]></title>
            <link>https://medium.com/@nextgrowth.ai/scaling-n8n-with-queue-mode-automated-deployment-script-8ee5c317be6e?source=rss-3c7c7f9c1149------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ee5c317be6e</guid>
            <dc:creator><![CDATA[The Minh Nguyen | NextGrowth.AI]]></dc:creator>
            <pubDate>Sun, 24 Aug 2025 15:32:44 GMT</pubDate>
            <atom:updated>2025-09-16T02:09:40.828Z</atom:updated>
            <content:encoded><![CDATA[<p>When your n8n workflows start to grow-more triggers, heavier jobs, and higher execution volumes-the default single-process mode can quickly become a bottleneck. Long-running workflows may slow down the editor, block new executions, or even crash under heavy load.</p><p><a href="https://github.com/thenguyenvn90/n8n-queue-mode">Queue Mode</a> fixes that by separating responsibilities: the main n8n instance stays responsive for editing, webhooks, and scheduling, while workers pull jobs from Redis, execute them in parallel, and persist results in PostgreSQL. Pair that with Prometheus &amp; Grafana for visibility, and you’ve got a stack that scales without surprises.</p><p>This guide shows you how to stand up a production-ready n8n environment on an Ubuntu VPS with Docker Compose and Traefik-complete with metrics, dashboards, and alerts (no heavy log stack required).</p><p><strong>In this guide, you’ll learn</strong>:</p><ul><li>✅ What Queue Mode is and why it matters in production</li><li>✅ How the architecture fits together with Docker Compose, Traefik, Redis, and PostgreSQL</li><li>✅ Step-by-step manual configuration to deploy Queue Mode on Ubuntu</li><li>✅ How to manually verify health checks, scale workers, and troubleshoot common issues</li><li>✅ Best practices to keep your automation stack secure and reliable</li></ul><p><strong>Prefer automation?</strong></p><p>If you’d rather skip manual configuration, our <a href="https://github.com/thenguyenvn90/n8n-toolkit">n8n Manager</a> script gives you a turnkey, production-ready setup in minutes. One script handles fresh installs, repeatable environments, upgrades, and full disaster recovery (backup &amp; restore). Flip on observability with Prometheus and Grafana, and you’ll have real-time dashboards and alerts tracking n8n’s health and performance.</p><h3>Why Queue Mode?</h3><p>Running n8n in Queue Mode isn’t just about handling more jobs — it’s about making your automation stack stable, scalable, and production-ready. Here’s why:</p><p><strong>1. Scalable Execution</strong></p><ul><li>Heavy workflows don’t block the main instance — instead, they’re distributed across multiple workers.</li><li>Add more workers anytime to process more jobs in parallel.</li></ul><p><strong>2. Responsive UI</strong></p><ul><li>The main service is dedicated to editor, API, and webhooks.</li><li>Even when dozens of workflows are running, the UI remains smooth and responsive.</li></ul><p><strong>3. Improved Reliability</strong></p><ul><li>If one worker crashes, others keep running — no single point of failure.</li><li>Redis ensures queued jobs aren’t lost; they’ll be picked up by the next available worker.</li></ul><p><strong>4. Flexible Scaling</strong></p><ul><li>Start small (1 worker, low concurrency).</li><li>Scale horizontally (add workers) or vertically (bigger servers) as workflows grow.</li><li>Works well for cloud VPS, Docker Swarm, or Kubernetes deployments.</li></ul><p><strong>5. Workload Isolation</strong></p><ul><li>UI, scheduling, and execution are separate processes.</li><li>Long-running or resource-intensive workflows don’t interfere with day-to-day operations.</li></ul><blockquote><em>Think of it like a busy restaurant: instead of one person taking orders </em>and<em> cooking, the manager (main) handles orders while multiple chefs (workers) do the cooking.</em></blockquote><h3>How Queue Mode works</h3><p>Queue Mode splits n8n into two roles: a main instance that stays responsive (editor, webhooks, schedules) and one or more workers processes that do the heavy lifting. Jobs are placed on Redis (BullMQ) and processed by the next available worker; results are written to PostgreSQL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-1onYGuAg2QSoC2V.png" /></figure><p><strong>Workers &amp; concurrency</strong><br>Each worker is a separate Node.js process (running the n8n <em>worker</em> command). Workers can run multiple executions in parallel (configurable concurrency), so you scale throughput by increasing worker count and/or concurrency.</p><p><strong>Why this scales</strong><br>Add workers to handle spikes; remove them when traffic is low. The main instance remains stable because it doesn’t execute workflows in Queue Mode-it only schedules and enqueues.</p><p><strong>Execution lifecycle (step-by-step)</strong>:</p><ol><li><strong>Trigger &amp; schedule intake</strong><br>The main n8n instance handles webhooks, timers, and other triggers. When a run is needed, it creates an execution (but does not run it).</li><li><strong>Enqueue</strong><br>The main instance pushes an execution ID (and payload) to Redis, which maintains the queue of pending jobs.</li><li><strong>Dispatch</strong><br>An available <strong>worker</strong> pulls the next job from Redis.</li><li><strong>Fetch context</strong><br>The worker uses the execution ID to load the workflow definition, credentials, and context from PostgreSQL.</li><li><strong>Execute</strong><br>The worker runs the workflow. If configured, it can process several executions concurrently.</li><li><strong>Persist results</strong><br>On completion, the worker writes execution results and status back to PostgreSQL.</li><li><strong>Acknowledge &amp; notify</strong><br>The worker acks the job in Redis (finish/fail per retry policy). Redis updates the queue state; the main instance can reflect completion in UI/API and any follow-up logic.</li></ol><h3>How n8n Queue Mode works with monitoring</h3><p>n8n Main handles the UI/API, webhooks, and schedules. Instead of executing workflows itself, it enqueues runs to Redis (BullMQ). Workers pull jobs from Redis, execute them in parallel, and persist results in PostgreSQL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6C2C22WET7wmMYFQ.png" /></figure><p><strong>Execution lifecycle + monitoring hooks:</strong></p><ol><li><strong>Create &amp; enqueue</strong><br>n8n Main creates an execution (doesn’t run it) and pushes a job to Redis.<br><strong>Observed via:</strong> n8n metrics (execution counters/rates, failures, webhook counts, scheduler events).</li><li><strong>Dispatch &amp; run</strong><br>A Worker pulls the job from Redis, loads workflow context from Postgres, and executes.<br><strong>Observed via:</strong> queue depth (waiting/active/failed), execution durations/throughput (from n8n metrics), Redis ops/sec.</li><li><strong>Persist &amp; acknowledge</strong><br>The Worker writes results to Postgres and acks the job in Redis; n8n Main updates status in the UI/API.<br><strong>Observed via:</strong> Postgres connections/locks, execution status counters; Redis latency/evictions.</li></ol><p><strong>What each metrics source adds</strong>:</p><ul><li><strong>Traefik metrics:</strong> Edge reliability and routing health (request rates, 4xx/5xx).</li><li><strong>Postgres Exporter:</strong> Connections, locks, cache hit ratio, checkpoints → early warning for DB saturation.</li><li><strong>Redis Exporter:</strong> Memory, keys, <strong>evictions</strong>, ops/sec, clients → queue pressure &amp; backlog risk.</li><li><strong>Node Exporter (host):</strong> CPU, RAM, disks, filesystem, network → VPS capacity &amp; bottlenecks.</li><li><strong>cAdvisor (containers):</strong> Per-container CPU/mem/restarts → noisy containers &amp; right-sizing.</li><li><strong>n8n Main (/metrics):</strong> Executions, failures, durations, webhook/API rates, health/readiness.</li></ul><p><strong>How it all fits together</strong>:</p><p>Prometheus continuously scrapes n8n Main, Traefik, and all exporters (Postgres, Redis, Node Exporter, cAdvisor). Grafana then queries Prometheus to power real-time dashboards and alerts.</p><p>Read more detail about <a href="https://nextgrowth.ai/n8n-monitoring-prometheus-grafana/">n8n Monitoring with Prometheus &amp; Grafana</a>.</p><h3>Task Processing Flow</h3><p>Understanding how jobs move through the system helps clarify why Queue Mode is so powerful. Here’s how it works:</p><h3>Case 1: Single Worker</h3><ul><li>The main n8n instance enqueues workflow executions into Redis (Job Queue).</li><li>A single worker polls Redis, picks up tasks, runs them, and stores results in PostgreSQL.</li><li>Concurrency (e.g., N8N_WORKER_CONCURRENCY=5) controls how many tasks the worker can run at once.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8DYzaIwP-1uuNFJI.png" /></figure><h3>Case 2: Multiple Workers</h3><ul><li>With 2+ workers, Redis distributes tasks between them (first-come, first-served).</li><li>This doubles or triples throughput (depending on the number of workers).</li><li>If one worker fails, others continue processing — improving resilience.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hnN6dwVEUROW2owm.png" /></figure><h3>Step-by-Step Manual Install n8n Queue Mode on Ubuntu with Docker</h3><blockquote><em>This section covers the manual, from-scratch deployment. An automated script option follows in the </em><a href="https://nextgrowth.ai/scaling-n8n-queue-mode-docker-compose/#Automated_n8n_Queue_Mode_Installation_One_Script"><em>next section</em></a><em>.</em></blockquote><p>In this guide, I’ll show you how to deploy <strong>n8n in Queue Mode without monitoring</strong>. For a complete setup-including Prometheus &amp; Grafana monitoring for both Single and Queue mode-see the full guide .</p><p>We’ll deploy n8n in Queue Mode on a single Ubuntu VPS using Docker Compose. The stack includes:</p><ul><li><strong>Traefik</strong> — HTTPS (Let’s Encrypt) + reverse proxy; routes traffic to n8n.</li><li><strong>n8n Main</strong> — Editor/UI, API, webhooks, schedules; enqueues jobs to Redis.</li><li><strong>n8n Worker(s)</strong> — Pull jobs from Redis, execute workflows, write results to Postgres; scale horizontally.</li><li><strong>Redis (BullMQ)</strong> — Queue for pending and active executions.</li><li><strong>PostgreSQL</strong> — System of record for workflows, execution data, and encrypted credentials.</li></ul><blockquote><em>Not included here: monitoring (Prometheus, Grafana, exporters).</em></blockquote><p><strong>Where we deploy:</strong><br>For this guide, all services (main + workers + Redis + Postgres + Traefik) run on the same VPS for simplicity and cost efficiency. It’s a solid starting point for most small teams.</p><p><strong>When to go beyond one VPS:</strong><br>In higher‑load or mission‑critical environments, you can scale by:</p><ul><li>Running <strong>multiple workers on additional VPS instances</strong> (pointing to the same Redis).</li><li>Moving <strong>Redis and PostgreSQL</strong> to managed services or dedicated servers for high availability.</li><li>Adding <strong>more workers</strong> or autoscaling (Kubernetes/Docker Swarm) as throughput needs grow.</li></ul><p>This layout gives you a production‑ready baseline now, and a clear path to horizontal scaling later.</p><h3>1. Prepare VPS</h3><p>Recommended VPS Sizing &amp; Worker Strategy:</p><h3>2. Create DNS record</h3><ul><li>Create an <strong>A/AAAA</strong> record for your n8n host:</li><li>Point n8n.&lt;your-domain&gt; → your server’s public IP.</li></ul><h3>3. Install Docker &amp; Compose</h3><h3>4. Clone our queue-mode repo</h3><p>In this guide I just show use how to deploy n8n queue mode without monitoring. You can check the detail guide here on how to deploy n8n (both single and queue mode) with Prometheus &amp; Grafana Monitoring here</p><h3>5. Create project and copy templates</h3><p>It’s best to install n8n in a dedicated folder on your VPS. This keeps everything in one place, so upgrade, backups, restore are easy to manage later.</p><h3>6. Configure environment variables</h3><p>This setup requires two key files:</p><p>With your VPS and Docker Compose ready, configure the following environment variables to enable Queue Mode. Here are the key variables you need to set:</p><p>EXECUTIONS_MODE=queue</p><p>Enables Queue Mode (main schedules; workers execute).</p><p>QUEUE_BULL_REDIS_HOST=redis</p><p>Hostname of the Redis instance (service name on the Docker network).</p><p>QUEUE_BULL_REDIS_PORT=6379</p><p>Redis port (defaults to 6379).</p><p>QUEUE_BULL_REDIS_PASSWORD</p><p>Password for Redis (set if Redis auth is enabled).</p><p>OFFLOAD_MANUAL_EXECUTIONS_TO_WORKERS=true</p><p>Sends manual executions to workers (keeps editor responsive).</p><p>QUEUE_HEALTH_CHECK_ACTIVE=true</p><p>Enables internal health checks for the Redis connection.</p><p>I’ve pre-filled the core settings above in the .env file. What you need to do is just update your domain, email, timezone, secrets:</p><h3>8. Health check</h3><p>Run these commands after deployment to verify everything is working:</p><h3>Automated n8n Queue Mode Installation (One Script)</h3><p>Skip the hand wiring and go straight to a production-ready Queue Mode setup. The <a href="https://github.com/thenguyenvn90/n8n-toolkit">n8n Manager script</a> installs everything for you-Traefik (HTTPS), n8n Main + Workers, Redis, PostgreSQL, and (optionally) Prometheus + Grafana-with sane, secure defaults. It’s idempotent (safe to re-run), version-aware, and logs every step so ops stay predictable.</p><h3>What this script n8n_manager.sh gives you</h3><ul><li><strong>One command</strong> to provision Queue Mode on an Ubuntu VPS (Docker Compose).</li><li><strong>TLS &amp; routing</strong> via Traefik + Let’s Encrypt, with Basic Auth in front of dashboards.</li><li><strong>Strong secrets</strong> generated and pinned into .env.</li><li><strong>Repeatable installs &amp; upgrades</strong> with version validation.</li><li><strong>(Optional) Observability</strong>: --monitoring auto-provisions Prometheus + Grafana, datasource, dashboards, and starter alerts.</li></ul><h3>Quick start</h3><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W-t1URQX2CS8lSik.gif" /></figure><blockquote><em>If you want to enable the </em><strong><em>monitoring</em></strong><em> option, follow my detailed guide here: </em><a href="https://nextgrowth.ai/n8n-monitoring-prometheus-grafana/#Install_n8n_queue_mode_with_monitoring"><em>install n8n queue mode with monitoring</em></a></blockquote><h3>Monitor and scale</h3><h3>n8n Queue Mode: Health &amp; Performance in Grafana</h3><p>Keeping Queue Mode healthy comes down to watching a few signals and scaling workers/concurrency before the queue backs up.<br>With our Prometheus + Grafana setup, you get real dashboards-queue depth, failure rate, p95 duration, edge 5xx, and CPU/RAM headroom-so you can make data-driven calls on when to add workers or raise concurrency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/0*AtGKhtpQR4TIUZ-5.png" /></figure><h3>When to Scale (read your panels like this)</h3><p>If ANY of these hold for ≥ 5 minutes: scale OUT workers.</p><ul><li><strong>Queue Backlog (waiting)</strong></li><li><strong>Trigger to scale:</strong> Backlog stays <strong>&gt; 0</strong> for <strong>&gt; 5–10 min</strong>, or consistently <strong>&gt; 50–100 jobs</strong> during normal hours.</li><li>Why: Arrival rate &gt; processing rate. Add workers or bump concurrency.</li><li><strong>Queue throughput (completed/sec) vs arrival rate</strong></li><li><strong>Trigger to scale:</strong> Throughput plateaued <strong>below</strong> arrival for multiple intervals (e.g., 3–4 panels worth).</li><li>Why: You’re under-provisioned; more parallelism needed.</li><li><strong>Event loop lag (p99) &amp; Current Event Loop Lag</strong></li><li><strong>Trigger to scale:</strong> <strong>p99 &gt; 200 ms</strong> (or tile &gt; ~100–150 ms) for <strong>&gt; 5 min</strong>.</li><li>Why: Workers are CPU-bound or saturated; add workers (or reduce per-worker concurrency).</li><li><strong>CPU usage (cores)</strong></li><li><strong>Trigger to scale:</strong> Sustained <strong>&gt; 70–80%</strong> per worker for <strong>&gt; 10 min</strong>.</li><li>Why: You’re at compute headroom; new workers spread the load.</li><li><strong>Memory — RSS</strong></li><li><strong>Trigger to scale:</strong> RSS near the container/host limit (or climbing with GC duration rising).</li><li>Why: Risk of OOM/restarts; either add workers (with lower concurrency) or increase memory.</li><li><strong>Execution success ratio &amp; failures</strong></li><li><strong>Trigger to scale:</strong> Success ratio dropping while backlog rises (no major code changes).</li><li>Why: Starvation/timeouts under load; more capacity helps.</li></ul><h3>Don’t scale (yet) if these are the root cause</h3><ul><li><strong>API error rate (5xx)</strong> is up (Traefik panel) but <strong>queue backlog</strong> is normal<br>→ investigate misroutes, upstream API issues, bad deploys-not worker count.</li><li><strong>Postgres</strong> near connection/lock limits or high I/O wait (you’ll see in Postgres/cAdvisor dashboards)<br>→ raise DB limits, tune pool, or move Postgres to a larger box before adding workers.</li><li><strong>Redis</strong> shows <strong>evictions &gt; 0</strong>, high latency, or memory pressure<br>→ fix Redis memory/config first; scaling workers can <strong>worsen</strong> it.</li></ul><h3>Quick rules of thumb</h3><ul><li>If <strong>backlog &gt; 50 for &gt; 10 min</strong> and <strong>CPU &lt; 70%</strong>, first <strong>increase per-worker concurrency</strong> a notch (e.g., 5 → 8).</li><li>If <strong>CPU &gt; 75%</strong> and <strong>lag is high</strong>, <strong>add workers</strong> (keep concurrency moderate).</li><li>If <strong>memory</strong> is the constraint, <strong>reduce concurrency</strong> and add workers (spread memory footprint).</li><li>Re-check <strong>throughput</strong> and <strong>backlog</strong> after each change; change <strong>one lever at a time</strong>.</li></ul><h3>How to scale</h3><h3>Post-scale sanity checklist (10–15 min after change)</h3><h3>Redis and RabbitMQ in n8n Queue Mode</h3><p>n8n can leverage both <strong>Redis</strong> and <strong>RabbitMQ</strong>, but they serve very different purposes in the ecosystem. Understanding this distinction is key when scaling n8n or connecting it to other event-driven systems.</p><h3>Redis in n8n Queue Mode</h3><p>Redis is the <strong>primary backend</strong> for n8n’s internal job queue when you run in <em>Queue Mode</em>.</p><ul><li><strong>Configuration</strong><br>The main n8n instance then uses <strong>BullMQ</strong> (a Redis-based queue library) to manage jobs.</li><li><strong>Job Enqueuing</strong><br>When a workflow is triggered, the execution is packaged as a job and pushed into Redis.</li><li><strong>Worker Processing</strong><br>Separate <em>worker containers</em> (or processes) pull jobs from Redis and run the workflows asynchronously. This separation of “dispatcher” (the main n8n) and “executor” (the workers) allows:</li><li>Horizontal scaling (add more workers to handle load).</li><li>Resilience (if one worker crashes, others keep running).</li><li>Faster editor response times (main instance isn’t blocked by heavy jobs).</li></ul><p>👉 In short: <strong>Redis = n8n’s internal job queue</strong> for scaling and stability.</p><h3>RabbitMQ in n8n Workflows</h3><p>Unlike Redis, RabbitMQ is <strong>not used by n8n internally</strong>. Instead, it’s an integration point for event-driven architectures, letting n8n interact with external systems.</p><ul><li><strong>RabbitMQ Trigger Node</strong><br>Starts a workflow whenever a new message arrives in a RabbitMQ queue. This lets n8n <em>react</em> to external events.</li><li><strong>RabbitMQ Node (Publish/Consume)</strong><br>Allows your workflows to publish new messages or consume existing ones from RabbitMQ. Perfect for chaining n8n automations with other microservices or applications.</li></ul><h3>Example Scenario</h3><ul><li>A logistics system publishes shipping updates into a RabbitMQ queue.</li><li>An n8n workflow, listening with a <strong>RabbitMQ Trigger</strong>, processes each update.</li><li>That workflow pushes heavier tasks into <strong>Redis</strong> for worker execution (e.g., database updates, report generation).</li><li>Another n8n workflow publishes processed results back to a different RabbitMQ queue, where a warehouse system consumes them.</li></ul><h3>Key Takeaway</h3><ul><li><strong>Redis</strong> → powers n8n’s <em>internal</em> job queue in Queue Mode.</li><li><strong>RabbitMQ</strong> → connects n8n to <em>external</em> event streams and services.</li></ul><p>Think of Redis as the <strong>engine inside n8n</strong> that makes scaling possible, while RabbitMQ is the <strong>bridge</strong> that lets n8n talk with the rest of your ecosystem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2WUeWWnP80pdT4lW.png" /></figure><h3>Conclusion</h3><p><strong>Queue Mode</strong> upgrades n8n from a single box to a <strong>scalable, resilient platform</strong>: the editor stays snappy, failures are isolated, and you can add workers as load grows. With this guide you now have two clear paths:</p><ul><li><strong>Manual path</strong> (Step-by-Step): precise control over each component-from DNS and Docker to health checks and scaling.</li><li><strong>Automation path</strong> (<strong>n8n Manager</strong>): one script to install, upgrade, backup, restore, and enable monitoring with sane defaults and repeatable results.</li></ul><p><em>Originally published at </em><a href="https://nextgrowth.ai/scaling-n8n-queue-mode-docker-compose/"><em>https://nextgrowth.ai</em></a><em> on August 24, 2025.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ee5c317be6e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Self-Host n8n Automation: Install, Upgrade, Backup & Restore]]></title>
            <link>https://medium.com/@nextgrowth.ai/self-host-n8n-automation-install-upgrade-backup-restore-df5ab135b17c?source=rss-3c7c7f9c1149------2</link>
            <guid isPermaLink="false">https://medium.com/p/df5ab135b17c</guid>
            <dc:creator><![CDATA[The Minh Nguyen | NextGrowth.AI]]></dc:creator>
            <pubDate>Sun, 24 Aug 2025 07:17:23 GMT</pubDate>
            <atom:updated>2025-09-16T02:16:40.727Z</atom:updated>
            <content:encoded><![CDATA[<p>If you already know about n8n and want to deploy it on your own server (like a VPS) for greater <strong>flexibility, privacy, and scalability</strong>, this guide is for you.</p><p>Maybe you’ve asked yourself: <em>“What’s the best way to install n8n for production on Ubuntu?”</em> — Docker, Traefik, PostgreSQL, SQLite, Nginx… it can get confusing fast.</p><p>This guide cuts through the noise, and it will walk you through:</p><ul><li>✅ Installing <strong>n8n</strong> on an <strong>Ubuntu</strong> server with <strong>Docker Compose</strong>, <strong>Traefik</strong>, and <strong>PostgreSQL</strong></li><li>✅ Safely <strong>upgrading</strong> n8n to a pinned or latest version</li><li>✅ <strong>Backing up</strong> and <strong>restoring</strong> your entire stack to prevent data loss</li><li>✅ Adding <strong>monitoring</strong> with <strong>Prometheus &amp; Grafana</strong> for dashboards and alerts</li></ul><p>By the end, you’ll fully understand the <strong>lifecycle of a production-ready n8n instance</strong> -and you’ll be able to install, upgrade, back up, and restore your own deployment without depending on any other platform.</p><p><strong>Prefer automation?</strong></p><p>Prefer not to hand-configure? <a href="https://github.com/thenguyenvn90/n8n-toolkit"><strong>n8n Manager</strong></a> gives you a turnkey, production-ready setup in minutes. One script covers install, repeatable envs, upgrades, and full disaster recovery (backup &amp; restore). Enable monitoring to auto-provision Prometheus + Grafana and get real-time dashboards and alerts on your n8n’s health and performance.</p><p>Before you dive into self-hosting n8n, it’s important to understand what’s involved. Running your own automation stack means you’re not only installing n8n-you’re also responsible for keeping the server secure, stable, and updated.</p><p><strong>✅ 1. Technical Knowledge</strong></p><p>Self-hosting n8n requires familiarity with:</p><ul><li><strong>Server setup and configuration</strong> — installing software, managing processes, troubleshooting errors.</li><li><strong>Docker and containers</strong> — building, running, and maintaining containerized applications.</li><li><strong>Resource management and scaling</strong> — adjusting CPU, memory, and storage as workflows grow.</li><li><strong>Security hardening</strong> — setting up firewalls, SSL certificates, and secure access.</li><li><strong>n8n configuration</strong> — customizing .env files, enabling features like queue mode, handling updates.</li><li><strong>VPS management</strong> — provisioning, monitoring, and maintaining a cloud server.</li><li><strong>DNS and domains</strong> — pointing your domain/subdomain to the server and configuring records.</li></ul><p><strong>✅</strong> <strong>2. Server Requirements</strong></p><ul><li><strong>Operating System:</strong> Ubuntu 22.04 LTS (recommended) — ideally on a fresh VPS or dedicated server.</li><li><strong>Minimum resources:</strong> 1 vCPU, 2 GB RAM, 20 GB storage (sufficient for testing).</li><li><strong>Production resources:</strong> 2+ vCPU, 4+ GB RAM, 50+ GB storage (for stability and larger workflows).</li><li><strong>Access:</strong> Root or sudo privileges to install packages and manage Docker.</li></ul><p><strong>✅ 3. Domain Name</strong></p><ul><li>A registered <strong>domain</strong> or <strong>subdomain</strong> that points to your server’s IP address.</li><li>Example: n8n.yourdomain.com</li><li>Needed for issuing free HTTPS certificates via Let’s Encrypt.</li></ul><p><strong>✅ 4. Email Address</strong></p><ul><li>A valid email address (e.g., admin@yourdomain.com) for SSL certificate registration.</li><li>Let’s Encrypt will use this to send renewal reminders and alerts.</li></ul><h3>What You Need to Run n8n (and Why)</h3><p>The Production Stack (at a glance):</p><ul><li><strong>Docker + Docker Compose (on Ubuntu):</strong> Orchestrates n8n, PostgreSQL, and Traefik into one repeatable, production-ready setup.</li><li><strong>PostgreSQL:</strong> Stores workflows, credentials, executions, and logs reliably.</li><li><strong>Traefik (reverse proxy):</strong> Handles HTTPS termination, domain routing, and Let’s Encrypt certificates automatically.</li><li><strong>n8n application:</strong> The automation engine you’ll access from your browser.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9-ltoTJnxXh2kOGN.png" /></figure><p><strong>n8n Single Mode Observability Architecture:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8F2acIBxSetNgDSi.png" /></figure><p><strong>Why Docker Compose on Ubuntu?</strong></p><p>The best practice for production is to run n8n using <strong>Docker Compose</strong>, because it:</p><ul><li>Starts/stops the entire stack with one command.</li><li>Runs each service in its own container for safety and easier debugging.</li><li>Simplifies upgrades and rollbacks.</li><li>Provides resilience with restart policies and persistent volumes.</li><li>Centralizes environment variables, storage, and scaling in one file.</li></ul><p><strong>Why PostgreSQL (not SQLite)?</strong></p><p>Use <strong>PostgreSQL</strong> in production instead of SQLite because it:</p><ul><li>Handles multiple workers and higher throughput.</li><li>Supports queue mode and scaling.</li><li>Enables safer backups and migrations.</li><li>Maintains stronger data integrity under load.</li></ul><p><strong>Why Traefik (not Nginx or Caddy)?</strong></p><p>For HTTPS and routing, <strong>Traefik</strong> is the best choice for Dockerized n8n because it:</p><ul><li>Auto-discovers containers with Docker labels.</li><li>Manages Let’s Encrypt SSL certificates automatically.</li><li>Supports sticky sessions and load balancing.</li><li>Integrates seamlessly with Docker Compose.</li></ul><h3>Automating n8n Management with Scripts</h3><p>Managing n8n by hand-installing, upgrading, backing up, restoring-takes time and invites mistakes. That’s why I built <a href="https://github.com/thenguyenvn90/n8n-toolkit">n8n_manager.sh</a>, a script that automates the entire lifecycle of a self-hosted n8n instance in just a few commands.</p><p><strong>What it covers:</strong></p><ul><li><strong>Install</strong> — Deploy n8n with Docker Compose, PostgreSQL, and Traefik (HTTPS via Let’s Encrypt).</li><li><strong>Upgrade</strong> — Safely pull a pinned or latest n8n image and redeploy with validation and logs.</li><li><strong>Backup</strong> — Archive DB dumps, named volumes, SSL certs, and config files (checksums included).</li><li><strong>Restore</strong> — Recover from a local file or rclone remote in minutes.</li><li><strong>Monitoring</strong> — One-flag setup for Prometheus + Grafana with pre-provisioned dashboards and alert rules.</li></ul><h3>Quick Start</h3><p>Download the script:</p><p>The <em>n8n_manager.sh</em> script is the main tool to <strong>install, upgrade, backup, restore, cleanup and monitor</strong> your n8n stack. Check detail here <a href="https://github.com/thenguyenvn90/n8n-toolkit/blob/main/README.md">n8n Manager — User Guide</a></p><p><strong>Example: install n8n (single mode) in Ubuntu VPS with docker compose</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8S082iS7Z17netQy.gif" /></figure><blockquote><em>If you want to enable the </em><strong><em>monitoring</em></strong><em> option, follow my detailed guide here: </em><a href="https://nextgrowth.ai/n8n-monitoring-prometheus-grafana/#Install_n8n_single_mode_with_monitoring"><em>install n8n single mode with monitoring</em></a></blockquote><h3>Step-by-Step Manual Install n8n Single Mode on Ubuntu with Docker</h3><p>In this section, we’ll manually set up a <strong>production-ready n8n stack</strong> on Ubuntu using Docker Compose. The stack will include:</p><ul><li><strong>n8n</strong> — the automation platform</li><li><strong>PostgreSQL</strong> — database for storing workflows and credentials</li><li><strong>Traefik</strong> — reverse proxy for HTTPS and domain routing</li><li><strong>Let’s Encrypt</strong> — automatic SSL certificate management</li></ul><p>Use this as a <strong>starting point</strong>. Size up or down after you observe real traffic, execution duration, and resource headroom.</p><p>To make your n8n instance accessible online, create a <strong>dedicated subdomain</strong> that points to your server’s IP address.</p><p>Add the following DNS record in your domain provider’s DNS settings:</p><p>Wait a few minutes for DNS propagation, then verify that your domain resolves to your VPS IP.</p><h3>Step 2: Install Docker and Docker Compose</h3><p>Docker lets us run n8n, PostgreSQL, and Traefik in isolated containers. Docker Compose ties them together into a single stack.</p><h3>Step 3: Create docker-compose.yml and .env file</h3><p><strong>Prepare the project directory</strong></p><p>It’s best to install n8n in a dedicated folder on your VPS. This keeps everything in one place, so upgrade, backups, restore are easy to manage later.</p><p><strong>Create docker-compose.yml</strong></p><p>You can copy the <em>docker-compose.yml</em> here or from my GitHub: <a href="https://github.com/thenguyenvn90/n8n-toolkit/blob/main/single-mode/docker-compose.yml">single-mode/docker-compose.yml</a></p><p><strong>Create the .env configuration file</strong></p><p>Copy the <em>.env</em> file here or from my GitHub <a href="https://github.com/thenguyenvn90/n8n-toolkit/blob/main/single-mode/.env">single-mode/.env</a> and then update the values for your own DOMAIN, SSL_EMAIL, GENERIC_TIMEZONE, N8N_ENCRYPTION_KEY, and some Strong Passwords:</p><p>Edit the top of your /home/n8n/.env file:</p><h3>Step 4: Launch the n8n stack</h3><p>The Docker Compose file runs three main containers:</p><ul><li><strong>n8n</strong> — the automation app itself.</li><li><strong>Traefik</strong> — the reverse proxy that terminates TLS/SSL certificates and routes HTTPS traffic to n8n.</li><li><strong>PostgreSQL</strong> — the database container for storing workflows, credentials, and execution history.</li></ul><p>It also creates and mounts persistent storage volumes:</p><p>n8n-data</p><p>Volume</p><p>/home/node/.n8n</p><p>Stores encryption keys, user sessions, and small metadata.</p><p>postgres-data</p><p>Volume</p><p>/var/lib/postgresql/data</p><p>Stores the PostgreSQL database files (all workflows, credentials, etc.).</p><p>letsencrypt</p><p>Volume</p><p>/letsencrypt</p><p>Stores TLS/SSL certificates managed by Traefik.</p><p>./local-files</p><p>Bind</p><p>/files</p><p>A shared folder between host and n8n. Useful for importing/exporting files inside workflows.</p><p>We use <strong>external volumes</strong> (named Docker volumes) instead of internal container storage so that:</p><ul><li>Data <strong>survives container recreation</strong> (upgrades, restarts, rebuilds).</li><li>You can <strong>backup and restore volumes</strong> independently of the running containers.</li><li>Multiple script runs won’t accidentally wipe your database or certificates.</li></ul><p><strong>What about ./local-files (bind mount)?</strong></p><p>This maps a folder from the <strong>host server filesystem</strong> into the container to <a href="https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.readwritefile/">let workflows read/write files</a> at /files inside n8n, while actually persisting them on the host at ./local-files.</p><h3>Step 5: Verify the installation</h3><ul><li>Visit: <a href="https://n8n.yourdomain.com/">https://n8n.yourdomain.com</a></li><li>Confirm SSL is active (green padlock in the browser).</li></ul><p>🎉 Congratulations-you now have a <strong>production-ready n8n instance</strong> running on Ubuntu with Docker!</p><h3>Step 6: First-Time Setup &amp; License Activation</h3><p>Now, open your browser and visit your n8n instance at the domain or hostname you configured (e.g <a href="https://n8n.nextgrowth.ai)./">https://n8n.nextgrowth.ai).</a> You’ll be greeted with the <strong>n8n owner account setup page</strong>, where you can create your admin account with secure credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/0*lKlVBd0eH89ZHvdp.png" /></figure><p>After creating your owner account, n8n will show a short onboarding form to help tailor the experience. This step is optional and only helps n8n understand its users better. Once you’ve filled it out, click <strong>Get started</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*4K1aTu6GueYj1IIx.png" /></figure><p>Next, you’ll see a page offering a <strong>free license key</strong> for some advanced features:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/0*CbM3cmehdC_9_Dbp.png" /></figure><p>To activate, simply enter your email and click <strong>Send me a free license key</strong>. You’ll receive a key by email that unlocks these features permanently.</p><p>After submitting your email, you’ll receive an email from n8n containing your <strong>license key</strong>.</p><p>To activate:</p><ol><li>Copy the license key from the email.</li><li>In your n8n dashboard, go to <strong>Settings → Usage → Plan</strong>.</li><li>Paste the key into the activation field.</li></ol><p>Your advanced features will now be permanently unlocked for your instance.</p><h3>How to Upgrade n8n instance</h3><p>Like any software, keeping n8n updated is critical for security, bug fixes, and new features. With Docker, upgrading is straightforward if you follow the right steps.</p><h3>How to Backup your n8n instance</h3><p>Regular backups are essential to prevent data loss and ensure business continuity. In an n8n stack, you need to back up:</p><ul><li><strong>PostgreSQL database</strong> (workflows, credentials, execution history)</li><li><strong>n8n application data</strong> (credentials encryption key, settings)</li><li><strong>SSL certificates</strong> (Let’s Encrypt files via Traefik)</li><li><strong>Configuration files</strong> (.env, docker-compose.yml)</li><li><strong>Shared directory local-files</strong></li></ul><h3>How to Restore the n8n instance</h3><p>In case of system failure or migration, you can restore your n8n stack from backups.</p><p>⚠️ <strong>Best Practices</strong></p><ul><li>Automate backups (cron + script) for daily or weekly snapshots.</li><li>Test restores periodically to verify data integrity.</li><li>Keep multiple versions (30-day rolling window recommended).</li><li>Store copies in secure, redundant locations.</li></ul><h3>Frequently Asked Questions (FAQs)</h3><p><strong>What’s the best way to install n8n on Ubuntu for production?</strong></p><p>The recommended method is Docker Compose. This isolates n8n and its dependencies (like PostgreSQL) in containers, making upgrades, scaling, and backups much easier. With Docker Compose, you can also define environment variables, persistent storage, and restart policies-ensuring your n8n instance is robust and production-ready.</p><p><strong>How do I secure my n8n instance on Ubuntu with HTTPS?</strong></p><p>Use a reverse proxy (Traefik recommended, though Nginx or Caddy also work). Pair it with Let’s Encrypt for free SSL certificates. This ensures all traffic between users and your automation platform is encrypted. Also:</p><ul><li>Set strong credentials.</li><li>Restrict access to the admin interface.</li><li>Keep your containers updated to patch vulnerabilities.</li></ul><p><strong>Do I need a separate database for n8n on Ubuntu?</strong></p><p>Yes-PostgreSQL is strongly recommended for production. Unlike SQLite (default), PostgreSQL ensures:</p><ul><li>Better persistence and reliability.</li><li>Support for scaling and queue mode.</li><li>Safer backups and easier migrations.</li></ul><p><strong>What common mistakes should I avoid when self-hosting n8n?</strong></p><ul><li>Using SQLite in production</li><li>Skipping reliable backup strategies</li><li>Lacking error monitoring</li><li>Over-relying on third-party AIs or automated advice. These errors can lead to data loss, downtime, or costly failures.</li></ul><p><strong>Why might webhooks fail in a self-hosted setup?</strong></p><p>If n8n doesn’t know its public address (missing WEBHOOK_URL), it can generate incorrect local URLs like localhost:5678 that external services can’t reach. Make sure this variable matches your external domain.</p><p><strong>How do I recover if the server goes down or I lose data?</strong></p><p>You’ll need to rely on your backup strategy: PostgreSQL dumps, backups of volumes, SSL certs, .env, and Compose files. These let you restore quickly. Without backups, you risk permanent data loss and prolonged downtime.</p><p>Self-hosting <strong>n8n</strong> on Ubuntu with Docker, PostgreSQL, and Traefik gives you full control over your automation platform. You’ve learned how to:</p><ul><li>Install a production-ready stack with HTTPS.</li><li>Safely upgrade n8n without losing workflows.</li><li>Back up and restore your system to protect against failures.</li><li>Troubleshoot common issues and follow best practices.</li></ul><p>With this setup, your automation platform is <strong>secure, flexible, and future-proof</strong>.</p><p>But let’s be honest-managing servers, SSL, databases, and backups isn’t everyone’s favorite task. If you’d rather focus on building workflows instead of wrestling with infrastructure, I can help.</p><h3>Professional n8n Deployment &amp; Support</h3><p>I offer a <strong>done-for-you n8n setup and ongoing support service</strong>, so you get the benefits of self-hosting without the headaches.</p><p>Here’s what I provide:</p><ul><li>✅ <strong>Deploy and run n8n</strong> on your personal VPS.</li><li>✅ <strong>Set up PostgreSQL database</strong> with secure configuration.</li><li>✅ <strong>Add firewall rules</strong> to protect your server.</li><li>✅ <strong>Automated daily backups</strong> directly on your VPS.</li><li>✅ <strong>Auto-upload backups to Google Drive</strong> for safe offsite storage.</li><li>✅ <strong>Step-by-step guides</strong> on how to upgrade, back up, or restore on your own.</li><li>✅ <strong>Ongoing support</strong> if you hit issues after deployment.</li></ul><p>💡 <em>Think of it as having your own “n8n DevOps partner” — I handle the heavy lifting so you can focus on building powerful automations.</em></p><p><strong>Contact me via this form:</strong></p><p>Please enable JavaScript in your browser to submit the form</p><p><em>Originally published at </em><a href="https://nextgrowth.ai/self-host-n8n-automation-ubuntu-docker/"><em>https://nextgrowth.ai</em></a><em> on August 24, 2025.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df5ab135b17c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>