Skip to content

Chapter 14: n8n Cloud vs. Self-Hosted n8n (Docker/AWS EC2)

Video: Watch this chapter on YouTube (2:54:14)

Overview

This chapter explores deployment options for n8n: the managed n8n Cloud service versus self-hosting using Docker on local machines or AWS EC2 instances. Each approach has distinct advantages and tradeoffs.

Detailed Summary

The Deployment Decision

When starting with n8n, a key decision is how to deploy it:

  1. n8n Cloud: Managed service from n8n
  2. Self-Hosted: Run n8n on your own infrastructure

n8n Cloud: Managed Service

Advantages

Benefit Description
Simplicity Sign up and start building immediately
No infrastructure No servers, Docker, or DevOps required
Automatic updates Always on latest version
Security patches Handled automatically
Official support Access to n8n support team
Uptime monitoring Built-in reliability tracking

Disadvantages

Drawback Description
Cost Monthly subscription fees
Limited control Can't customize infrastructure
Resource limits Bound to plan tiers
Data location May not meet compliance needs

Self-Hosted: Full Control

Advantages

Benefit Description
Total freedom Control resources, location, access
Cost efficiency Can be cheaper with existing infrastructure
Internal integration Connect to internal tools/databases
Security compliance Keep data on-premises
No vendor lock-in Full ownership of deployment

Disadvantages

Drawback Description
Maintenance burden You handle updates, patches
No safety net You fix what breaks
DevOps required Need infrastructure skills
Uptime responsibility You ensure availability

Self-Hosting Option 1: Docker Desktop (Local)

Prerequisites

  1. Docker Desktop: Download from docker.com
  2. Git: For cloning the repository

Installation Steps

  1. Clone the repository:

    git clone https://github.com/n8n-io/self-hosted-ai-starter-kit.git
    cd self-hosted-ai-starter-kit
    

  2. Set up environment:

    cp .env.example .env
    

  3. Run Docker Compose (for Mac/CPU):

    docker compose --profile cpu up
    

The package includes: - n8n - OLLAMA (local LLM) - PostgreSQL (database) - Qdrant (vector database)

Accessing Local n8n

  1. Open browser: localhost:5678
  2. Create account (local only, not saved permanently)
  3. Access dashboard

Demo Workflow

The starter kit includes a demo workflow: - Chat trigger connected to OLLAMA - Demonstrates local LLM integration - Add fallback model for error handling

Docker Desktop Management

  • View running containers
  • Start/stop containers
  • Check logs
  • Configure resources
  • Access container terminals

Self-Hosting Option 2: AWS EC2

Prerequisites

  • AWS account
  • Basic EC2 knowledge
  • SSH client

Using CodeCloud Playground

  1. Go to codecloud.com/playground
  2. Select AWS Sandbox
  3. Launch playground
  4. Copy credentials

Creating EC2 Instance

  1. Navigate to EC2 in AWS Console
  2. Launch Instance:
  3. Name: "n8n-demo"
  4. AMI: Ubuntu
  5. Instance type: t2.medium (for OLLAMA)
  6. Storage: 30GB
  7. Create Key Pair:
  8. Name: "n8n-demo-key"
  9. Format: .pem
  10. Security Group:
  11. Allow SSH (port 22)
  12. Allow Custom TCP (port 5678) from anywhere
  13. Launch

SSH Into Instance

chmod 400 n8n-demo-key.pem
ssh -i n8n-demo-key.pem ubuntu@[PUBLIC_IP]

Install Docker

sudo apt update
sudo apt install -y docker.io
sudo systemctl enable docker
sudo usermod -aG docker ubuntu

Install Docker Compose

sudo apt install docker-compose-v2
docker compose version

Clone and Configure

git clone https://github.com/n8n-io/self-hosted-ai-starter-kit.git
cd self-hosted-ai-starter-kit
cp .env.example .env

Security Configuration

Edit .env file to disable secure cookies (for HTTP access):

nano .env

Add:

N8N_SECURE_COOKIE=false

Launch n8n

docker compose --profile cpu up -d

Verify Containers

docker ps

Should show: n8n, OLLAMA, PostgreSQL, Qdrant

Access n8n

  1. Get EC2 public IP from AWS console
  2. Open browser: http://[PUBLIC_IP]:5678
  3. Create account
  4. Start building workflows

Comparison Summary

Factor n8n Cloud Self-Hosted
Setup time Minutes Hours
Maintenance None Ongoing
Cost Subscription Infrastructure
Control Limited Full
Scaling Plan-based Manual
Security Managed Your responsibility
Updates Automatic Manual
Support Official Community

Recommendation by Use Case

Choose n8n Cloud if: - Just learning n8n - Don't want infrastructure burden - Need reliable uptime - Have budget for subscription

Choose Self-Hosted if: - Need data on-premises - Have DevOps resources - Want full customization - Cost-conscious with existing servers - Enterprise security requirements


Key Takeaways

  1. No wrong answer: Both approaches are valid—choose based on needs.

  2. Cloud is easiest start: Sign up and build without infrastructure concerns.

  3. Self-hosting offers control: Full access to environment and data.

  4. Docker simplifies self-hosting: Container-based deployment is straightforward.

  5. Starter kit includes AI tools: OLLAMA, PostgreSQL, Qdrant bundled together.

  6. EC2 enables cloud self-hosting: AWS infrastructure with self-managed n8n.

  7. Security groups are critical: Must allow port 5678 for n8n access.

  8. t2.medium minimum for OLLAMA: Local LLM needs adequate resources.

  9. Maintenance is ongoing: Self-hosting means continuous responsibility.

  10. Hybrid possible: Some organizations use both for different purposes.

Conclusion

The deployment choice between n8n Cloud and self-hosting reflects broader tradeoffs in software operations. n8n Cloud removes operational burden at the cost of monthly fees and some flexibility. Self-hosting provides complete control and potential cost savings but requires DevOps expertise and ongoing maintenance. For learning and prototyping, n8n Cloud's simplicity is valuable. For production workloads with specific compliance or integration requirements, self-hosting may be necessary. Many organizations start with Cloud and migrate to self-hosted as needs evolve, or maintain both for different use cases. The detailed Docker and EC2 setup instructions enable learners to experience self-hosting firsthand and make informed decisions.