By Rakibul Hasan, Moonlab
Self-hosting n8n means running it on a server you control instead of using n8n's hosted service. It gives you control over data and can be cost-effective, but you take on updates, backups and security. If nobody will look after it, use the hosted version.
This guide covers what you need, the main cost factors, backups, security, and how to decide between self-hosted and cloud. n8n's licence terms and pricing change, so check n8n's own site for current details before you commit.
What you need to self-host n8n
The basics are a server, a way to run n8n, a database, a domain name with HTTPS and somewhere to keep backups. Most people use a small Linux virtual private server and run n8n with Docker, following the official documentation.
For anything beyond testing, use a proper database such as PostgreSQL rather than the default file-based one, and put n8n behind a reverse proxy that handles HTTPS. Check n8n's current docs for supported setups and system requirements, because they change between versions.
Rough cost factors
Self-hosting is not free even if the software is. Think of the whole cost, not just the server rental.
- Server hosting. A small virtual server is often cheap, but you may need more as workflows grow. Check provider pricing.
- Backup storage. A little extra for offsite copies.
- Domain and monitoring. Small recurring costs.
- Licence terms. Review n8n's current licence for commercial use and which features need a paid plan.
- Your time. Setup, updates and fixing problems. For a small business this is usually the largest cost.
- AI and API usage. These are billed by their own providers regardless of where n8n runs.
Backups you can actually restore
A backup you have never restored is a hope, not a backup. You need three things saved: the database, which holds workflows and credentials, your n8n encryption key, and your configuration files. Without the encryption key, saved credentials in a restored database will not work.
Schedule automatic daily database dumps, copy them off the server, keep several days of history and test a restore on a spare machine at least once. Also export workflows as files and keep them in version control so you can see changes over time.
Security basics
A self-hosted instance holds the keys to your other systems, so treat it as sensitive.
- Serve it over HTTPS only and keep the server's firewall tight, opening only what you need.
- Turn on user authentication and use strong passwords, with two-factor if available on your version.
- Keep the operating system, Docker and n8n updated, reading release notes first.
- Restrict webhooks and the editor to what must be public.
- Use the least-privilege credentials for each connection, and rotate keys when staff leave.
- Do not store secrets in workflow text. Use n8n's credential store.
Updates and monitoring
n8n releases updates often, some of them security fixes. Decide who applies them and how often. A sound routine is: back up, update on a test copy if possible, check that key workflows still run, then update production, and keep a way to roll back.
Monitor the server's disk space and uptime, and add a heartbeat workflow that pings an external check service. If the heartbeat stops, you get an alert. A stopped n8n sends no error emails, so an outside check matters. Our broader view on error alerts is in moonlab.space/guides/n8n-automation-agency.
Data protection and location
Self-hosting lets you choose the region where workflow data and logs live, which can help with GDPR and UK GDPR. It does not change what your connected tools do. An AI provider or CRM you call from n8n still processes data on its own terms. Set execution data retention so logs do not keep personal data longer than you need. This is not legal advice. See moonlab.space/guides/gdpr-ai-automation.
A worked example: a small agency decides
Say a six person marketing agency in Amsterdam runs about a dozen workflows and handles client contact data. One team member is comfortable with Linux and Docker. They compare the two options on a page of paper, with four rows: data location, who maintains it, cost and speed of start.
Self-hosting wins on data location, because they can pick an EU region for the server. It loses on maintenance, since one person becomes responsible for updates and backups, and on speed of start. They decide to self-host but plan for the single point of failure: a second person is trained on the restore process, a written runbook lists the update and rollback steps, and a monthly calendar reminder covers a test restore. If that team member left and nobody could take over, they agreed to move to the hosted service rather than leave an unmaintained server running.
- Step 1: decide who is accountable for the server, in writing, with a deputy.
- Step 2: set up a database that is backed up separately from the n8n container.
- Step 3: store the encryption key somewhere safe and separate from the backups.
- Step 4: put HTTPS and authentication in place before connecting real accounts.
- Step 5: add a heartbeat workflow and an outside uptime check.
- Step 6: write the update and rollback steps, then practise them once.
- Mistake: running on a laptop or an unpatched server that nobody checks.
- Mistake: exposing the editor to the whole internet with weak passwords.
When cloud is the better choice
Choose the hosted service when nobody on your team is comfortable with servers, when you need a quick start, or when the time spent maintaining a server would exceed the savings. It also suits teams that want n8n to handle updates and infrastructure.
Choose self-hosting when you need data to stay on infrastructure you control, want fewer limits from plan tiers, or already run servers confidently. If you are unsure, start on the hosted service and move later, since workflows can be exported. If you want us to set up or run it for you, see moonlab.space/services/cloud-and-devops, or book the free audit at moonlab.space/contact.
