n8n Self-Hosting Tutorial: Deploy n8n on a VPS with Docker
Understand what self-hosting involves, compare it with n8n Cloud, and follow a safe deployment plan for a VPS, Docker, domain, and HTTPS. Learn about backups, updates, security, and common setup problems.
- Architecture explained visually
- Deployment checklist and commands
- Security and backup guidance
What is n8n self-hosting?
You run the n8n service on infrastructure you manage.
Self-hosting n8n means running the application on your own server or cloud virtual private server (VPS), instead of using a provider-managed n8n Cloud environment. A common deployment uses Docker Compose, a persistent data volume, a domain, and a reverse proxy that handles HTTPS.
You gain control over the environment, but you also take responsibility for server security, updates, backups, availability, and troubleshooting. If you are new to workflows, first learn the basics in our n8n tutorial for beginners.
n8n Cloud vs self-hosting
Choose based on how much infrastructure work you want to own.
| Consideration | n8n Cloud | Self-hosted n8n |
|---|---|---|
| Server management | Managed by the provider. | You manage the server, containers, and maintenance. |
| Configuration | Use the available plan features and settings. | More control over the deployment environment. |
| Operations | Less infrastructure work for you. | You handle updates, monitoring, backups, and security. |
| Costs | Plan and usage costs. | Server, storage, backup, and maintenance costs. |
| Good fit when… | You prefer a managed service and quick setup. | You have the skills and time to operate a server. |
Check current features, restrictions, and pricing before choosing.
Why self-host n8n?
Self-hosting can make sense when you want to manage the environment directly.
Environment control
Choose and configure the server and related services you operate.
Data placement
Manage where your instance stores data, subject to your own setup and obligations.
Flexible configuration
Adjust supported deployment options to fit your infrastructure.
Custom workflows
Connect services and build automation for your use cases.
Infrastructure learning
Gain experience with containers, domains, and server operations.
Cost visibility
Review server and service expenses directly, while accounting for maintenance time.
What you need for self-hosted n8n
- A VPS or server running a supported operating system.
- SSH access and basic command-line familiarity.
- Docker Engine and Docker Compose, installed according to current official instructions.
- A domain or subdomain and access to its DNS settings for public HTTPS access.
- A persistent storage plan, encryption key, backups, and update process.
Resource needs depend on execution volume, workflow design, data, and connected services. Start with modest usage, monitor actual server load, and scale based on evidence rather than assuming one server size fits everyone.
How to choose a VPS for n8n
Compare providers on region, CPU and memory, storage, backups, network reliability, support, and total price. Choose a region suitable for your users and data needs. Check the provider’s backup and firewall options before deploying.
For a small learning instance, begin with a configuration that meets current n8n guidance and monitor usage. Production workloads may need more capacity, a managed database, or additional operational planning.
How to self-host n8n with Docker Compose
Use the official deployment instructions for current image tags and environment variables.
- 1
Create a VPS
Choose a supported server, region, and access method. Configure a firewall before exposing services.
- 2
Connect using SSH
Use a secure key-based account where possible. Avoid sharing root credentials.
- 3
Install Docker
Follow the current Docker installation instructions for your operating system.
- 4
Create a project folder
Keep the Compose configuration and environment file in a controlled directory with appropriate permissions.
- 5
Set environment values
Configure your hostname, timezone, encryption key, webhook URL, and other required settings. Keep secrets in a protected environment file.
- 6
Configure Docker Compose
Use a persistent volume and bind the n8n service to a private interface behind a reverse proxy where appropriate.
- 7
Start and inspect n8n
Start the service, check container status and logs, then confirm the instance is reachable as intended.
Configuration checklist
Before starting the container, verify these items against the current n8n documentation for your version:
- Use a supported n8n image tag and update strategy.
- Set the public hostname and HTTPS protocol correctly.
- Set the webhook base URL for your public address. The brief’s technical note calls out
N8N_WEBHOOK_URLfor n8n versions 2.30.0 and later; verify the current variable name and behavior in the official docs before deployment. - Configure proxy hop settings when running behind a reverse proxy.
- Use persistent storage for the n8n data directory.
- Create and securely preserve an encryption key; losing it can affect access to stored credentials.
- Do not expose the application port directly to the public internet when a reverse proxy is intended.
Version-sensitive: environment variables and deployment recommendations can change. Copy the current official Compose example for your n8n version rather than relying on an older tutorial snippet.
Connect a domain to your n8n server
- Create a DNS record for your chosen subdomain pointing to the VPS address.
- Allow time for DNS changes to propagate.
- Confirm the hostname resolves to the expected server before configuring HTTPS.
Keep the hostname consistent across your reverse proxy, n8n host configuration, and public webhook URL.
Configure HTTPS with a reverse proxy
A reverse proxy accepts public HTTPS traffic and forwards it to n8n on a private local port.
Domain resolves
The hostname points to the server where your proxy runs.
Proxy secures traffic
The proxy handles the certificate and forwards requests to n8n.
n8n receives requests
The app listens on a private interface or network behind the proxy.
Caddy is one possible reverse proxy. Install and configure it using current official instructions, set the hostname and upstream, then reload and verify the certificate. Avoid exposing n8n’s internal port publicly.
Test your self-hosted n8n installation
- Open the HTTPS hostname and confirm the login page loads securely.
- Create a small manual workflow and run it.
- Check execution history and container logs for errors.
- Test a webhook using a safe test event and confirm the public URL is correct.
- Restart the container and verify workflows, credentials, and settings persist.
Only connect production credentials after you understand the deployment and have confirmed a backup and recovery path.
Back up self-hosted n8n
Back up the persistent n8n data and any external database or configuration your deployment relies on. Store backups separately from the server and protect them because they may contain sensitive workflow data.
- Schedule backups and monitor whether they complete.
- Protect backup files and encryption keys.
- Keep a copy off the VPS.
- Test restoring to a safe environment.
- Document which versions and settings are needed for recovery.
A backup is only useful if it can be restored. Test recovery before relying on it.
Update your n8n instance
- Read the release notes and check for breaking changes.
- Back up your data and configuration.
- Test the update in a non-production environment when possible.
- Pull the intended image version and recreate the service using your Compose setup.
- Check logs, workflows, credentials, and webhook behavior after updating.
Avoid unplanned updates directly on a critical production instance. Choose a release process you can repeat and roll back if needed.
Common n8n self-hosting problems
n8n will not open
Check DNS, firewall rules, container status, proxy routing, and service logs.
HTTPS certificate fails
Confirm DNS resolution, inbound ports, hostname spelling, and proxy configuration.
Webhook URLs look wrong
Verify public hostname, protocol, proxy settings, and webhook base URL.
Data disappears after restart
Check that the expected persistent volume is mounted and still present.
Container keeps restarting
Inspect logs, environment values, permissions, and available resources.
Workflows run slowly
Review server load, execution volume, database performance, and external service latency.
n8n self-hosting security checklist
Self-hosting means security and maintenance are your responsibility.
Use HTTPS
Secure browser and webhook traffic with a correctly configured certificate.
Keep app ports private
Use firewall and proxy rules so only intended traffic reaches n8n.
Protect SSH
Use secure authentication, restrict access, and keep server packages updated.
Protect encryption keys
Store keys securely and maintain a protected recovery copy.
Patch and monitor
Update Docker and n8n deliberately and watch logs and server health.
Limit credentials
Use least privilege and review public webhook access.
What can you build after self-hosting n8n?
Once your instance is maintained and secured, you can build workflows that connect services, automate business processes, and add AI steps where useful. Start with a small project and monitor how it uses server and provider resources.
Explore our guides to n8n workflow automation, n8n AI automation, building an AI agent with n8n, n8n OpenAI integration, n8n workflow templates, WhatsApp automation, building an n8n AI chatbot, and n8n automation examples.
Frequently asked questions
Is n8n free to self-host?
n8n offers a self-hosted Community Edition, but server, storage, backups, and maintenance can cost money. Check current n8n licensing and plan details.
Can I self-host n8n on a VPS?
Yes, a VPS is a common deployment choice. You are responsible for setup, security, updates, backups, and monitoring.
Can I install n8n without Docker?
Other installation methods may be available. Follow current official installation guidance for your chosen method.
Do I need a domain to self-host n8n?
A domain or subdomain is commonly used for secure public access and webhooks. Local testing can use a different setup.
Can I run n8n on my own computer?
You can run it locally for learning or testing. A personal computer may not be available continuously for production workflows.
Does self-hosted n8n run 24/7?
It can run continuously while the server and services are available and maintained. Plan for restarts, outages, and monitoring.
Is self-hosted n8n secure?
Security depends on your server configuration, access controls, updates, credentials, backups, and monitoring. Self-hosting does not secure itself automatically.
Should I use SQLite or PostgreSQL?
The suitable database depends on workload and deployment requirements. Review current n8n database guidance before choosing.
Can I use AI agents with self-hosted n8n?
You can build AI workflows if your instance and connected providers are configured for them. See the n8n AI agent tutorial.
What if my VPS stops working?
Workflows may stop until the server is restored. Backups, monitoring, and a documented recovery plan help reduce disruption.
Official deployment resources
External documentation is grouped at the bottom; verify it before installing.
- n8n self-hosting documentation
- n8n Docker Compose setup
- n8n environment variables
- n8n security guidance
- Docker Engine installation
- Caddy documentation
Deployment steps and settings can change. Verify the recommended environment variables, proxy configuration, and security requirements for your installed n8n version.
Choose the setup you can maintain
Self-host when you’re ready to own updates, backups, and server security.
