🚀 N8N Self Hosted Tutorial: Complete Installation Guide on AWS EC2 with Docker (Beginner Friendly)

✨ This comprehensive n8n tutorial will show you how to set up n8n self hosted on AWS EC2 using Docker, Caddy for HTTPS, and your custom domain — perfect for beginners looking for a complete n8n installation guide.

🧠 What Is N8N?

n8n (pronounced “n-eight-n”) is an open-source workflow automation tool that helps you connect apps and automate tasks without writing code. This self-hosted solution gives you complete control over your automation workflows while keeping costs low with AWS Free Tier.

🧰 What You’ll Need for This Setup

✅ An AWS EC2 Ubuntu Server (Free Tier works perfectly for small workloads)
✅ A domain name (like n8n.yourdomain.com)
✅ Access to your domain DNS settings (via Namecheap, GoDaddy, etc.)
✅ An SSH client like Terminal (Mac/Linux) or PuTTY (Windows)

⚙️ Step 1: Launch Your AWS EC2 Instance

  1. Go to AWS Console
  2. Launch a new EC2 instance:
    • Choose Ubuntu 22.04 LTS
    • Use t2.micro (Free Tier eligible for your setup)
    • Allow HTTP, HTTPS, and SSH in the security group
    • Add a key pair (download the .pem file)
  3. Connect via SSH:
ssh -i your-key.pem ubuntu@your-ec2-public-ip

🐳 Step 2: Install Docker

Install Docker on your server for the n8n installation:

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

Then log out and back in (or run newgrp docker) to use Docker without sudo.

🌐 Step 3: Set Up Caddy for HTTPS

Install Caddy to secure your workflow automation platform:

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo tee /etc/apt/trusted.gpg.d/caddy.asc
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

Make sure ports 80 and 443 are allowed through your firewall/security group (done in Step 1).

🌍 Step 4: Update DNS Settings for Your Domain

Go to your domain registrar (e.g. Namecheap, GoDaddy):

  1. Add an A record:
    • Name: n8n (or @ if using root domain)
    • Value: Your EC2 public IP
    • TTL: Automatic or 30 mins
  2. Wait 5–10 minutes for DNS to propagate.

📦 Step 5: Deploy N8N with Docker

Pull the latest stable n8n image:

docker pull docker.n8n.io/n8nio/n8n

Then run your containerized workflow platform:

docker run -d --restart always \
  -p 5678:5678 \
  -v n8n_data:/home/node/.n8n \
  -e N8N_BASIC_AUTH_ACTIVE=true \
  -e N8N_BASIC_AUTH_USER=admin \
  -e N8N_BASIC_AUTH_PASSWORD=yourpassword \
  -e N8N_SECURE_COOKIE=true \
  -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true \
  -e WEBHOOK_URL=https://n8n.yourdomain.com/ \
  --name n8n \
  docker.n8n.io/n8nio/n8n

Important: Replace yourpassword with something strong for your workflow automation platform.

🔒 Step 6: Configure Caddy for HTTPS

Edit Caddy config for your setup:

sudo nano /etc/caddy/Caddyfile

Paste this configuration (replace with your domain):

n8n.yourdomain.com {
  reverse_proxy localhost:5678
}

Restart Caddy to complete the process:

sudo systemctl restart caddy

✅ Caddy will automatically get a free SSL certificate from Let’s Encrypt for your instance.

🔑 Step 7: Access Your Workflow Platform

Visit your automation platform:

  • URL: https://n8n.yourdomain.com
  • Username: admin
  • Password: yourpassword

🎉 Your setup is now complete!

🔁 Optional: Export & Backup Your Workflows

You can run this command to export all workflows from your platform:

docker run --rm \
  -v /var/lib/docker/volumes/n8n_data/_data:/home/node/.n8n \
  -v /home/ubuntu/n8n-git-backups:/home/node/backup \
  -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false \
  n8nio/n8n \
  export:workflow --backup --output=/home/node/backup

📌 Final Setup Checklist

✅ TaskDescription
🌐 DomainDNS A record points to EC2 IP
🐳 DockerRunning n8n container
🔐 HTTPSCaddy reverse proxy with SSL
👥 AuthBasic auth enabled
💾 VolumeDocker volume for persistent storage

🎉 Congratulations! You now have a secure, production-ready workflow automation platform running with your custom domain and HTTPS, ready to automate anything!

🧠 Bonus: Update Your Platform Later

To update your automation platform:

docker pull docker.n8n.io/n8nio/n8n
docker stop n8n
docker rm n8n
# Then re-run the docker run command from Step 5 above

🎯 Why Choose This Self-Hosted Approach?

  • Complete Control: Your n8n self hosted setup means your data stays on your servers
  • Cost-Effective: Use AWS Free Tier for your deployment
  • Scalable: Easy to upgrade your instance as you grow
  • Secure: Full HTTPS encryption and custom authentication
  • Open Source: No vendor lock-in with this solution

This n8n tutorial provides everything you need for a professional deployment that’s both secure and scalable. Your automation platform is now ready to handle all your workflow needs!