Kokil Thapa - Professional Web Developer in Nepal
Freelancer Web Developer in Nepal with 15+ Years of Experience

Kokil Thapa is an experienced full-stack web developer focused on building fast, secure, and scalable web applications. He helps businesses and individuals create SEO-friendly, user-focused digital platforms designed for long-term growth.

n8n: Self-Hosted Workflow Automation

By Kokil Thapa | Last reviewed: September 2026

n8n: Self-Hosted Workflow Automation gives you a visual node editor on infrastructure you control. You connect apps, APIs, databases, and webhooks without paying per task on a SaaS meter. That matters when you run AI integration and automation beside Laravel apps, WooCommerce stores, or legal-tech portals that must keep data in-country. This guide covers install, security, scaling, and real patterns I use on production systems—aligned with the same self-hosting mindset as build automation fundamentals.

What is n8n self-hosted workflow automation?

n8n is a fair-code workflow automation platform. You draw flows as connected nodes: a trigger starts the run, each node transforms or routes data, and the last node completes the job. Self-hosting means you run the n8n process, PostgreSQL or SQLite database, and optional Redis queue on your VPS or private cloud.

SaaS tools like Zapier charge by task volume. n8n Community Edition on your server removes that meter. You pay for compute, storage, and your time to maintain the stack. For a Kathmandu agency shipping web applications in Nepal, that trade-off often wins once monthly task counts climb past a few thousand.

n8n Self-Hosted ArchitectureTriggerWebhook / Cronn8n CoreEditor + EngineActionsHTTP / DB / EmailPostgreSQLWorkflows + credsRedis QueueScale workersReverse ProxyTLS + AuthExternal TargetsLaravel API · Khalti · Slack · MySQL · S3
n8n self-hosted workflow automation stack: triggers flow through the engine to actions, backed by PostgreSQL and optional Redis workers.

Core concepts map cleanly to backend work you already do:

  • Workflows — saved graphs of nodes with version history.
  • Executions — individual runs with input/output JSON you can inspect.
  • Credentials — encrypted API keys stored in the n8n database.
  • Expressions — JavaScript snippets inside nodes to map fields.
  • Sub-workflows — reusable modules called from parent flows.

The official docs at docs.n8n.io remain the source of truth for node parameters and environment variables. Treat community forum recipes as starting points, not production specs.

How do you install n8n on your own server?

Docker Compose is the fastest path on Ubuntu 22 or 24. You already manage PHP-FPM and MySQL on client boxes; adding a Compose stack fits the same Linux server administration workflow. Pin images by digest in production rather than floating latest tags.

Minimal Docker Compose stack

Create /opt/n8n/docker-compose.yml with PostgreSQL for persistence. SQLite works for a laptop demo but fails under concurrent writes on a busy server.

services:
  postgres:
    image: postgres:18
    restart: unless-stopped
    environment:
      POSTGRES_USER: n8n
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: n8n
    volumes:
      - n8n_postgres:/var/lib/postgresql/data

  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: unless-stopped
    ports:
      - "127.0.0.1:5678:5678"
    environment:
      DB_TYPE: postgresdb
      DB_POSTGRESDB_HOST: postgres
      DB_POSTGRESDB_DATABASE: n8n
      DB_POSTGRESDB_USER: n8n
      DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}
      N8N_HOST: automation.example.com
      N8N_PROTOCOL: https
      WEBHOOK_URL: https://automation.example.com/
      GENERIC_TIMEZONE: Asia/Kathmandu
      N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
    volumes:
      - n8n_data:/home/node/.n8n
    depends_on:
      - postgres

volumes:
  n8n_postgres:
  n8n_data:

Generate a 32-character encryption key once. Store it in a password manager. Losing it makes saved credentials unreadable forever.

Bring the stack online

  1. Copy the Compose file to the server under /opt/n8n/.
  2. Create .env with strong passwords and the encryption key.
  3. Run docker compose up -d from that directory.
  4. Point Nginx or Apache at 127.0.0.1:5678 with TLS via Certbot.
  5. Open the editor, create the owner account, and disable public signup.
  6. Build a test workflow: Cron → HTTP Request → respond with static JSON.

Full install options—including Kubernetes and bare Node—are documented at n8n Docker installation. Mirror the same backup discipline you use for self-hosted object storage: nightly database dumps plus volume snapshots.

How does n8n compare to Zapier, Make, and custom code?

Pick the tool by data residency, task volume, and who maintains it. A founder with ten zaps should stay on SaaS. A team running thousands of webhook-driven jobs per day should self-host or write Laravel queues.

Criterian8n self-hostedZapier / Make SaaSLaravel queues + jobs
HostingYour VPS or cloudVendor cloudSame app server
Cost modelServer + ops timePer-task pricingDeveloper time
Visual editingYesYesNo (code only)
Data residencyFull controlVendor regionFull control
Complex branchingGood with IF/Switch nodesGoodExcellent in PHP
Version controlExport JSON to GitLimitedNative Git
Best fitCross-app glue, opsNon-dev teamsCore business logic

My rule on client projects: keep money-moving logic in Laravel with tests. Use n8n for integrations, alerts, and staff-facing glue. That split mirrors how I treat REST API development versus ad-hoc scripts.

Where Should Automation Live?New automation needMoney / orders?Payments, refundsCross-app glue?Slack, CRM, sheetsLow volume?Under 500 tasksLaravel JobsTested PHP logicn8n Self-HostedVisual workflowsZapier SaaSFast setup
Decision guide for n8n self-hosted workflow automation versus Laravel jobs or SaaS integrators.

How do you secure a self-hosted n8n instance?

An exposed n8n editor is a remote-code execution surface. Attackers who gain login access can run HTTP nodes against your internal network. Treat it like production infrastructure, not a side project.

Network and authentication hardening

  • Bind the container to 127.0.0.1 only; never publish port 5678 publicly.
  • Terminate TLS at Nginx with modern cipher suites and HSTS.
  • Put the UI behind VPN, SSO, or at minimum HTTP basic auth at the proxy.
  • Set N8N_BASIC_AUTH_ACTIVE=true only as a secondary layer, not the sole gate.
  • Disable user self-registration immediately after creating the owner account.
  • Restrict outbound traffic if you run n8n beside private APIs.

Webhook URLs must use the public WEBHOOK_URL value. A mismatch produces signed URLs that fail silently in payment callbacks. I have debugged Khalti and eSewa issues caused by exactly this class of config drift.

Secrets, backups, and updates

Store N8N_ENCRYPTION_KEY outside Git. Rotate API credentials in n8n when staff leave. Export workflows to JSON in a private Git repo for change tracking—similar to how teams version self-hosted CI runner configs.

Schedule pg_dump nightly. Test restores quarterly. Patch the n8n image on a fixed cadence; read release notes before upgrading because node schemas do change.

What are practical n8n workflows for Laravel and eCommerce?

On a booking platform like Adventure Third Pole Trek, n8n excels at notifications and sync jobs that would clutter controllers. On Notary Nepal-style legal portals, it can route lead forms to Slack and CRM without embedding vendor SDKs in Blade templates.

Pattern 1: Laravel webhook to multi-channel alert

Fire a signed POST from a Laravel event listener when a form submits. n8n validates the HMAC header, branches on service type, and posts to Slack plus email.

// Laravel: dispatch after NotaryRequestCreated event
Http::withHeaders([
    'X-N8N-Signature' => hash_hmac('sha256', $payload, config('services.n8n.secret')),
])->post(config('services.n8n.webhook'), [
    'reference' => $request->reference,
    'service'   => $request->service_slug,
    'phone'     => $request->phone,
]);

Debug payloads with a JSON formatter before mapping fields in the n8n expression editor. Off-by-one key names waste hours.

Pattern 2: Scheduled report from MySQL

A Cron trigger runs daily at 06:00 Asia/Kathmandu. A MySQL node selects yesterday's orders. A Spreadsheet or email node delivers the CSV to operations staff. Keep heavy aggregation in SQL; let n8n handle delivery only.

Pattern 3: Payment gateway callback fan-out

Point Khalti or Stripe webhooks at n8n for staging environments. Forward sanitized events to a Laravel /api/webhooks/relay endpoint. Production should hit Laravel directly; n8n is a convenience layer, not a choke point.

For WooCommerce and custom carts built through e-commerce development, n8n can sync inventory to Google Sheets or trigger SMS gateways when stock drops. Do not replace WooCommerce webhooks for order state—those belong in PHP with idempotent handlers.

Laravel → n8n Lead FlowForm SubmitBlade + LivewireLaravelEvent + HMACn8n WebhookValidate + routeSlackOps channelEmail SMTPStaff inboxGoogle SheetLead logError branch → retry queue → PagerDuty or SMSFailed executions visible in n8n execution log
Typical n8n self-hosted workflow automation path from a Laravel form event to Slack, email, and spreadsheet targets.

How do you run n8n in production with queue mode and monitoring?

Single-container n8n handles moderate load. Once executions queue up during cron collisions, enable queue mode with Redis 8.10 and separate worker containers. The pattern parallels workflow orchestration at scale, but with a lighter ops footprint.

Queue mode essentials

Add Redis and set execution mode variables on both main and worker services:

environment:
  EXECUTIONS_MODE: queue
  QUEUE_BULL_REDIS_HOST: redis
  N8N_CONCURRENCY_PRODUCTION_LIMIT: 10

Run one n8n worker container per CPU core you allocate. Watch Redis memory. Stalled jobs usually mean workers crashed or database connections exhausted.

Observability and cost

Enable execution pruning so the PostgreSQL database does not grow without bound. Ship logs to your existing stack—journald, Loki, or a plain log file watched by fail2ban rules.

On a Rs 2,500/month VPS (~USD 19), you can run n8n, PostgreSQL, and Redis alongside a small Laravel app if traffic stays modest. Dedicated automation servers make sense above roughly five thousand executions daily. Compare that to SaaS tiers that charge per task above free limits.

Pair n8n with Laravel Envoy deploy hooks: Envoy handles symlink releases; n8n posts deploy summaries to Slack. Each tool stays in its lane.

n8n Queue Mode Productionn8n MainEditor + APIRedis 8.10Job queueWorkers x3Parallel runsPostgreSQL 18 — execution history + credentialsNightly pg_dumpOff-site backupImage updatesMonthly patch windowExecution pruneKeep 30 days
Production n8n self-hosted workflow automation with Redis queue workers, PostgreSQL persistence, and backup discipline.

For teams already running private Docker registries, pull the n8n image through the same mirror you use for app containers—documented in our self-hosted Docker registry guide. Store Compose files in GitLab CI alongside application pipelines.

When business rules grow past visual flows—multi-step refunds, chargeback windows, VAT calculations—move logic into Laravel 13.x services with PHPUnit coverage. n8n should notify; your app should decide. That boundary keeps custom software maintainable for the next developer.

Related reading: Python for DevOps automation, AI automation tools in 2026, and Court Marriage In Nepal for a live legal-tech stack that benefits from webhook-driven lead routing. Ongoing ops fit under support and maintenance when you want someone else to patch and monitor the box.

Key Takeaways

  • Self-host n8n with PostgreSQL and a fixed N8N_ENCRYPTION_KEY; SQLite is for demos only.
  • Never expose port 5678 publicly—terminate TLS at Nginx and restrict editor access.
  • Keep payment and order state in Laravel; use n8n for cross-app glue and alerts.
  • Enable Redis queue mode before cron-heavy workflows start colliding.
  • Export workflows to Git and backup PostgreSQL nightly with tested restores.
  • Match tooling to volume: SaaS for low task counts, n8n for controlled high-volume glue.

People Also Ask

Is n8n free to self-host?

The Community Edition is free to self-host under the Sustainable Use License. You pay for server resources and your time to maintain updates, backups, and security. Enterprise features such as SSO and advanced role controls require a paid license from n8n GmbH.

Can n8n replace Laravel queues?

No for core application logic. Laravel queues with Redis remain the right place for order processing, email receipts, and PDF generation tied to your domain models. n8n complements queues by connecting external SaaS tools and staff notification channels without deploying new PHP code for every integration.

What server specs do you need for n8n?

Start with two vCPUs, 4 GB RAM, and 40 GB SSD on Ubuntu 24. That comfortably runs n8n, PostgreSQL, and Redis for small teams. Add worker containers and RAM when daily executions exceed a few thousand or when individual workflows call slow third-party APIs.

How do you migrate from Zapier to n8n?

Rebuild flows one at a time in n8n rather than bulk importing. Map each Zap to a workflow, recreate credentials, and run both systems in parallel during a one-week overlap. Switch webhook endpoints in Laravel env files only after execution logs show matching output.

Ship automation you control

n8n: Self-Hosted Workflow Automation earns its place when task volume, data residency, or cross-app wiring outgrows SaaS pricing. Install it once with Docker, harden the proxy, and draw a bright line between glue workflows and business logic in your Laravel codebase. If you want the stack designed, secured, and monitored on your infrastructure, contact us for a scoped automation plan—or browse the AI integration and automation service for full delivery.

Frequently Asked Questions

Running the n8n editor and execution engine on infrastructure you control—typically Docker on a VPS—so triggers, node graphs, credentials, and webhooks live on your domain without per-run SaaS billing.

Community Edition is free under the Sustainable Use License. You pay server resources and maintenance time. Enterprise SSO and advanced role controls need a paid n8n GmbH license.

Docker Compose on Ubuntu 22 or 24 is the fastest path. Create /opt/n8n/docker-compose.yml with PostgreSQL 18 for persistence, a .env holding strong passwords and a 32-character N8N_ENCRYPTION_KEY, then run docker compose up -d. Bind port 5678 to 127.0.0.1 only, terminate TLS at Nginx or Apache with Certbot, set N8N_HOST, N8N_PROTOCOL, WEBHOOK_URL, and GENERIC_TIMEZONE to Asia/Kathmandu. Pin images by digest in production, create the owner account, disable public signup, and test with a Cron to HTTP Request workflow before going live.

SQLite suits laptop demos but fails under concurrent writes on a busy server. PostgreSQL 18 handles multiple simultaneous executions, queue workers, and growing execution history reliably. Treat SQLite as a proof-of-concept only. Mirror the same backup discipline you apply elsewhere: nightly pg_dump exports plus volume snapshots, with quarterly restore tests so credential encryption and workflow history survive hardware failure.

It is a 32-character key n8n uses to encrypt stored API credentials in the database. Generate it once, store it in a password manager, and never commit it to Git. Losing the key makes saved credentials unreadable forever—there is no recovery path. Set it in your .env before first boot alongside POSTGRES_PASSWORD. Rotating staff API keys inside n8n when people leave is separate; the encryption key itself should remain stable unless you are prepared to re-enter every integration credential.

Pick by data residency, task volume, and who maintains the stack. Zapier and Make suit non-developers with low task counts and charge per task. n8n self-hosted gives visual editing, full data control, and JSON workflow exports to Git—ideal for cross-app glue at higher volume. Laravel queues excel at core business logic with native version control and PHPUnit tests. My rule on client projects: keep money-moving logic in Laravel; use n8n for integrations, alerts, and staff-facing glue that would otherwise require deploying new PHP for every vendor SDK.

No for core application logic. Laravel queues with Redis remain correct for order processing, receipts, and PDF generation tied to domain models. n8n complements queues by wiring external SaaS tools and notification channels without new PHP deployments per integration.

Community Edition software is free; expect roughly Rs 2,500/month (~USD 19) for a modest VPS running n8n, PostgreSQL, and Redis beside a small Laravel app. Dedicated automation servers make sense above roughly five thousand daily executions.

Start with two vCPUs, 4 GB RAM, and 40 GB SSD on Ubuntu 24 running n8n, PostgreSQL, and Redis for small teams. Single-container mode handles moderate load comfortably. Add worker containers and RAM when daily executions exceed a few thousand or workflows call slow third-party APIs. Enable Redis queue mode before cron-heavy jobs start colliding. Execution pruning prevents PostgreSQL from growing without bound. Ship logs to journald, Loki, or watched log files so stalled jobs and worker crashes surface before staff notice missing alerts.

An exposed n8n editor is effectively remote-code execution—HTTP nodes can reach your internal network. Bind the container to 127.0.0.1, never publish 5678 publicly, terminate TLS at Nginx with HSTS, and put the UI behind VPN, SSO, or at minimum proxy-level HTTP basic auth. Disable self-registration after creating the owner account. N8N_BASIC_AUTH_ACTIVE is a secondary layer only. Restrict outbound traffic beside private APIs. Store N8N_ENCRYPTION_KEY outside Git, export workflows to a private repo, schedule pg_dump nightly, and patch the n8n image on a fixed cadence after reading release notes.

Webhook URLs must match the public WEBHOOK_URL value you set in environment variables. A mismatch produces signed callback URLs that fail silently—payment gateways like Khalti and eSewa will appear to fire but Laravel or n8n downstream nodes never receive valid payloads. I have debugged production payment issues caused by exactly this config drift between staging and production domains. Set N8N_HOST, N8N_PROTOCOL, and WEBHOOK_URL together during install and re-verify after any domain or reverse-proxy change.

Single-container n8n handles moderate load until cron collisions queue executions. Add Redis 8.10, set EXECUTIONS_MODE to queue and QUEUE_BULL_REDIS_HOST to redis on both main and worker services, and set N8N_CONCURRENCY_PRODUCTION_LIMIT—for example 10. Run one worker container per allocated CPU core. Watch Redis memory; stalled jobs usually mean workers crashed or PostgreSQL connections exhausted. Enable execution pruning so the database does not grow without bound. On modest VPS hardware you can co-host n8n with a small Laravel app; split to a dedicated box when volume climbs past roughly five thousand daily executions.

On booking platforms and legal-tech portals, n8n excels at notifications and sync jobs that would clutter controllers. Pattern one: Laravel fires a signed HMAC POST from an event listener; n8n validates the header and branches to Slack plus email. Pattern two: a Cron trigger at 06:00 Asia/Kathmandu queries MySQL for yesterday's orders and emails a CSV—keep aggregation in SQL, delivery in n8n. Pattern three: point Khalti or Stripe webhooks at n8n in staging and forward sanitized events to Laravel. For WooCommerce, sync inventory to Google Sheets or trigger SMS on low stock—do not replace WooCommerce order-state webhooks; those belong in PHP with idempotent handlers.

Production payment callbacks should hit Laravel directly with idempotent handlers tested in PHPUnit. n8n is a convenience layer for staging environments—forward sanitized Khalti, Stripe, or eSewa events to a Laravel relay endpoint while testing integrations. Making n8n a production choke point adds latency, another failure surface, and config drift risk around WEBHOOK_URL signing. Keep n8n for alert fan-out and cross-app glue; keep order state and money-moving logic inside Laravel 13.x services where domain models, transactions, and audit trails live.

Rebuild flows one at a time rather than bulk importing. Map each Zap to an n8n workflow, recreate credentials manually, and run both systems in parallel for about one week. Compare execution logs node by node—off-by-one JSON key names waste hours, so use a formatter node to inspect payloads before mapping expressions. Switch webhook endpoints in Laravel .env files only after n8n logs show matching output to the old Zap. Export finished workflows to JSON in a private Git repo so future changes are tracked the same way you version CI configs on self-hosted infrastructure.

Share this article

0 Comments

Leave a comment

Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

Quick Contact Options
Choose how you want to connect me: