
Step-by-Step Guide: How to Set Up n8n on DigitalOcean with Docker (Beginner Friendly)
Introduction
Welcome to the wonderful world of workflow automation with n8n! 🎉 If you’ve ever dreamed of connecting apps, moving data, or firing off emails automatically—without writing endless lines of code—n8n is your new best friend. Self-hosting n8n on DigitalOcean gives you full control, lower costs, and the freedom to build whatever you like. Plus, with Docker, your setup is clean, repeatable, and portable. Let’s dive in!
1. Prerequisites
Before we jump in, make sure you have:
A DigitalOcean account (free credits may apply!)
A basic comfort level with the terminal (copy/paste commands are OK 😅)
An SSH client (optional but recommended)
A few minutes of free time and a cup of coffee ☕
2. Create a Droplet on DigitalOcean
Log in to your DigitalOcean dashboard.
Click Create → Droplets.
Choose Ubuntu 22.04 as your OS.
Pick a plan. The $5/month tier is perfect for testing.
Select a datacenter region close to you or your users.
Under Authentication, add an SSH key or set a password.
Name your droplet (e.g.,
n8n-server
) and click Create Droplet.
When your droplet is ready, note its public IP address—you’ll need it soon!
Connect via SSH
On macOS/Linux, open a terminal and run:
ssh root@YOUR_DROPLET_IP
On Windows, use PuTTY or the built-in OpenSSH in PowerShell:
ssh root@YOUR_DROPLET_IP
If you used a password, type it in. If you used an SSH key, you’ll get right in. 🚀
3. Install Docker and Docker Compose
Once you’re logged into your droplet, let’s install Docker.
# Update package listsdpkg --configure -a && apt update -y# Install Dockerdash apt install -y docker.io# Start and enable Docker on bootsystemctl start dockersystemctl enable docker# (Optional) Install Docker Compose pluginapt install -y docker-compose-plugin
Verify everything is working:
docker --version # e.g., Docker version 20.10.xdocker compose version # e.g., Docker Compose version v2.x
If you see version numbers, you’re golden! 🌟
4. Set Up n8n with Docker Compose
Create a new directory for n8n:
mkdir -p ~/n8n && cd ~/n8n
Create a file named
docker-compose.yml
:
nano docker-compose.yml
Paste the following into it:
version: '3'services:n8n:image: n8nio/n8nrestart: alwaysports:- "5678:5678"environment:- N8N_BASIC_AUTH_ACTIVE=true- N8N_BASIC_AUTH_USER=admin- N8N_BASIC_AUTH_PASSWORD=supersecret- WEBHOOK_TUNNEL_URL=volumes:- ~/.n8n:/home/node/.n8n
Why these settings?
ports
: Exposes n8n on port 5678.
BASIC_AUTH
: Simple login protection.
volumes
: Saves workflows even if the container restarts.
Save and exit (
Ctrl + X
, thenY
, thenEnter
).
5. Start n8n
In the same folder, run:
docker compose up -d
Docker will download the n8n image (first time only) and start your container. After a minute, open your browser and go to:
http://YOUR_DROPLET_IP:5678
Log in with the admin/supersecret credentials you set earlier. 🎊 Congratulations—you’re in!
6. (Optional) Secure with HTTPS
For production, you’ll want HTTPS. A quick way is using Nginx and Certbot:
Install Nginx and Certbot:
apt install -y nginx certbot python3-certbot-nginx
Create an Nginx site config that proxies
YOUR_DOMAIN
tohttp://localhost:5678
.Obtain a free TLS cert:
certbot --nginx -d yourdomain.com
Reload Nginx:
systemctl reload nginx
For a detailed walkthrough, check the [DigitalOcean HTTPS guide].
7. Next Steps and Automation Ideas
Now that your n8n is live, what can you automate? 🤔
Send a Slack message when a new GitHub issue is opened.
Mail yourself a daily weather report.
Backup form responses from Typeform to Google Sheets.
Tweet your blog posts automatically.
Explore the [n8n community workflows] for inspiration!
8. Troubleshooting Tips
Container Restarting
? Rundocker logs n8n
to see errors.Port conflicts? Make sure nothing else uses 5678.
Permissions issues? Check that
~/.n8n
is owned by the Docker user (usuallyroot
).
If all else fails, Googling the error message often leads to quick fixes.
Conclusion
Self-hosting n8n on DigitalOcean with Docker is surprisingly straightforward—even for beginners! You now have a flexible, powerful automation platform at your fingertips. Go ahead, build a few workflows, impress your friends, and save tons of manual time. 🎉
Got questions or ran into a snag? Drop a comment below or join the n8n forum. Happy automating! 🚀