Skip to content

Self-hosted n8n: automation without fees

Section 1 of 9
Size 3 of 5

Virtual servers04/08

Self-hosted n8n: automation without fees

A guide to n8n on your own server: what its licence allows, workflows for a small business, Docker install, domain and webhooks, backups and updates.

Abdulwahed MohammadContent writer at tech+11 min read

A clothing shop in Amman takes orders from its website, writes each one into a spreadsheet by hand, then messages the warehouse and emails the customer. Three steps, repeated forty times a day, and every one a chance for a mistake. Automation tools do this in seconds, but most charge a monthly fee that grows with every task they run. n8n is a different option: a workflow automation tool you can install on your own server and use without counting tasks. This guide explains what n8n is and what its licence allows, gives workflows that suit a small business in Jordan, then installs it with Docker, connects it to a domain for webhooks, and keeps it backed up and up to date.

01What n8n is

n8n is a tool for building automations by drawing them. Each is a chain of nodes on a canvas: it starts with a , such as a new form submission, a new email or a set time every morning, then passes the data from node to node. One node writes a row to Google Sheets, another sends an email, a third posts a message to a team chat. Between them you can filter, branch on conditions, merge data, or write a few lines of JavaScript or Python when no ready node does what you need.

Hundreds of ready nodes connect it to common services: Google Sheets and Drive, Gmail and any mail server, Telegram, Slack, databases such as MySQL and PostgreSQL, and any service with an API through the HTTP Request node. It also has AI nodes that call a language model, including one you run yourself on the same server.

Every run is recorded: you see the data that entered and left each node, so when something fails you know exactly where and why. That alone saves hours compared with scripts that fail silently.

02What its licence allows

n8n is not open source in the strict sense. Its code is public, but the self-hosted community edition comes under the . In short, it lets you use and modify n8n for your own internal business purposes, or for personal and non-commercial use, free of charge. The line it draws is about selling n8n itself. n8n’s licence FAQ gives these examples:

UseUnder the Sustainable Use License
Automating your own company’s workAllowed
Building and running workflows for a client, who cannot create or edit themAllowed
Charging for setup, maintenance, training and consultingAllowed
Using n8n as a hidden engine behind your own app, where users never build workflowsAllowed
Hosting n8n as a service where your customers build their own workflowsNot allowed
White-labelling n8n under your name, or forking it into your own automation productNot allowed
Enterprise features that need a licence keyNeed an Enterprise licence

For a shop, a clinic, an office or an agency automating its own work, the licence is not an obstacle. If your plan sits in a grey area, such as shipping n8n to customers inside a paid product, n8n asks you to write to its licensing team first. And this licence covers the self-hosted edition only; n8n Cloud has its own terms.

03Workflows for a small business

Here is what the Amman shop, or a pharmacy in Irbid, or a training centre in Zarqa, can automate in its first week:

WorkflowTriggerMain nodes
Orders into a sheetWebhook from the website’s order formGoogle Sheets: append row, then Send Email to the customer
Alert the team about a new orderThe same webhookTelegram: send a message to the staff group
Morning sales summarySchedule: every day at 8:00Google Sheets: read yesterday’s rows, then Send Email to the owner
Sorting incoming invoicesEmail Trigger (IMAP)IF on the subject, then save the attachment to Google Drive
Order status repliesWebhook from the websiteDatabase lookup, then a reply to the customer

From order form to sheet and email

The first workflow is the classic. The website’s order form sends its data to an address that n8n gives you, through a Webhook node. The next node adds a row to the orders sheet with the name, phone number, item and city. A third node sends the customer a short confirmation email from the shop’s mail account. Then a Telegram node posts the order to the warehouse group, so the team starts packing without anyone copying anything by hand.

Messaging apps, in general terms

Telegram is the easiest to connect: you create a bot through Telegram’s own BotFather, paste its token into an n8n credential, and add the bot to your team’s group. WhatsApp is different: n8n connects to WhatsApp Business through Meta’s official Cloud API, which needs a Meta business account and a verified number, and Meta requires approved message templates to start a conversation with a customer. Plan for that setup before you promise customers WhatsApp updates.

04What the server needs

n8n itself is light, but the server runs Docker, a web server and the system beside it, and each workflow run uses memory while it works. 2 GB of memory and 2 cores is a practical minimum for a small business; heavy workflows, many runs at once or large files need more.

By default n8n stores its workflows, credentials and execution history in a SQLite database inside its data folder. That suits a small installation. If you run thousands of executions a day, move to PostgreSQL, which n8n supports through its DB_POSTGRESDB settings. Either way, the execution history grows: n8n prunes executions older than 14 days by default, or beyond 10,000, but on SQLite the space is not returned to the disk until the database is vacuumed, which the DB_SQLITE_VACUUM_ON_STARTUP setting does at each start.

05Install n8n with Docker

These steps assume Ubuntu 24.04, Debian 12 or AlmaLinux 9, with a user that has sudo. First install Docker Engine from Docker’s own repository; Docker says its quick convenience script is meant for test machines, not production:

Installing Docker Engine from Docker’s repository
# Ubuntu (on Debian, replace ubuntu with debian in both URLs)sudo apt update && sudo apt install -y ca-certificates curlsudo install -m 0755 -d /etc/apt/keyringssudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.ascsudo chmod a+r /etc/apt/keyrings/docker.ascsudo tee /etc/apt/sources.list.d/docker.sources <<EOFTypes: debURIs: https://download.docker.com/linux/ubuntuSuites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")Components: stableArchitectures: $(dpkg --print-architecture)Signed-By: /etc/apt/keyrings/docker.ascEOFsudo apt updatesudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin# AlmaLinux 9sudo dnf -y install dnf-plugins-coresudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.reposudo dnf -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginsudo systemctl enable --now docker

Then create a folder for n8n with two files. The in .env protects every password and token you save in n8n; generate it once and keep a copy somewhere safe, away from the server:

n8n in Docker Compose, published on the server itself only
mkdir -p ~/n8n && cd ~/n8necho "N8N_ENCRYPTION_KEY=$(openssl rand -hex 32)" > .envchmod 600 .env# compose.yamlservices:  n8n:    image: n8nio/n8n:2.49.7    restart: always    ports:      - "127.0.0.1:5678:5678"    environment:      N8N_HOST: auto.tatreez-studio.com      N8N_PORT: 5678      N8N_PROTOCOL: https      N8N_WEBHOOK_URL: https://auto.tatreez-studio.com/      N8N_PROXY_HOPS: 1      N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}      N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS: "true"      NODE_ENV: production      GENERIC_TIMEZONE: Asia/Dubai      TZ: Asia/Dubai    volumes:      - n8n_data:/home/node/.n8nvolumes:  n8n_data:

A few lines need explaining. The port is published on 127.0.0.1 only: ports that Docker publishes on all addresses bypass the UFW firewall, so this line is what keeps n8n closed to the internet until the web server sits in front of it. GENERIC_TIMEZONE makes the Schedule node fire at 8:00 Dubai time, not New York time, which is n8n’s default. N8N_WEBHOOK_URL is the name since n8n 2.30; on older versions the same setting is WEBHOOK_URL. The image is pinned to the version that was stable when this was written; check n8n’s documentation for the current one.

Start it with sudo docker compose up -d, and read its first start with sudo docker compose logs -f n8n.

06The domain, HTTPS and webhooks

are how other systems call n8n: your website’s form sends its data to an address such as https://auto.tatreez-studio.com/webhook/new-order. For that address to work from the internet, n8n needs a domain, HTTPS and the right webhook URL setting.

Point a subdomain at the server with an A record in your domain’s DNS, then put Nginx in front of n8n and get a certificate with Certbot. The Upgrade lines are needed because the n8n editor keeps a live connection over WebSocket:

Nginx and Certbot in front of n8n, and a firewall for SSH and the web
# Ubuntu and Debiansudo apt install -y nginx certbot python3-certbot-nginx# /etc/nginx/sites-available/n8nserver {    listen 80;    server_name auto.tatreez-studio.com;    client_max_body_size 20M;    location / {        proxy_pass http://127.0.0.1:5678;        proxy_http_version 1.1;        proxy_set_header Upgrade $http_upgrade;        proxy_set_header Connection "upgrade";        proxy_set_header Host $host;        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;        proxy_set_header X-Forwarded-Proto $scheme;        proxy_buffering off;    }}sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/sudo nginx -t && sudo systemctl reload nginxsudo certbot --nginx -d auto.tatreez-studio.comsudo ufw allow OpenSSHsudo ufw allow "Nginx Full"sudo ufw enable

Open the domain in your browser: n8n asks you to create the owner account on the first visit, so do it at once. Then two details save a lot of confusion with the Webhook node:

  • Test URL and production URL: Each Webhook node shows two addresses. The test address, under /webhook-test/, works only while you click to listen for a test event in the editor. The production address, under /webhook/, works only once the workflow is published. In n8n 2.0 and later, Publish replaced the old Active toggle, and saving a published workflow does not change the live version until you publish again.
  • Protect the webhook: Anyone who knows the address can call it. In the Webhook node, choose Header Auth or Basic Auth, and send the same secret from your website, so random requests are rejected.

07Keep it secure

An n8n server holds the keys to your other systems: your sheets, your mailbox, your team chat. Treat it accordingly:

  • Two-step sign-in: Turn on two-factor authentication for the owner account from your personal settings in n8n, with an authenticator app.
  • Accounts for people, not shared logins: Invite each team member with their own account, and remove it when they leave.
  • Only the ports you need: SSH, HTTP and HTTPS. Port 5678 stays on 127.0.0.1.
  • Careful with community nodes: Nodes from outside n8n run code on your server with access to your data. Install only well-known ones you need.
  • The narrowest permissions: When you connect a Google account or a database, give n8n only the access the workflow needs, such as one sheet rather than the whole Drive.

08Backups and updates

Everything n8n knows lives in its data volume: the database with your workflows, credentials and executions. Back up two things: the volume itself, and an export of your workflows and credentials in readable files. Without the encryption key, exported credentials cannot be read, so keep the .env file with every backup:

Exporting workflows and credentials, and archiving the data volume
cd ~/n8n# Readable exports, one file per workflow and per credentialsudo docker compose exec n8n n8n export:workflow --backup --output=/home/node/.n8n/backups/workflows/sudo docker compose exec n8n n8n export:credentials --backup --output=/home/node/.n8n/backups/credentials/# A full copy of the data volume, with n8n stopped for a moment so SQLite is consistentsudo docker compose stop n8nsudo docker run --rm -v n8n_n8n_data:/data -v "$PWD":/backup alpine tar czf /backup/n8n-data-$(date +%F).tar.gz -C /data .sudo docker compose start n8n

The volume is named n8n_n8n_data because Compose prefixes it with the folder name; sudo docker volume ls shows it. Put these commands in a script that cron runs every night, and copy the archive and the .env file off the server, since a backup on the same disk does not survive the loss of that disk. To restore on a new server, extract the archive into the volume before the first start, or use n8n import:workflow and import:credentials with --separate and --input on the exported folders, with the same encryption key.

To update, change the version in compose.yaml after reading n8n’s release notes, then run:

Updating n8n in Docker Compose
cd ~/n8nsudo docker compose pullsudo docker compose downsudo docker compose up -dsudo docker compose logs -f n8n

Take a backup before every update, and read the breaking changes before a new major version, as n8n 2.0 changed how workflows are published.

ProblemThe webhook address in n8n shows localhost:5678
FixN8N_WEBHOOK_URL is missing or wrong (WEBHOOK_URL on versions before 2.30). Set it to your domain with https and a trailing slash, then recreate the container.
ProblemThe production webhook answers 404
FixThe workflow is not published, or the call uses the /webhook-test/ address. Publish the workflow and use the /webhook/ address.
ProblemThe scheduled workflow runs at the wrong hour
FixGENERIC_TIMEZONE is not set, so n8n uses New York time. Set Asia/Dubai, or the workflow’s own timezone in its settings.
ProblemCredentials stop working after moving to a new server
FixThe new server has a different encryption key. Use the same N8N_ENCRYPTION_KEY as the old one.
ProblemThe disk fills up slowly
FixExecution history and pruned SQLite space. Lower EXECUTIONS_DATA_MAX_AGE, set DB_SQLITE_VACUUM_ON_STARTUP to true, or move to PostgreSQL.

09n8n ready on CoreVPS

If you would rather start building workflows than set up a server, n8n is one of nearly 100 ready apps on CoreVPS. When you order, choose your operating system, then pick n8n under «Preinstalled software»; the list shows only the apps that support that system and fit the chosen plan. After the server is delivered, the install runs on its own, and an email brings you the app’s address and the login details or the setup steps.

The order form starts n8n at the VPS Plus plan: 2 vCPU on AMD EPYC processors, 2 GB of memory and 30 GB of NVMe, at $6 a month, with 15 GB of backup space. That is enough for a small business’s everyday workflows. If you will run heavy workflows, many runs at once or PostgreSQL beside it, the CoreVPS builder lets you add cores and memory, and you can upgrade later without reinstalling.

Then follow the steps above that still apply: point your domain at the server from DNS Console, put HTTPS in front of n8n, set the webhook URL, turn on two-step sign-in, and schedule your backups. Questions about the right plan? Our support team is there when you need it.

Test your understanding

Three questions, one minute

⁦0 / 3⁩Set 1

  1. 01A shop uses its own n8n server to put its orders into a sheet. What does the Sustainable Use License say?

  2. 02Which of these does the Sustainable Use License forbid?

  3. 03Why publish n8n’s port on 127.0.0.1 in compose.yaml?

Ready to start? Power your projects today

Choose the hosting, server or domain that suits your business, and our specialist team is available around the clock to make your projects a success.

A .com domain a year
$17
cPanel hosting per month
$2
CoreVPS servers per month
$3.50