Some links may be affiliate links. We may earn a commission at no extra cost to you. Learn more
Open Source

Self-hosted n8n

Own Your Automation. Zero Per-Task Fees.

n8n is the open-source workflow automation platform with 400+ integrations, visual editor, and full code flexibility. Self-host it for free on a $5.50/mo VPS and run unlimited workflows without per-task pricing. This comprehensive guide covers everything from Docker setup to AI-powered workflows.

What is Self-hosted n8n?

n8n is a powerful, open-source workflow automation platform that allows you to connect different services and automate repetitive tasks without extensive coding. When self-hosted, n8n runs on your own server infrastructure, giving you complete control over your data, unlimited workflow executions, and significant cost savings compared to cloud-based alternatives.

Self-hosted vs Cloud n8n vs Competitors

Feature Self-hosted n8n n8n Cloud Zapier Make
Cost (10K ops/month) $5-$20 (server only) ~$50 $500+ $90-$180
Data Control Complete Limited Limited Limited
Execution Limits Unlimited Plan-based Task-based pricing Operation-based pricing
Custom Code Full JS/Python Full JS/Python Limited Limited
Setup Complexity Medium (~4 hours) Low (minutes) Low Low
AI Integration LangChain native LangChain native Basic AI actions AI modules

Open-Source Advantages

Cost Efficiency

Pay only for server infrastructure ($4-$20/month) instead of per-task pricing that can reach $1,500/month for high-volume automation.

Data Privacy

All workflow data remains on your servers, crucial for sensitive business information and GDPR compliance.

Customization

Full access to source code allows custom modifications, integrations, and fine-tuned behavior for your needs.

No Vendor Lock-in

Your workflows and data are portable across different hosting environments. Move anywhere, anytime.

Community Support

Active open-source community with 1,000+ integrations and thousands of workflow templates shared freely.

Scalability

Scale horizontally with queue workers and multiple instances as your automation needs grow.

Getting Started with Self-hosted n8n

VPS Requirements

Choose a VPS plan based on your expected workload. We recommend Contabo VPS for the best price-to-performance ratio.

Use Case CPU/vCPU RAM Storage Notes
Basic/Testing 1 vCPU 1-2 GB 10-20 GB SSD Simple workflows, low volume
Production (Recommended) 2 vCPUs 2-4 GB 20-30 GB NVMe Moderate complexity workflows
High-Volume/Enterprise 4-8 vCPUs 8-24 GB 50-200 GB NVMe Heavy loads, large data processing
Recommended: Contabo Cloud VPS starting at $5.50/mo gives you 4 vCPU and 8GB RAM -- more than enough for production n8n workloads.

Docker Compose Setup

Create a project directory and the required folder structure:

Terminal
mkdir ~/n8n && cd ~/n8n
mkdir n8n_data db_data caddy

Create docker-compose.yml with PostgreSQL, Redis, n8n, and Caddy for automatic SSL:

docker-compose.yml
version: '3.8'

services:
  postgres:
    image: postgres:16
    restart: always
    environment:
      POSTGRES_DB: n8n
      POSTGRES_PASSWORD: your_secure_db_password
      POSTGRES_USER: n8n
      POSTGRES_NON_ROOT_USER: n8n
      POSTGRES_NON_ROOT_PASSWORD: your_secure_db_password
    volumes:
      - db_data:/var/lib/postgresql/data
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -h localhost -U n8n -d n8n']
      interval: 5s
      timeout: 5s
      retries: 10

  redis:
    image: redis:7-alpine
    restart: always
    healthcheck:
      test: ['CMD-SHELL', 'redis-cli ping || exit 1']
      interval: 5s
      timeout: 3s
      retries: 5

  n8n:
    image: docker.n8n.io/n8nio/n8n:latest
    restart: always
    environment:
      # Database Configuration
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=n8n
      - DB_POSTGRESDB_USER=n8n
      - DB_POSTGRESDB_PASSWORD=your_secure_db_password

      # Basic Configuration
      - N8N_HOST=your-domain.com
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://your-domain.com/
      - GENERIC_TIMEZONE=UTC

      # Security
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=your_secure_admin_password
      - N8N_SECURE_COOKIE=true

      # Performance
      - EXECUTIONS_PROCESS=main
      - N8N_ENCRYPTION_KEY=your_32_char_encryption_key_here
    volumes:
      - n8n_data:/home/node/.n8n
    ports:
      - "127.0.0.1:5678:5678"
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
    healthcheck:
      test: ['CMD-SHELL', 'wget --no-verbose --tries=1 --spider http://localhost:5678/healthz || exit 1']
      interval: 5s
      timeout: 5s
      retries: 3

  caddy:
    image: caddy:alpine
    restart: always
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./caddy/Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
    depends_on:
      - n8n

volumes:
  n8n_data:
  db_data:
  caddy_data:

Caddyfile for Automatic HTTPS

Create caddy/Caddyfile to handle SSL certificates automatically:

caddy/Caddyfile
your-domain.com {
    reverse_proxy n8n:5678
    encode gzip
    header {
        Referrer-Policy no-referrer-when-downgrade
    }
}

Key Environment Variables

WEBHOOK_URL Critical for external webhooks; must be your public domain with HTTPS
N8N_ENCRYPTION_KEY 32-character key for encrypting stored credentials -- generate one securely
DB_TYPE Use PostgreSQL for production instead of default SQLite for reliability
GENERIC_TIMEZONE Set to your local timezone for accurate scheduled workflow triggers
N8N_BASIC_AUTH_* Enable authentication to protect your n8n instance from unauthorized access

First Workflow Walkthrough

1

Start the Stack

Launch all services with Docker Compose:

docker compose up -d
docker compose logs -f n8n
2

Access n8n

Navigate to https://your-domain.com and log in with your configured credentials. Create your owner account on first visit.

3

Create Your First Workflow

Click "Add Workflow", add a Schedule Trigger node, connect an HTTP Request node to fetch API data, then save results to Google Sheets. Click "Execute Workflow" to test.

4

Update & Maintain

Keep n8n updated with simple commands:

docker compose pull
docker compose down
docker compose up -d

Cost Comparison Analysis

See exactly how much you save by self-hosting n8n versus cloud alternatives

Detailed Cost Breakdown by Volume

Monthly Operations n8n Self-Hosted n8n Cloud Zapier Make
1,000 ops $5-$20 $20-$22 $20-$30 $90-$180
10,000 ops $5-$20 $50 $500+ $90-$180
50,000 ops $5-$20 $200+ $1,200-$1,500 $400-$600
100,000 ops $5-$20 $400+ $2,000+ $800-$1,200

Pricing Model Differences

n8n Self-hosted

Charges per workflow execution (one complete run regardless of steps). Free Community Edition with unlimited usage. You only pay for your server.

n8n Cloud

Same execution model but hosted. Starting at $20/month for ~2,500 executions. Convenient but more expensive at scale.

Zapier

Charges per task (each action step processing one data item). A 5-step workflow uses 5 tasks. Free tier: 100 tasks/month only.

Make (Integromat)

Charges per operation (similar to Zapier tasks). Better mid-range value than Zapier but still per-operation pricing. Try Make free →

Break-even Analysis

When does self-hosting pay off?
  • 200-500 executions/month -- beats n8n Cloud pricing
  • 1,000-2,000 operations/month -- beats Zapier Professional
  • 5,000+ operations/month -- significant savings over all alternatives

Annual Savings Examples

Small Business

5K ops/month

Self-hosted $60-$240/yr
Zapier $3,600/yr
Save $3,360+/yr

Medium Business

25K ops/month

Self-hosted $60-$240/yr
Zapier $12,000+/yr
Save $11,760+/yr

Enterprise

100K ops/month

Self-hosted $60-$240/yr
Zapier $24,000+/yr
Save $23,760+/yr
Recommendation: Self-hosted n8n wins for businesses with over 10,000 executions/month or complex workflows requiring custom code. The break-even point is typically 6-12 months for medium to high-volume users.
Prefer a managed solution? Make (formerly Integromat) offers a powerful visual automation platform with 1,500+ integrations. Great for teams that want no-code automation without server management. Try Make free →

Popular Workflow Templates

n8n offers thousands of community-contributed templates through the official Creator Hub. Here are the 10 most popular business automation workflows.

1. Lead Generation & Enrichment

Automatically processes leads from multiple sources, enriches contact data, and creates personalized outreach campaigns.

Google Sheets Apollo.io Enrich OpenAI GPT-4 Gmail Send

2. Social Media Distribution

Monitors GitHub commits and automatically posts updates across multiple social platforms with AI-generated content.

GitHub Webhook GPT-4 Copy Twitter + LinkedIn + Discord

3. E-commerce Fulfillment

Integrates Shopify/WooCommerce with shipping providers and inventory management systems automatically.

Shopify Order If: Product Type ShipStation Slack Notify

4. Customer Support Automation

Auto-responds to customer inquiries from email, WhatsApp, and contact forms with AI-powered contextual responses. Average response time under 15 seconds.

Sentiment Analysis Auto-categorization Escalation Rules

5. CRM Data Synchronization

Keeps customer data synchronized across multiple CRM systems and marketing platforms in real-time.

HubSpot Salesforce Mailchimp Airtable

6. AI Document Processing

Uses OCR and AI to extract structured data from documents and invoices, storing results in vector databases.

Google Drive OCR OpenAI GPT-4 Pinecone

7. DevOps Automation

Automates development workflows including auto PR creation, JIRA ticket updates from commit messages, and multi-repo support.

Auto PR Creation JIRA Integration Multi-repo

8. Financial Data Processing

Automates invoice processing, expense tracking with receipt parsing, and weekly financial report generation across accounting systems.

QuickBooks Invoice PDFs Expense Tracking

9. Content Creation Pipeline

AI-powered video and content generation with automatic distribution to YouTube, social media, and blog platforms.

Schedule AI Generate GPT-4o Title YouTube + Social

10. Monitoring & Alerting

Comprehensive system monitoring with multi-channel alerting for website uptime, server metrics (CPU, memory, disk), and business KPIs.

Uptime Monitoring Server Metrics KPI Tracking

Template Categories & Counts

Category Template Count Most Popular Use Cases
AI/Machine Learning 5,850 Content generation, data analysis, chatbots
Marketing 2,661 Lead nurturing, email campaigns, social media
Content Creation 1,348 Blog posting, video creation, SEO optimization
Sales/CRM 800+ Lead qualification, pipeline management, reporting

Integrations (400+)

n8n supports over 1,200 integrations through pre-built nodes, HTTP requests for REST APIs, and community-contributed connectors. Connect to virtually any service with an API.

Integration Categories

Category Node Count Popular Examples
CRM & Sales 45+ HubSpot, Salesforce, Pipedrive, Zoho CRM
Marketing 60+ Mailchimp, SendGrid, Klaviyo, Facebook Ads
Development 35+ GitHub, GitLab, Jira, Jenkins
Data & Analytics 40+ Google Sheets, Airtable, MySQL, PostgreSQL
Communication 50+ Slack, Discord, Telegram, WhatsApp
Productivity 55+ Google Workspace, Microsoft 365, Notion
E-commerce 25+ Shopify, WooCommerce, Stripe, PayPal

Top 20 Most Popular Integrations

1 Google Sheets
2 Slack
3 Gmail
4 Webhook
5 HTTP Request
6 Airtable
7 Google Drive
8 OpenAI
9 Notion
10 Discord
11 Telegram
12 HubSpot
13 GitHub
14 ClickUp
15 Stripe
16 Calendly
17 Mailchimp
18 Salesforce
19 Jira
20 MySQL/PostgreSQL

Custom HTTP Integrations

For services without dedicated nodes, use the HTTP Request node to connect to any REST API:

HTTP Request Node Configuration
# HTTP Request Node Setup:
Method: POST / GET / PUT / DELETE
URL: https://api.example.com/endpoint
Headers:
  Authorization: Bearer {{$credentials.api_token}}
  Content-Type: application/json
Body:
  { "data": "{{$json.input_field}}" }

Authentication Methods Supported

API Key -- Simple token-based auth
OAuth 2.0 -- Secure authorization flow
Basic Auth -- Username/password
Bearer Token -- JWT and similar tokens
Custom Headers -- Proprietary auth methods

Community Nodes

Extend n8n functionality with community-contributed nodes:

Popular Community Nodes
# Install additional nodes for:
n8n-nodes-aws        # AWS services (S3, Lambda, SQS)
n8n-nodes-pushbullet # Push notifications
n8n-nodes-youtube    # YouTube management
n8n-nodes-pdf        # PDF manipulation
n8n-nodes-crypto     # Cryptocurrency data
Enterprise Integrations: n8n also supports SAP, Oracle, Microsoft Dynamics, ServiceNow, and Workday for enterprise-grade workflows.

AI & LangChain Integration

n8n provides native support for AI integrations including OpenAI, Anthropic, and LangChain, enabling sophisticated AI-powered workflows without extensive coding.

OpenAI Node Setup

1

Get API Key

Navigate to OpenAI's dashboard and create a new secret key for n8n.

2

Configure Credentials

In n8n, go to Credentials and add your OpenAI API key.

3

Add OpenAI Node

Search for "OpenAI" in the nodes panel under the "AI" section.

Available OpenAI Operations

Operation Use Case Example Configuration
Chat Completion Conversational AI, content generation System: "You are a helpful assistant"
Text Completion Content continuation, writing assistance Prompt: "Complete this article: ..."
Image Generation Visual content creation (DALL-E) Prompt + Size: 1024x1024
Transcription Audio to text (Whisper) File input, Model: whisper-1
Embeddings Vector search, semantic analysis Model: text-embedding-ada-002

LangChain Workflow Examples

n8n supports LangChain for building sophisticated AI agents and multi-step reasoning workflows:

AI Agent Workflow with LangChain
# AI Agent Workflow:
Webhook Trigger
  -> LangChain Agent Node (tools: web search, calculator)
  -> OpenAI Chat Node (GPT-4)
  -> Slack / Email Response

Vector Database Integration

Build knowledge bases and semantic search systems with n8n:

Pinecone Integration

Store document embeddings for intelligent semantic search across your knowledge base.

OCR to Vector DB

Google Drive -> OCR -> OpenAI Embeddings -> Pinecone for document intelligence.

Document Processing

Extract text, create embeddings, and enable semantic queries across all your documents.

Practical AI Agent Examples

Customer Support AI Agent

Support Bot Workflow
# Customer Support Bot:
1. Webhook - Customer Query
2. OpenAI Embeddings - Query Analysis
3. Pinecone - Search Knowledge Base
4. OpenAI Chat - Generate Response
5. If Node - Escalate if confidence < 80%
6. Slack (human agent) OR respond directly

Content Research & Generation Agent

Research Agent Workflow
# Research Agent:
Schedule Trigger -> Google Search Node ->
Web Scraping (Cheerio) -> OpenAI Analysis ->
Generate Blog Post -> WordPress Publication ->
Social Media Distribution

Multi-Agent System

Sequential AI Processing
# Multi-Agent Pipeline:
Input -> Researcher Agent (web search) ->
Analyst Agent (data processing) ->
Writer Agent (content creation) ->
Editor Agent (quality check) -> Output

AI Configuration Best Practices

Parameter Recommended Value Purpose
Temperature 0.1-0.3 (factual) / 0.7-0.9 (creative) Controls response randomness
Max Tokens 500-2000 typical Response length limit
System Message Detailed role description Sets AI behavior context
Error Handling Retry with exponential backoff Handles API rate limits
Exclusive Deal

Affiliate link. We may earn a commission at no extra cost to you.

Security & Best Practices

Essential security configurations for running n8n in production

SSL/TLS Configuration

Always use HTTPS in production. The Caddy reverse proxy in our Docker Compose setup handles SSL certificates automatically via Let's Encrypt. Never expose n8n directly on port 5678 without SSL.

# Caddy handles SSL automatically
# Just point your domain and it works
your-domain.com {
    reverse_proxy n8n:5678
}

Authentication

Enable basic authentication at minimum. For teams, use the enterprise SSO/SAML integration. Always change default credentials and use strong passwords.

# Required environment variables:
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=strong_password_here
N8N_SECURE_COOKIE=true

Backup Strategy

Regular backups are critical. Back up the PostgreSQL database and n8n data volume. Automate daily backups and test restoration regularly.

# Daily PostgreSQL backup:
docker exec postgres pg_dump -U n8n n8n \
  > backup_$(date +%Y%m%d).sql

# Backup n8n data volume:
docker run --rm -v n8n_data:/data \
  -v $(pwd):/backup alpine \
  tar czf /backup/n8n_data.tar.gz /data

Scaling for High Volume

For high-volume workloads, enable queue mode with Redis to distribute execution across multiple worker instances.

# Enable queue mode:
EXECUTIONS_MODE=queue
QUEUE_BULL_REDIS_HOST=redis
QUEUE_BULL_REDIS_PORT=6379

# Run separate worker instances:
docker compose up -d --scale n8n-worker=3
Pro Tip: Generate a secure encryption key with openssl rand -hex 16 and store it safely. If you lose this key, all saved credentials in n8n become unrecoverable.

Troubleshooting

Common issues and solutions when running self-hosted n8n

Docker container fails to start or keeps restarting

Check the container logs for specific error messages:

docker compose logs n8n
docker compose logs postgres

Common causes:

  • PostgreSQL not ready yet -- the healthcheck and depends_on conditions in our compose file handle this
  • Incorrect database credentials -- ensure POSTGRES_PASSWORD matches DB_POSTGRESDB_PASSWORD
  • Port 5678 already in use -- check with lsof -i :5678
  • Volume permission issues -- ensure the n8n data directory is writable
Out of memory errors or high CPU usage

n8n can consume significant memory with complex workflows or large data processing:

  • Increase Node.js memory limit: NODE_OPTIONS=--max-old-space-size=4096
  • Upgrade your VPS RAM -- Contabo offers affordable high-RAM plans
  • Enable queue mode to distribute load across worker processes
  • Prune old execution data: set EXECUTIONS_DATA_PRUNE=true and EXECUTIONS_DATA_MAX_AGE=168 (hours)
Webhooks not receiving data

Webhook issues are usually caused by incorrect URL configuration:

  • Ensure WEBHOOK_URL is set to your public HTTPS domain
  • Verify Caddy is correctly proxying to n8n on port 5678
  • Check that your domain DNS is pointing to your VPS IP
  • Test the webhook URL directly in your browser -- you should see a response from n8n
  • Make sure the workflow is active (toggled on) for production webhooks
Workflow debugging tips

When workflows aren't producing expected results:

  • Use the Execute Workflow button to run step-by-step and inspect output at each node
  • Add Set nodes between complex steps to inspect and transform data
  • Check the Executions tab for historical run data and error details
  • Use Error Trigger workflows to catch and log failures automatically
  • Enable verbose logging: N8N_LOG_LEVEL=debug (disable in production)
SSL certificate issues with Caddy

If Caddy fails to obtain SSL certificates:

  • Ensure ports 80 and 443 are open on your VPS firewall
  • Verify your domain A record points to the correct VPS IP address
  • Check Caddy logs: docker compose logs caddy
  • Make sure no other service is using ports 80/443 (e.g., Apache, Nginx)
  • Let's Encrypt has rate limits -- wait 1 hour if you've made too many requests
Database migration or upgrade errors

When updating n8n to a new version:

  • Always back up your database before upgrading
  • Pull the latest image: docker compose pull
  • Stop and restart: docker compose down && docker compose up -d
  • Check migration logs: docker compose logs n8n | grep -i migrat
  • If migration fails, restore from backup and check n8n release notes for breaking changes

Frequently Asked Questions

Is self-hosted n8n really free?

Yes. The self-hosted version of n8n is completely free under a fair-code license. You get unlimited workflows, unlimited executions, and unlimited users. You only pay for the VPS hosting it runs on, which can be as low as $5.50/month on Contabo.

What VPS specifications do I need for n8n?

For basic testing, 1 vCPU and 1-2 GB RAM is sufficient. For production workloads, we recommend 2 vCPUs and 2-4 GB RAM with NVMe SSD storage. High-volume enterprise deployments may need 4-8 vCPUs with 8-24 GB RAM. Contabo VPS starting at $5.50/mo provides 4 vCPU and 8GB RAM, which handles most production scenarios.

How does n8n compare to Zapier?

n8n offers unlimited executions for free (self-hosted), while Zapier charges per task starting at $19.99/month. n8n supports full code nodes (JavaScript/Python), has 400+ native integrations plus community nodes, and gives you complete data control. For 10,000 operations/month, self-hosted n8n costs $5-20 versus $500+ on Zapier.

Can I use n8n for AI workflows?

Yes. n8n has native LangChain integration for building AI agents, supports OpenAI (GPT-4, DALL-E, Whisper), Anthropic Claude, and local model hosting. You can build vector database RAG systems with Pinecone, create multi-agent workflows, and process documents with AI-powered OCR and analysis.

How do I install n8n on a VPS?

The recommended approach is Docker Compose with PostgreSQL and Caddy for SSL. Create a docker-compose.yml with n8n, PostgreSQL, Redis, and Caddy services, configure your environment variables, then run docker compose up -d. The full setup takes about 15-30 minutes.

Is n8n secure for business use?

Yes. Self-hosted n8n keeps all data on your server, giving you full control. Best practices include SSL via Caddy, basic authentication or SSO, encrypted credentials storage with N8N_ENCRYPTION_KEY, and regular PostgreSQL backups. The enterprise version adds SAML SSO, RBAC, audit logs, and is SOC 2 compliant.

How many integrations does n8n support?

n8n supports over 400 built-in integration nodes covering CRM, marketing, development, communication, e-commerce, and more. With the HTTP Request node, you can connect to any REST API. Community nodes add hundreds more integrations including AWS services, PDF manipulation, and cryptocurrency data.

What is the break-even point for self-hosted n8n?

Self-hosted n8n becomes cost-effective at around 200-500 executions/month versus n8n Cloud, and at 1,000-2,000 operations/month versus Zapier Professional. At 5,000+ operations/month, the savings are significant: a small business can save over $3,300 per year compared to Zapier.

Stop Paying Per Task. Start Self-hosting.

Get unlimited n8n automation on your own Contabo VPS for just $5.50/month. Follow this guide and be up and running in under an hour.