How to Install n8n on Ubuntu 22.04 with SSL and Domain
In the rapidly evolving landscape of 2026, automation is no longer a luxuryโit is the engine of productivity. Learning how to Install n8n on Ubuntu is like building your own digital command center, giving you the power to connect hundreds of apps without a single monthly subscription fee. This guide will walk you through the process of setting up a secure, professional-grade instance with a custom domain and SSL encryption. ๐
Self-hosting n8n on a Linux server offers unparalleled privacy and control. Think of it as owning your own factory rather than renting space in someone elseโs warehouse. By the end of this tutorial, you will have a robust automation platform running on Ubuntu 22.04, protected by a “secret handshake” (SSL) that keeps your data safe from prying eyes. ๐ก๏ธ
Table of Contents
- Prerequisites: Preparing Your Server
- Step 1: Installing the Foundation (Docker)
- Step 2: Deploying n8n with Docker Compose
- Step 3: Securing with Nginx and SSL
- Self-Hosted vs. n8n Cloud
- Pros and Cons
- How to Use It Properly
- Tips and Tricks for 2026
- Frequently Asked Questions
Prerequisites: Preparing Your Server ๐๏ธ
Before we dive into the installation, we need a solid foundation. You should have an Ubuntu 22.04 server with at least 2GB of RAM (4GB is recommended for heavy workflows). You will also need a domain name (e.g., n8n.yourdomain.com) pointed to your server’s IP address via an A Record.
A “Domain Name” is essentially the digital address of your server. An “A Record” is the instruction that tells the internet which specific physical computer (IP address) that address belongs to. Ensure your firewall allows traffic on ports 80 (HTTP) and 443 (HTTPS) before proceeding. ๐
Step 1: Installing the Foundation (Docker)
To Install n8n on Ubuntu effectively, we use Docker. Docker is like a standardized shipping container for software; it ensures that n8n runs the same way on your server as it does on the developer’s machine. Run the following commands to get started:
// This script updates your system and installs Docker
// We use sudo to ensure we have administrative permissions
sudo apt update && sudo apt upgrade -y;
// Install necessary certificates and curl for downloading Docker
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y;
// Add Docker's official GPG key for security
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg;
// Install the Docker engine
sudo apt install docker-ce docker-ce-cli containerd.io -y;
By running these commands, you are cleaning up the “workspace” and bringing in the heavy machinery. Docker allows n8n to exist in its own isolated environment, preventing conflicts with other software on your Ubuntu system. ๐ฆ
Step 2: Deploying n8n with Docker Compose
Now we will use Docker Compose to define how n8n should run. We need to create a configuration file that tells Docker which version of n8n to pull and which ports to open. We use a .env file to keep our sensitive information, like our domain name, organized. ๐ ๏ธ
{
"version": "3.8",
"services": {
"n8n": {
"image": "n8nio/n8n:latest",
"restart": "always",
"ports": [
"5678:5678"
],
"environment": [
"N8N_HOST=n8n.yourdomain.com",
"N8N_PORT=5678",
"N8N_PROTOCOL=https",
"NODE_ENV=production",
"WEBHOOK_URL=https://n8n.yourdomain.com/"
],
"volumes": [
"n8n_data:/home/node/.n8n"
]
}
},
"volumes": {
"n8n_data": {}
}
}
This JSON-like structure is the “blueprint” for your n8n house. It tells the server to always restart if it crashes and defines where to save your workflows so they don’t disappear if the server restarts. The WEBHOOK_URL is vital; itโs the return address for other apps to send data back to your n8n instance. ๐ฎ
Step 3: Securing with Nginx and SSL ๐ก๏ธ
Running n8n over a plain connection is risky. We need a “Reverse Proxy”โthink of it as a security guard (Nginx) standing at the front door who checks IDs and ensures everyone is speaking a coded language (SSL). We will use Certbot to get a free certificate from Let’s Encrypt.
// Install Nginx, our traffic director
sudo apt install nginx -y;
// Install Certbot for our SSL certificate
sudo apt install certbot python3-certbot-nginx -y;
// Request the SSL certificate and automatically configure Nginx
// Replace n8n.yourdomain.com with your actual domain
sudo certbot --nginx -d n8n.yourdomain.com;
Once this is done, Nginx will handle the “handshake” between your user and the server. It encrypts the data before it ever leaves the server, making sure that your API keys and passwords remain private. ๐
Self-Hosted vs. n8n Cloud
| Feature | Self-Hosted (Ubuntu) | n8n Cloud |
|---|---|---|
| Monthly Cost | Server Cost only (~$5-10) | Starts at ~$20+ |
| Data Privacy | Total Control | Hosted by n8n |
| Maintenance | Manual Updates | Automatic |
| Execution Limits | Unlimited (Server Dependent) | Tier-based Limits |
Pros and Cons
Pros โ
- Full Ownership: You own the data and the workflows entirely.
- No Execution Limits: Run as many workflows as your CPU can handle.
- Customization: Install custom Node.js libraries and tools.
- Cost-Effective: Significantly cheaper for high-volume users.
Cons โ
- Server Management: You are responsible for backups and security patches.
- Initial Complexity: Requires basic knowledge of the Linux command line.
- No Built-in Support: You rely on the community and documentation rather than a support ticket system.
How to Use It Properly
To use n8n properly on Ubuntu, you must monitor your server’s resource usage. Automation can sometimes go into “infinite loops” if not designed correctly. Always set up a “Resource Monitor” or check your server periodically using the htop command. ๐
Furthermore, ensure you are using the “Code Node” sparingly for heavy processing. While n8n is powerful, performing complex data manipulation in JavaScript is more efficient than using 20 different basic nodes. Here is a quick example of a well-commented health check you might use inside an n8n Code Node:
// This code checks if the incoming data has the required fields
// It's a simple gatekeeper for your workflows
for (const item of $input.all()) {
// Check if 'email' exists in the JSON body
if (!item.json.email) {
item.json.status = "error";
item.json.message = "Missing email field";
} else {
item.json.status = "success";
// We add a timestamp to track when the check occurred
item.json.checkedAt = new Date().toISOString();
}
}
return $input.all();
The code above acts like a “quality control inspector” on an assembly line. It looks at each piece of data passing through and stamps it with a status so the rest of your workflow knows whether to proceed or stop. ๐ง
Tips and Tricks for 2026 ๐ก
- Auto-Backups: Set up a Cron job to back up your
.n8ndirectory to an external S3 bucket every night. - Binary Data Storage: If you process many files, use an external storage provider like AWS S3 or MinIO to keep your Ubuntu server lean.
- Environment Variables: Store your most sensitive credentials in the
.envfile rather than hardcoding them into n8n nodes. - Updating: To update n8n, simply run
docker-compose pull && docker-compose up -d. It’s like refreshing a webpage for your entire server.
Frequently Asked Questions
Is n8n free to host on Ubuntu?
Yes, n8n is “fair-code,” meaning you can host it for free for personal and internal business use. Check their official license for specific commercial redistribution rules.
Can I run n8n on 1GB of RAM?
It is possible but not recommended. The Node.js process and the n8n application are quite hungry for memory, especially when dealing with large JSON objects. 2GB is the “sweet spot” for small setups.
What happens if my server restarts?
Since we used the restart: always policy in our Docker Compose file, n8n will automatically boot up as soon as your server finishes restarting. You won’t miss a beat! โก
By following these steps, you have successfully learned how to Install n8n on Ubuntu and secure it for the modern age. You now have a private, powerful, and scalable automation engine at your fingertips. ๐
Ready to take your automation skills to the next level? Explore more guides and tutorials at n8nnode.com.