Automation is reshaping the way we work and manage tasks. With the rise of workflow automation tools, even those without coding experience can streamline repetitive tasks and focus on what matters. One standout in this arena is n8n — a powerful, open-source workflow automation platform that is flexible, extensible, and easy to get started with.
This guide will walk you through every step of running n8n: from installation and setting up your first workflow, to running it reliably in production, and securing your instance. Whether you’re a business user, developer, or automation enthusiast, by the end of this article you’ll be ready to automate your daily workflows efficiently.
Prerequisites: What You Need Before Starting
Before we dive in, it’s important to have a few essentials in place:
Node.js and npm
If you prefer to install n8n manually, you’ll need Node.js (version 14 or higher recommended) and npm (Node Package Manager). Node.js enables you to run JavaScript applications on your machine, and npm helps manage the packages.
Why is this important? Installing manually with Node.js gives you direct control over your environment, which is great for development or custom setups. But it also requires you to manage dependencies and updates yourself.
Docker
Docker is a tool that packages software into containers — lightweight, portable environments with everything needed to run your app. Docker is highly recommended for installing n8n because it simplifies deployment, ensures consistency, and makes updates easy.
If Docker isn’t installed on your system yet, you can download it from the official Docker website.
Basic Command Line Knowledge
You’ll need to run a few commands in your terminal or command prompt. Don’t worry if you’re new — this guide provides exact commands you can copy and paste.
Optional: Database (PostgreSQL or MySQL)
For casual or development use, n8n uses SQLite (a file-based database). However, for production environments with multiple users or complex workflows, a proper database like PostgreSQL or MySQL is strongly recommended for reliability and performance.
Installation Options
There are two main ways to install and run n8n: using Docker (recommended) or manual installation with Node.js.
a. Using Docker (Recommended)
Docker makes it straightforward to get started and is the preferred method, especially for production environments.
Benefits of Docker Deployment
- Isolation: Runs n8n in its own environment, avoiding conflicts with other software.
- Portability: Containers can be easily moved between machines or servers.
- Easy Updates: Simply pull the latest Docker image to upgrade.
- Persistence: Mount volumes for saving workflows, credentials, and data outside the container.
- Scalability: Easily integrates with orchestration tools like Kubernetes for large deployments.
Step-by-Step Docker Commands
- Install Docker
- Download and install Docker Desktop from docker.com if you haven’t done so already.
- Pull the n8n Docker image
Open your terminal and run:
docker pull n8nio/n8n
This downloads the official n8n image.
- Run n8n container
docker run -it --rm \
-p 5678:5678 \
-v ~/.n8n:/home/node/.n8n \
n8nio/n8n
Explanation:
p 5678:5678
exposes port 5678 on your local machine.v ~/.n8n:/home/node/.n8n
mounts the.n8n
directory from your home folder to persist data like workflows and credentials.-rm
removes the container when stopped (useful for testing).
- Access the UI
- Open your browser and navigate to http://localhost:5678. You’ll see the n8n Editor UI ready to use.
Using docker-compose for Persistent Setup
For a more robust setup, especially for production, use docker-compose
. Create a file named docker-compose.yml
with the following:
version: '3'
services:
n8n:
image: n8nio/n8n
ports:
-"5678:5678"
volumes:
- ~/.n8n:/home/node/.n8n
restart: always
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=yourpassword
Then run:
docker-compose up -d
Your n8n instance will now run in the background and automatically restart if your machine reboots.
b. Manual Installation (Local with Node.js)
If you prefer running n8n directly on your machine without Docker, follow these steps.
Using npx (Quick Start)
If you don’t want to install n8n globally, you can run it instantly with:
npx n8n
This downloads and runs n8n temporarily.
Cloning the GitHub Repository
For development or if you want to customize:
git clone https://github.com/n8n-io/n8n.git
cd n8n
npm install
npm run build
npm start
Running n8n via CLI
After installation, simply type:
n8n
to start the service.
Setting Environment Variables
You can configure n8n’s behavior by setting environment variables, either in your terminal session or a .env
file.
Examples:
N8N_PORT=5678
— change the default port.N8N_BASIC_AUTH_ACTIVE
— enable basic authentication.
=trueN8N_BASIC_AUTH_USER
and
=adminN8N_BASIC_AUTH_PASSWORD
— set login credentials.
=yourpassword
Accessing the n8n Editor UI
With n8n running, open your browser to:
http://localhost:5678
You’ll see the main interface where you create and manage workflows.
Logging In
By default, n8n does not require a login. For local testing, this is fine. But if your n8n is accessible from the internet, you must secure it.
Enable basic authentication via environment variables or configure a reverse proxy with authentication and HTTPS for security.
Quick UI Tour
- Nodes Panel: Located on the left, showing available triggers, actions, and utilities.
- Canvas: The workspace in the center where you drag and connect nodes.
- Executions: On the right, shows workflow run history and debug info.
- Workflow List: Save, open, and manage your automation workflows.
The UI is designed for ease of use, making it accessible to non-developers while providing power users with advanced options.
Creating Your First Workflow
Let’s build a practical example: send an email notification when a Google Sheet is updated.
Step 1: Add a Google Sheets Trigger
- Click “+” to add a node.
- Select Google Sheets Trigger.
- Authenticate with your Google account.
- Choose the spreadsheet and worksheet to monitor.
- Set trigger to “Watch for changes”.
Step 2: Add an Email Node
- Add a new node, select Email.
- Configure SMTP credentials or use a service like Gmail or SendGrid.
- Set recipient, subject, and email content.
Step 3: Connect the Nodes
- Drag from the output of the Google Sheets node to the input of the Email node.
- This means when the sheet updates, the email node will run.
Step 4: Run and Test the Workflow
- Click Execute Workflow to run a test.
- Update your Google Sheet.
- Confirm the email is received.
Step 5: Save and Activate
- Save your workflow with a descriptive name.
- Activate it so it runs automatically in the background.
Running n8n in the Background
You want your workflows to run continuously without keeping a terminal open.
Using pm2 for Manual Installations
pm2
is a process manager that keeps Node.js apps running in the background.
npm install -g pm2
pm2 start n8n
pm2 save
pm2 startup
This ensures n8n restarts if your machine reboots or the process crashes.
Docker Best Practices
When using Docker, add restart: always
to your container or compose file to restart automatically on failure or reboot.
Cron Workflows
n8n supports time-based workflows using the Cron node:
- Run workflows every minute, hour, day, or custom intervals.
- Great for scheduled reports, data syncs, or cleanup tasks.
Security & Environment Variables
Your n8n instance often holds sensitive credentials and integrates with many services — securing it is critical.
Enable Basic Authentication
Add these environment variables:
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=yourstrongpassword
This protects the editor UI and API.
Use HTTPS
Protect your traffic by running n8n behind a reverse proxy like Nginx or Traefik configured with SSL certificates (Let’s Encrypt is free and popular).
Manage Secrets Carefully
Store API keys, tokens, and passwords in environment variables or Docker secrets instead of hardcoding in workflows.
Hosting and Production Deployment
Once you’re comfortable running n8n locally, you might want to deploy it in a more reliable, scalable, and accessible way. This is especially important if your workflows are business-critical or used by multiple team members.
Hosting Options
Several hosting options exist depending on your needs and budget:
- Virtual Private Server (VPS): Providers like DigitalOcean, Linode, or Vultr give you full control over a Linux server. You can install Docker or Node.js, configure backups, and secure your instance. VPS is ideal for those comfortable with server administration.
- Cloud Platform Services: Platforms like Railway, Render, or Heroku provide simple ways to deploy Docker containers or Node.js apps with minimal server management. They often include automatic SSL, easy scaling, and integrated environment management.
- Managed Kubernetes: If your organization uses Kubernetes, n8n can run as a container inside a cluster for robust scaling and orchestration.
Using Custom Domains
By default, your instance runs on localhost
or an IP address. You can set up a custom domain to access n8n with a friendly URL like https://workflow.yourdomain
.
.com
- Configure DNS records (A or CNAME) pointing your domain to your server IP.
- Use a reverse proxy (Nginx, Traefik) to route domain requests to your n8n service.
- Enable HTTPS with certificates for secure connections.
Backup & Persistence
Workflows, credentials, and execution data are precious — regular backups are essential.
- When using Docker, mount persistent volumes (
v ~/.n8n:/home/node/.n8n
) so data is stored outside containers. - Schedule backups of your
.n8n
directory or database dumps if you’re using PostgreSQL/MySQL. - Test restoring backups regularly to avoid surprises.
Resources & Next Steps
Now that you have your first workflow running, here’s how to deepen your n8n knowledge and make the most of this powerful tool.
Official n8n Documentation
The n8n docs are comprehensive and regularly updated. They cover everything from node references to API usage and advanced configurations.
Community Forum and Support
Join the n8n community forum to ask questions, share workflows, and get support from fellow users and developers.
Marketplace for Templates
Explore the n8n workflow marketplace for pre-built automation templates you can import and customize. This is a great way to accelerate building new workflows.
Building Custom Nodes
If you want to integrate services not supported out of the box, n8n lets you build custom nodes using JavaScript or TypeScript. This unlocks virtually unlimited automation possibilities.
Conclusion
Getting started with n8n is straightforward and empowering. With just a few prerequisites and simple setup steps — especially using Docker — you can have your first automation running in minutes. The intuitive visual interface makes building workflows easy, while the platform’s extensibility ensures it can grow with your needs.
Automation saves time, reduces errors, and connects the disparate apps and services you rely on daily. Whether sending notifications, syncing data, or triggering complex multi-step processes, n8n gives you the control and flexibility you need.
Take advantage of the rich community, explore integrations, and experiment with your own workflows. Soon, you’ll wonder how you ever managed without automation.
Happy automating!