I recently published a detailed guide on my blog about setting up n8n on an AWS EC2 instance. If you’ve ever wanted to run your own automation server—without relying on third-party SaaS—this is one of the most flexible and cost-effective ways to do it.
👉 Here’s the full article on my blog: Self-Hosting n8n on AWS EC2 with Docker
But let me give you a quick breakdown here.
Why EC2 for n8n?
EC2 is Amazon’s go-to compute service. You get:
- Full control over the instance (OS, storage, network).
- Flexibility to scale up or down depending on workload.
- Integration with other AWS services if you want to expand later.
And since n8n runs well in Docker, EC2 is a natural fit.
The Deployment Flow (Short Version)
Here’s the 10,000-foot view of how the process works:
Launch an EC2 instance
Start with Ubuntu 22.04 LTS. Even at3.micro
works for testing.Configure security groups
Open inbound ports: 22 (SSH), 80, and 443 (HTTP/HTTPS). If you’re testing without SSL, you can expose port 5678 directly, but it’s not secure.Install Docker & Docker Compose
sudo apt update && sudo apt upgrade -y
sudo apt install docker.io docker-compose -y
Set up n8n with Docker Compose
Create a simpledocker-compose.yml
file mapping port 5678 (or use a reverse proxy like Nginx/Caddy for SSL).Secure with HTTPS
Point a domain to your EC2 Elastic IP, then use Let’s Encrypt (Certbot) or Caddy to generate certificates automatically.Configure environment variables
For example:
N8N_HOST=n8n.example.com
N8N_PROTOCOL=https
WEBHOOK_URL=https://n8n.example.com/
N8N_ENCRYPTION_KEY=$(openssl rand -base64 24)
Restart Docker Compose after editing.
Common Pitfalls
From my own setup and feedback from others, here are the usual snags:
- Browser says site is unsafe → That’s because there’s no SSL. Add HTTPS with Let’s Encrypt or Caddy.
-
Container keeps restarting → Check your
.env
file for missing keys likeN8N_ENCRYPTION_KEY
. -
Can’t SSH into EC2 → Use the correct username (
ubuntu@
for Ubuntu), ensure your key pair is added, and security group allows port 22. - Workflows disappear after reboot → Mount a Docker volume or connect n8n to PostgreSQL instead of relying on SQLite.
Want the Full Walkthrough?
This is just the short version. I’ve written the full step-by-step tutorial with detailed commands, screenshots, and a troubleshooting section on my blog. You can check it out here:
👉 Self-Hosting n8n on AWS EC2 with Docker
✍️ If you try this setup, let me know how it goes—or share what other cloud providers you’ve deployed n8n on.
Top comments (0)