n8n (also known as “node everywhere node”) is an open-source workflow automation platform that gives developers complete control over integrations and data flows. Unlike SaaS alternatives like Zapier, n8n can be hosted on your own infrastructure, unlocking flexibility, privacy, and scalability.
This tutorial provides a beginner-friendly walkthrough for installing and configuring n8n on a self-hosted Ubuntu server using Docker Compose. You’ll also learn how to resolve common setup errors, secure your instance with HTTPS, and avoid pitfalls during production deployment.
By following this guide, you’ll gain a comprehensive understanding of how to deploy, secure, and extend n8n for a wide range of automation scenarios, from simple notifications to advanced, AI-powered workflows.
n8n allows you to connect services and automate workflows using a visual interface. You can integrate APIs, databases, cloud apps, and even custom logic using JavaScript.
To explore how intelligent agents can enhance workflow capabilities, check out our Agentic AI Frameworks Guide.
n8n stands out as a flexible, developer-friendly automation platform with a rich set of features designed to streamline integration and workflow management:
n8n is the perfect addition to any modern backend stack, integrating with other backend components or introducing new ones, performing scheduled job management, data synchronization between systems, DevOps automation, internal tool development, and multi-step business flows integration. It can be flexible and extensible; therefore, it is capable of supporting simple automations, as well as very complex, enterprise-level workflows.
Option | Pros | Cons | Recommended For |
---|---|---|---|
n8n Cloud | No setup, managed infra, scaling | Paid, limited backend control | Non-technical users, quick start |
Self-hosted via Docker | Full control, cost-effective, secure | Requires setup, server maintenance | Developers, teams with infrastructure |
Bare-metal (Node.js) | Maximum flexibility | Manual config and updates | Advanced users, edge use cases |
For most developers and small teams, Docker-based self-hosting on Ubuntu offers the best mix of control and simplicity.
Before starting, ensure you have:
sudo
privilegesYou can install Docker and Docker Compose using:
sudo apt update
sudo apt install docker.io docker-compose -y
Set up a directory for your n8n stack:
mkdir ~/n8n && cd ~/n8n
nano docker-compose.yml
Paste the following minimal setup (PostgreSQL + n8n):
version: '3.7'
services:
db:
image: postgres:14
environment:
- POSTGRES_USER=n8n
- POSTGRES_PASSWORD=n8npass
- POSTGRES_DB=n8n
volumes:
- postgres_data:/var/lib/postgresql/data
n8n:
image: n8nio/n8n
ports:
- "5678:5678"
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=db
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=n8n
- DB_POSTGRESDB_PASSWORD=n8npass
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=strongpass
- N8N_HOST=n8n.yourdomain.com
- WEBHOOK_TUNNEL_URL=https://n8n.yourdomain.com
depends_on:
- db
volumes:
- n8n_data:/home/node/.n8n
volumes:
postgres_data:
n8n_data:
Run the containers:
docker-compose up -d
`*
Open your browser and go to:
http://your_server_ip:5678
Alternatively, use your domain name after DNS and reverse proxy are set up.
Important:
If you access n8n via an IP address or a domain without HTTPS, you may see a browser security warning like this:
This happens because n8n uses secure cookies by default, which require HTTPS.
To resolve:
- Recommended: Use HTTPS with a valid TLS certificate.
- For local development only: Set the environment variable
N8N_SECURE_COOKIE=false
(not safe for production).
We’ll use Nginx and Let’s Encrypt to serve n8n over HTTPS.
sudo apt install nginx certbot python3-certbot-nginx -y
Note:
If you want to use HTTP only (not recommended for production), you can use the following Nginx config to reverse proxy n8n:
server {
listen 80;
server_name n8n.yourdomain.com;
location / {
proxy_pass http://localhost:5678;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
For production environments, it’s strongly advised to use HTTPS.
server {
listen 443 ssl;
server_name n8n.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/n8n.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/n8n.yourdomain.com/privkey.pem;
location / {
proxy_pass http://localhost:5678;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Save it as /etc/nginx/sites-available/n8n
and enable it:
sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d n8n.yourdomain.com
Example of Certbot configuring HTTPS using Nginx for n8n.
Once n8n is running successfully at https://n8n.yourdomain.com
, you will be greeted with a sequence of setup screens before reaching the main workflow dashboard. Here’s what to expect:
The first screen prompts you to create an owner account. You will need to enter:
This step is required to initialize the admin user for your instance.
After account creation, n8n asks a few optional questions to personalize your setup:
These are used to tailor your experience but are not mandatory for functionality.
You are then offered a chance to unlock select paid features (like execution history, advanced debugging, and folder structure) for free by registering your community instance. You’ll need to enter your email address to receive a free license key.
After entering your email, check your inbox for a license key. You’ll receive a unique activation code that can be entered as follows:
Navigate to: Settings → Usage and Plan → Enter Activation Key
Once the key is submitted, your instance will show as Registered, unlocking the advanced features for lifetime use.
These initial steps complete the setup of your n8n interface and unlock functionality needed for production use.
Once your n8n instance is up and running at https://n8n.yourdomain.com
, you’ll be able to create and test your first automation in minutes. Here’s how to do it from the web interface:
Upon visiting your domain, you’ll be prompted to sign up and create your owner account. This replaces the need for hardcoded credentials in Docker.
After logging in, click “New Workflow” from the top bar. This opens the visual editor where you’ll build your automation.
POST
.test-webhook
.message
as the name and "Hello from n8n!"
as the value.Toggle the “Active” switch in the top-right corner to enable the workflow.

*
Use the following curl
command to trigger the workflow:
curl -X POST https://n8n.yourdomain.com/webhook/test-webhook
If successful, you’ll see the message "Hello from n8n!"
in the response, and the execution log will appear in the n8n dashboard.

*
Congratulations, you’ve successfully built your first automated workflow in n8n!
To demonstrate how n8n can be used for real-world automation, here’s a workflow designed to handle server or domain downtime using UptimeRobot monitoring. This setup detects a failure, triggers a shell command to restart services, updates DNS or SSL settings on Cloudflare if needed, and sends real-time alerts.
Monitor a domain/server using UptimeRobot.
On failure detection, restart Nginx or other services via shell command.
Update Cloudflare settings (e.g., SSL toggle, cache purge) if needed.
Notify teams via WhatsApp and Slack.
Await approval or confirmation via Discord.
Loop over the monitors for continued monitoring.
Schedule Trigger
The Schedule Trigger node is responsible for automatically starting the workflow at predefined intervals, such as every 5 or 10 minutes. This ensures that server or domain health checks are performed consistently without manual intervention. By configuring the schedule, you can tailor the frequency of checks to match your operational needs, allowing for rapid detection of outages or issues. This proactive approach helps minimize downtime and ensures that problems are caught early, before they escalate.
Get Monitor (UptimeRobot)
In this step, the workflow uses the UptimeRobot node to connect to the UptimeRobot API and retrieve the current status of all configured monitors. The node fetches real-time data about server or domain uptime, response times, and any detected failures. If UptimeRobot reports that a monitored service is down, the workflow branches into remediation steps. This integration allows for seamless, automated monitoring and ensures that the workflow always acts on the latest available information.
Execute Command
The Execute Command node leverages n8n’s ability to run shell commands directly on your server. When a failure is detected, this node can restart critical services like Nginx, run custom recovery scripts, or perform other administrative tasks needed to restore service. By automating these actions, you reduce the need for manual intervention during incidents, speed up recovery times, and ensure that standard operating procedures are followed consistently every time an issue occurs.
Cloudflare
This node connects to Cloudflare’s API to perform advanced domain management tasks as part of the recovery process. For example, it can toggle SSL settings, update DNS records, or purge the cache to resolve issues related to misconfigurations or propagation delays. Automating these Cloudflare actions within the workflow helps address a wide range of domain-level problems quickly, ensuring that your services remain accessible and secure even during complex incidents.
Send Notifications
The workflow uses parallel nodes to send real-time notifications via Slack and WhatsApp to all relevant team members. These alerts include details about the incident, actions taken, and any next steps required. By notifying teams instantly, you ensure that everyone is aware of the situation and can coordinate their response effectively. This rapid communication reduces confusion, speeds up resolution, and helps maintain transparency during outages or critical events.
Approval Step (Discord)
At this stage, the workflow pauses and sends a message to a designated Discord channel, requesting manual approval from an administrator before proceeding. This step adds a human-in-the-loop safeguard, allowing admins to review the situation, approve further automated actions, or intervene if necessary. It’s especially useful for sensitive operations or when escalation is required, providing an extra layer of control and accountability in the automation process.
Loop Over Items
The final step involves looping over all monitored endpoints or services, repeating the health check and remediation process for each one. This ensures that the workflow can handle multiple servers or domains in a single run, scaling your monitoring and recovery efforts efficiently. By iterating through each item, you maintain comprehensive coverage and can quickly address issues across your entire infrastructure, reducing the risk of unnoticed failures.
This example highlights how n8n enables proactive incident recovery and alerting all without human intervention, unless required. The modular design also lets you extend this logic to include logging, escalation workflows, or integration with external ticketing systems.
To learn how such automation principles extend to intelligent agents, refer to our guide on building autonomous systems.
This workflow demonstrates how n8n can be used as a powerful self-hosted incident automation solution, improving operational resilience and enabling precise, modular responses to service disruptions. For developers interested in combining workflow automation with intelligent systems, see our Agentic AI Frameworks Guide.
Error | Cause | Solution |
---|---|---|
401 Unauthorized | Missing or incorrect basic auth | Double-check N8N_BASIC_AUTH_* settings |
Webhook doesn’t trigger | Domain/DNS misconfigured | Verify WEBHOOK_TUNNEL_URL is reachable |
JavaScript heap out of memory | Insufficient memory for Node.js | Add NODE_OPTIONS=--max-old-space-size=2048 |
Permissions denied for volumes | File system ownership issue | sudo chown -R 1000:1000 ./n8n_data |
SSL not working | Missing cert or DNS not propagated | Wait, retry certbot , and ensure DNS is correct |
Q1: What are the prerequisites for installing n8n on Ubuntu?
To install n8n on Ubuntu, you’ll need an Ubuntu 22.04 (or newer) server with root or sudo privileges, a registered domain name pointed to your server’s IP, and Docker plus Docker Compose installed. It’s also recommended to have an email address for SSL certificate registration (Let’s Encrypt). Make sure your system is up to date and has sufficient resources (at least 2GB RAM for small deployments).
Q2: What’s the best way to install n8n on Ubuntu for production?
The recommended method is using Docker Compose. This approach isolates n8n and its dependencies (like PostgreSQL) in containers, making upgrades, scaling, and backups much easier. Docker Compose also allows you to define environment variables, persistent storage, and restart policies, ensuring your n8n instance is robust and production-ready.
Q3: How do I make my n8n instance on Ubuntu secure with HTTPS?
To secure your n8n instance, set up a reverse proxy (such as Nginx) in front of your n8n Docker container. Use Let’s Encrypt to obtain a free SSL certificate and configure Nginx to forward HTTPS traffic to n8n. This ensures all data between users and your automation platform is encrypted. Additionally, set strong credentials and restrict access to the admin interface.
Q4: Do I need to use a separate database for n8n on Ubuntu?
Yes, for production deployments, it’s strongly recommended to use an external database like PostgreSQL (rather than the default SQLite). This ensures data persistence, reliability, and easier scaling. With Docker Compose, you can run PostgreSQL as a separate service and map its data to a persistent volume for safe backups.
Q5: How can I back up my n8n instance?
Back up both your n8n_data
and postgres_data
Docker volumes regularly. For database-level backups, you can use the following command to dump all PostgreSQL data:
Q6: Can I use n8n with Git for version control?
Yes. While n8n doesn’t offer native Git integration for workflows, you can export workflows as JSON files and commit them to your Git repository. This enables versioning, change tracking, and collaboration across teams. For CI/CD integration, consider using scripts to import/export workflows during deployment.
Q7: How do I upgrade my n8n instance safely?
To upgrade n8n when using Docker Compose, simply pull the latest image with docker-compose pull
and then restart the container using docker-compose up -d
. Before upgrading, back up your Docker volumes (n8n_data
and postgres_data
) to prevent data loss.
Q8: What’s the difference between active and manual executions in n8n?
Active executions are triggered by real-world events (e.g., webhook requests, schedule triggers) when a workflow is “active.” Manual executions occur when you click “Execute Workflow” during development. Active executions run in the background, while manual ones are used for debugging and testing.
Q9: Can I scale n8n for high-volume workflows?
Yes, n8n can be scaled using queue mode. In this setup, a central queue (e.g., Redis) distributes jobs across multiple worker instances. This is ideal for high-concurrency scenarios, such as large-scale data processing or frequent API polling. Check n8n’s documentation for queue mode setup.
Q10: Is it possible to run multiple workflows in parallel?
Yes. n8n supports parallel execution of multiple workflows as long as your server has adequate resources. Each workflow execution is isolated and runs independently, enabling concurrent automation tasks without conflict.
n8n offers developers a powerful, extensible platform for automating workflows from simple email alerts to full-blown backend orchestration. By self-hosting n8n with Docker on Ubuntu, you unlock both control and cost savings.
Set it up once, and you’ll find dozens of use cases across your projects from triggering CI/CD tasks to monitoring webhooks or integrating AI services. You can also explore how agentic workflows power self-directed systems by visiting our Autonomous Systems with Agentic AI guide.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
Building future-ready infrastructure with Linux, Cloud, and DevOps. Full Stack Developer & System Administrator @ DigitalOcean | GitHub Contributor | Passionate about Docker, PostgreSQL, and Open Source | Exploring NLP & AI-TensorFlow | Nailed over 50+ deployments across production environments.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.