
September 11, 2026
11 min read
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.
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
- Copy the Compose file to the server under
/opt/n8n/. - Create
.envwith strong passwords and the encryption key. - Run
docker compose up -dfrom that directory. - Point Nginx or Apache at
127.0.0.1:5678with TLS via Certbot. - Open the editor, create the owner account, and disable public signup.
- 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.
| Criteria | n8n self-hosted | Zapier / Make SaaS | Laravel queues + jobs |
|---|---|---|---|
| Hosting | Your VPS or cloud | Vendor cloud | Same app server |
| Cost model | Server + ops time | Per-task pricing | Developer time |
| Visual editing | Yes | Yes | No (code only) |
| Data residency | Full control | Vendor region | Full control |
| Complex branching | Good with IF/Switch nodes | Good | Excellent in PHP |
| Version control | Export JSON to Git | Limited | Native Git |
| Best fit | Cross-app glue, ops | Non-dev teams | Core 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.
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.1only; 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=trueonly 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.
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.
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
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.

