DEV Community

Roshan Sharma
Roshan Sharma

Posted on

How I Deployed and Self-Hosted n8n on Ubuntu 24.04 🚀

I recently wanted to experiment with automating tasks across different apps without relying on third-party platforms. That’s when I came across n8n — an open-source workflow automation tool. In this post, I’ll show you how I set it up from scratch on an Ubuntu 24.04 server using Docker.

This guide assumes you're starting fresh with a new server.


✅ What You’ll Need

  • A cloud VPS or server with Ubuntu 24.04 installed
  • SSH access to the server
  • Basic Linux knowledge (though I’ll guide you through everything)
  • A domain name (optional, but recommended for production setups)

Step 1 — Connect to Your Server

If you don’t already have a server, you can create one using providers like DigitalOcean, AWS Lightsail, or Vultr. After that, you can connect using SSH like this:

ssh username@your-server-ip
Enter fullscreen mode Exit fullscreen mode

Once connected, you’re ready to start!


Step 2 — Update the Server Packages

It's always a good practice to update your server before installing anything.

sudo apt update && sudo apt upgrade -y
Enter fullscreen mode Exit fullscreen mode

This updates your package lists and installs the latest versions.


Step 3 — Install Docker

n8n works best with Docker, so let's install Docker first.

Install Docker Engine

sudo apt install docker.io -y
Enter fullscreen mode Exit fullscreen mode

Enable and start Docker:

sudo systemctl enable docker
sudo systemctl start docker
Enter fullscreen mode Exit fullscreen mode

Verify Docker is installed:

docker --version
Enter fullscreen mode Exit fullscreen mode

You should see something like Docker version 20.xx.x.

Allow Docker Without sudo (Optional)

If you don't want to type sudo every time, you can add your user to the Docker group:

sudo usermod -aG docker $USER
Enter fullscreen mode Exit fullscreen mode

Then log out and log back in to apply the changes.


Step 4 — Install Docker Compose

Docker Compose makes it easier to define and run multi-container Docker applications.

sudo apt install docker-compose -y
Enter fullscreen mode Exit fullscreen mode

Check the version:

docker-compose --version
Enter fullscreen mode Exit fullscreen mode

Step 5 — Set Up n8n with Docker Compose

Create a Folder for n8n

mkdir ~/n8n
cd ~/n8n
Enter fullscreen mode Exit fullscreen mode

Create the docker-compose.yml File

You can create and edit the file using nano or any text editor:

nano docker-compose.yml
Enter fullscreen mode Exit fullscreen mode

Then paste the following content:

version: "3"

services:
  n8n:
    image: n8nio/n8n
    restart: always
    ports:
      - "5678:5678"
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=yourpassword
      - N8N_HOST=your-server-ip
      - WEBHOOK_URL=http://your-server-ip:5678/
      - GENERIC_TIMEZONE=Asia/Kolkata
    volumes:
      - ~/.n8n:/home/node/.n8n
Enter fullscreen mode Exit fullscreen mode

Important:

  • Replace yourpassword with a strong password
  • Replace your-server-ip with your server’s public IP address

Save the file and exit (Ctrl + X, Y, Enter).


Step 6 — Start n8n

Run the following command to start the container:

docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

This will download the required image and start the container in detached mode.

Check if it’s running:

docker ps
Enter fullscreen mode Exit fullscreen mode

You should see the n8n container listed.


Step 7 — Access n8n in Your Browser

Open your browser and navigate to:

http://your-server-ip:5678
Enter fullscreen mode Exit fullscreen mode

You’ll see the n8n login page. Use:

  • Username: admin
  • Password: the password you set in the docker-compose.yml file

Step 8 — Start Automating!

You can now create workflows that connect different apps and services without writing a lot of code. It’s a great tool for testing, personal projects, or even lightweight automation for your business.


Bonus — Next Steps

Here are some things you can consider next:

✔ Set up Nginx as a reverse proxy
✔ Secure your instance with SSL certificates using Let’s Encrypt
✔ Automate backups of your workflows
✔ Explore advanced workflows connecting APIs, messaging platforms, or databases


Final Thoughts

Setting up n8n from scratch on Ubuntu 24.04 was smooth and super rewarding. It’s powerful, flexible, and helps automate tasks in a way that’s easy to manage. If you’re exploring automation tools, I highly recommend giving n8n a try.

I actually learned how to set this up by following the documentation on docs.vultr.com
— huge thanks to them for making the process easy to understand!

Feel free to share your workflows or ask if you want tips on securing or scaling your instance!

Happy automating! 🚀

Top comments (0)