Guides

An AI Agent on n8n: Self-Hosting It Honestly, From VPS to Monthly Upkeep

Building an AI agent on n8n is real, legal and needs no code. It is also not a two-click job: someone has to run the server, apply updates, keep backups and react when a model or an API changes. The full path with prices checked on 25 November 2026.

11 min read
An AI Agent on n8n: Self-Hosting It Honestly, From VPS to Monthly Upkeep
n8n Cloud Starter€20 a month billed annually, 2,500 executions a month
Own serverHetzner CPX12 (2 GB RAM): €9.99 a month excl. VAT in Helsinki
n8n updatesA new minor version most weeks; 3.0 removes nodes such as Cron and AI Agent v1
Encryption keyLose it and the saved credentials in your backup cannot be decrypted
In this article

An agent that answers clients in Telegram, writes each inquiry to a table and calls a manager can be built in n8n without writing code. It is legal: n8n's Sustainable Use License lets you use it for your own internal business purposes for free. A small server starts at about €10 a month. It sounds like a weekend project.

Building it is the smaller part of the work. The bigger part starts after launch: updates, backups, security fixes, models being retired, APIs changing at every service you connect. Below is the whole path step by step and an honest list of the monthly upkeep. Prices were checked on official pages on 25 November 2026.

First choice: n8n Cloud or your own server

n8n Cloud is the paid hosted version. On 25 November 2026 the Starter plan costs €20 a month billed annually and includes 2,500 executions a month with 5 concurrent executions. Pro costs €50 a month billed annually for 10,000 executions. The trial lasts 14 days with 1,000 executions. Hosted data is stored in the EU, on servers in Frankfurt. Starter and Pro are capped, without overage fees, so count executions before you pick a plan: for a webhook-based workflow, n8n says each event (here, each incoming message) is one execution.

Self-hosted n8n costs nothing in licence fees for your own business, but you pay for the server and you become its administrator. n8n's own installation guide says it plainly: "n8n recommends self-hosting for expert users."

Cloud takes away the server, the certificate and the installation. It does not take away the rest: model retirements, Telegram changes, API keys and billing, the error workflow, reading conversations, and n8n major versions that remove nodes your workflow may use. The rest of this article covers self-hosting, where most of the work is. What an agent is, and how it differs from a button bot, is covered in what is an AI agent.

Step 1. A server

n8n's documentation gives no official minimum for memory or CPU. Its page on memory errors says usage depends on the amount of data, the number of nodes in a workflow and how many workflows run at the same time. The server holds the system, Docker, n8n and maybe Postgres. Prices on 25 November 2026:

  • Hetzner, Regular Performance line, IPv4 included, prices excl. VAT: CPX12 (1 vCPU, 2 GB RAM, 40 GB NVMe) is €9.99 a month in Helsinki and €11.99 in Falkenstein or Nuremberg. CPX22 (2 vCPU, 4 GB, 80 GB) is €16.99 in Helsinki and €19.99 in Nuremberg.
  • DigitalOcean, Basic droplets in US dollars: 1 vCPU, 2 GiB RAM, 50 GiB SSD for $12 a month; 2 vCPU, 4 GiB, 80 GiB for $24 a month. Automated backups add 20% of the droplet price for weekly copies or 30% for daily ones.

Step 2. A domain and HTTPS

Telegram delivers messages to a bot's webhook only at an HTTPS address, on ports 443, 80, 88 or 8443. So the server needs a domain name and a certificate. A subdomain of the domain you already own works, for example n8n.yourcompany.com: you add an A record pointing it to the server's IP address.

Let's Encrypt certificates are free and valid for 90 days by default. In n8n's Docker Compose setup, a proxy called Traefik requests the certificate, and by its own documentation Traefik starts renewing 30 days before expiry. If renewal breaks quietly, the certificate expires and Telegram, after a few retries, gives up.

Step 3. Install with Docker Compose

n8n marks its plain Docker page as outdated and recommends Docker Compose. The order from the official guide:

  1. Install Docker Engine and Docker Compose on a Linux server and check that docker --version and docker compose version both answer.
  2. Point your subdomain to the server with an A record.
  3. Create a project folder with an .env file: DOMAIN_NAME, SUBDOMAIN, GENERIC_TIMEZONE and SSL_EMAIL. Set the time zone: the default is New York, and scheduled workflows will fire at the wrong local time.
  4. Create compose.yaml with two services, traefik and n8n, from the example in the guide.
  5. Start it with docker compose up -d and open n8n at your address.

Database. The guide uses SQLite: workflows, credentials and execution history live in one file, ~/.n8n/database.sqlite. n8n also supports PostgreSQL 16, 17 and 18 through DB_TYPE=postgresdb and the DB_POSTGRESDB_* variables. MySQL and MariaDB were dropped in version 2.0. Postgres is one more service to update and back up with its own tools, so add it only with a reason.

Encryption key. Credentials you save in n8n (model key, bot token, CRM password) are stored encrypted. n8n generates a random key on first launch and saves it in the ~/.n8n folder, or you set your own with N8N_ENCRYPTION_KEY. The backup docs are clear: without that key, "a restored database or encrypted credential export can't be decrypted". The Compose guide does not set this variable: add it yourself and keep a copy away from the server.

Step 4. The model, the bot and the workflow

n8n has ready nodes for the main providers: OpenAI Chat Model, Anthropic Chat Model and Google Gemini Chat Model. Each needs an API key from the provider's developer console. Standard API prices per million tokens on 25 November 2026:

  • A cheap model: Claude Haiku 5.5 costs $0.10 for input and $0.50 for output (for prompts up to 100,000 tokens).
  • A strong model: Claude Sonnet 5.5 costs $2 for input and $10 for output; OpenAI's GPT-6.1 Sol has the same $2 and $10.

Then you create the bot in @BotFather and build the workflow: Telegram Trigger, an AI Agent node with the model, memory and tools, and a Telegram node that sends the answer. Every node and setting is walked through in how to build an AI agent in Telegram.

After launch: what you will do every month

This is the line between "it worked on launch day" and "it works". All of it is happening now.

  • n8n updates and breaking majors. n8n releases a new minor version most weeks. Major versions remove things: 2.0 (December 2025) dropped the Start node and MySQL and replaced the active toggle with publishing. 3.0, in early access since 27 October 2026, removes the Function, Cron and Interval nodes and version 1 of the AI Agent node, and stops loading unverified community nodes by default. Workflows that use removed nodes fail when they run. n8n recommends a full backup before every update and a Migration Report before the major one.
  • Security advisories. Your n8n server is open to the internet, or Telegram cannot reach it. On n8n's GitHub security page, 228 advisories were published in 2026 up to 25 November, 19 of them rated critical. An outdated n8n holding your CRM keys is a risk to client data.
  • Operating system and Docker. Linux, Docker and Postgres need their own updates. Some need a reboot, after which you check that every container came back. If n8n did not start, your business simply stops answering.
  • Backups off the host. A full n8n backup is the .n8n folder (with the key and, on SQLite, the database) plus Postgres if you use it. A hosting snapshot is not enough on its own: Hetzner says its backups are "server-bound and are removed when the server is deleted". Keep a copy somewhere else and test a restore from time to time.
  • Uptime monitoring. n8n has /healthz, which returns 200 if the instance is reachable, and /healthz/readiness, which returns 200 only when the database is connected. Neither alerts anyone. You need an outside monitor that polls them and messages you, or you learn about a night outage from clients.
  • Errors inside workflows. The server can be fine while the workflow fails. An error workflow starting with the Error Trigger node runs when an automatic run fails; you select it in the workflow's Options > Settings. Execution history is pruned by default after 14 days or 10,000 executions, but n8n warns the database can still grow and run out of storage.
  • API keys and billing. When a card expires, a balance runs out or a leaked key is replaced, the agent goes silent. Prices move too: Google lists Gemini 3.8 Flash at $0.75 input and $3.75 output per million tokens until 31 December 2026, and $1.50 and $7.50 from 1 January 2027.
  • Model retirements. Anthropic notified Claude Sonnet 4.5 users on 30 September 2026 and retires the model on 30 November 2026. After that, requests to it fail with a 404 not_found_error, and an agent still set to that model stops answering. Anthropic promises at least 60 days of notice. OpenAI shuts down gpt-5-mini and gpt-5-nano on 11 December 2026. Google is quieter: from 1 December 2026, requests to gemini-2.5-flash are routed automatically to Gemini 3.5 Flash-Lite at its rates, so no error appears, but a different model is talking to your clients. Each case means changing the model and retesting the answers.
  • Telegram Bot API changes. Telegram released nine Bot API versions between February and November 2026, and in four of them fields were renamed, replaced or removed. If your workflow reads specific Telegram fields, check the changelog.
  • Token spend. Every message costs tokens, and on each reply the agent rereads the conversation history and pieces of the knowledge base. More clients, bigger bill. In the first months, check usage weekly.
  • Reading conversations. The agent can say "you are booked" without booking anything, or quote last month's prices. Someone has to read the chats and update the instructions whenever prices or terms change.

What it really costs

The bills here are small. The expensive part is the steady attention of someone who knows what they are doing.

  • Server: from €9.99 a month excl. VAT at Hetzner (2 GB RAM, Helsinki) or $12 a month at DigitalOcean (2 GiB).
  • Domain and certificate: a subdomain of your existing domain costs nothing extra; the Let's Encrypt certificate is free.
  • n8n: free to self-host for your own business, or from €20 a month billed annually on Cloud.
  • Model: paid per token at the provider's rates, so the total depends on how many clients write.
  • A person's time: someone comfortable with Linux and SSH, Docker and Compose, DNS and TLS certificates, making and restoring backups, reading logs, n8n itself, and the dashboards of each provider. Not a one-time setup but a duty: updates, checks and fixes, including nights and holidays. Paying someone to do this is often easier than learning it all.

How to budget the whole agent, with the model and the message flow, is covered in how much an AI assistant costs.

A short note on GDPR

If people in the EU write to your agent, their messages are personal data, and you need a lawful basis for processing them. Every vendor that processes that data for you should have a data processing agreement with you: n8n offers a pre-signed one to download, and your hosting and model providers need the same check. Know where the data sits: n8n Cloud stores it in Frankfurt, a self-hosted instance stores it wherever your server is. Avoid free API tiers for client data: Google says content on the Gemini free tier is used to improve its products, while paid-tier content is not. This is not legal advice.

If building and running this yourself takes too long, or the agent needs your CRM, a knowledge base and several channels connected, AIVFX builds AI agents and can take on the server and the upkeep as part of business process automation.

Frequently asked questions

How much does it cost to run n8n on your own server?

On 25 November 2026, a 2 GB server costs from €9.99 a month excl. VAT at Hetzner or $12 a month at DigitalOcean, and the n8n licence for your own business is free. On top come model tokens at the provider's rates and the time of the person who maintains it all.

Is n8n Cloud easier than self-hosting?

For infrastructure, yes: no server or certificate to manage, from €20 a month billed annually. Model retirements, API keys, billing, error alerts and reading conversations stay with you either way.

Is it legal to self-host n8n for my business?

Yes. The Sustainable Use License allows using n8n for your own internal business purposes free of charge. Selling n8n itself to others as a product is not covered by that permission. If clients from the EU write to the agent, GDPR applies to their messages.

What happens if I do not update n8n?

For a while, nothing. But n8n published 19 critical security advisories in 2026, and your server faces the internet. The longer you wait, the more breaking changes pile up.

What happens if I lose the n8n encryption key?

Saved credentials in a restored backup cannot be decrypted. Every model key, bot token and password would have to be entered again. Set the key with N8N_ENCRYPTION_KEY and store a copy away from the server.

Do I need a programmer to build an agent in n8n?

Connecting nodes needs no code. Running the server, HTTPS, updates and backups needs system administration skills. That is the main job, not the workflow.

Need a video or an AI system built for your task?

Text: Artem Shutkin, AIVFX studio