How to Install n8n on a VPS? Beginner-Friendly Guide Needed

acharyasambhav

New member
May 7, 2026
2
1
3
Hey everyone,

I recently got a VPS and want to install n8n for automation workflows, but I’m a bit confused about the proper setup process.


My VPS currently has:
  • Ubuntu installed
  • Root SSH access
  • Domain available (optional)
  • Basic knowledge of Linux commands

I want to know:
  • What are the exact steps to install n8n on a VPS?
  • Is Docker recommended or direct installation better?
  • How do I run n8n securely with HTTPS/SSL?
  • What are the minimum VPS requirements?
  • How can I keep n8n running permanently in the background?
  • Any common mistakes beginners should avoid?

If possible, please share:
  • Step-by-step commands
  • Recommended stack/setup
  • Reverse proxy configuration (Nginx/Caddy)
  • Security tips

Would appreciate any beginner-friendly tutorials or advice. Thanks!
 
  • Like
Reactions: praweenkiorala
Hey @acharyasambhav, welcome to Ekuraa! This is a fantastic question and exactly the kind of infrastructure discussion we love to see here.
n8n is an absolute powerhouse for automation, but getting the initial setup right is crucial if you don't want it crashing on you later. Let's break down your questions first, and then I'll give you the exact step-by-step commands.
### The Quick Answers:
* **Docker vs. Direct?** **100% Docker.** Specifically, Docker Compose. Do not install it directly via npm. Docker keeps everything containerized, makes updating as easy as typing two commands, and automatically handles keeping it running in the background.
* **Minimum Requirements?** n8n can technically boot on 1GB of RAM, but the moment you run a heavy workflow, it will crash. **2GB of RAM is the absolute minimum** you want for a production environment.
* **Keeping it running permanently?** Because we are going to use Docker, we will set restart: always in the configuration. If your VPS reboots or n8n crashes, the server will instantly spin it back up automatically.
Here is the exact, beginner-friendly stack I recommend: **Ubuntu + Docker Compose + Caddy.**
We use Caddy instead of Nginx here because Caddy automatically provisions and renews your SSL (HTTPS) certificate for free without you having to mess with Certbot.
### Step-by-Step Installation Guide
**Step 1: Prep your Domain**
Before touching the terminal, go to your domain registrar (or Cloudflare) and create an **A Record** (e.g., n8n.yourdomain.com) pointing to your VPS IP address.
**Step 2: SSH in and Install Docker**
Log into your VPS as root and run this command to install Docker and Docker Compose automatically:
```bash
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

```
**Step 3: Create your n8n Folder**
Let's keep things organized. Create a directory for your n8n data and navigate into it:
```bash
mkdir ~/n8n-docker
cd ~/n8n-docker

```
**Step 4: Create the Docker Compose File**
This file tells your VPS exactly how to build n8n and Caddy.
Run nano docker-compose.yml and paste the following inside. **(Make sure to change n8n.yourdomain.com to your actual domain!)**
```yaml
version: '3.8'

services:
caddy:
image: caddy:latest
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- caddy_data:/data
- ./Caddyfile:/etc/caddy/Caddyfile

n8n:
image: docker.n8n.io/n8nio/n8n
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:
caddy_data:
n8n_data:

```
*(Press Ctrl+X, then Y, then Enter to save and exit).*
**Step 5: Create the Caddy Reverse Proxy File**
Now we tell Caddy to route traffic securely to n8n.
Run nano Caddyfile and paste this inside **(Change the domain again)**:
```text
n8n.yourdomain.com {
reverse_proxy n8n:5678
}

```
*(Save and exit).*
**Step 6: Boot it up!**
You are ready to go. Run this command to start everything in the background:
```bash
docker compose up -d

```
Wait about 60 seconds, then open https://n8n.yourdomain.com in your browser. You will be greeted by the n8n setup screen, completely secured with an SSL padlock!
### ⚠️ Common Beginner Mistakes to Avoid:
1. **Not adding a Swap File:** If your VPS only has 2GB of RAM, n8n might spike during heavy data processing. Run fallocate -l 2G /swapfile to create a 2GB swap file. It will save your server from freezing.
2. **Forgetting the Webhook URL:** Notice in the docker-compose file we set the WEBHOOK_URL. If you forget this, any webhooks you create in n8n will show the internal Docker IP instead of your actual domain, and third-party apps won't be able to talk to your work
flows.
Let us know if you hit any snags during the installation. Happy automating!
 
  • Like
Reactions: Sambhav Acharya