If you are building workflow automations, integrations, or internal tools, installing n8n locally is one of the smartest ways to get started.
n8n is a powerful open-source workflow automation platform that gives you full control over your data, infrastructure, and logic. Running it locally lets you experiment freely without vendor limits, cloud costs, or external dependencies.
This guide shows you every practical way to install n8n locally from the fastest npm setup to Docker and Docker Compose for production-like environments. Whether you are on Windows, macOS, or Linux, by the end of this article you will have n8n running locally in a way that actually fits your use case.
Table of Contents
Choose Your Setup (30-Second Decision Guide)
Before jumping into commands, choose the setup that matches what you are trying to do:
Use npm if
- You want the fastest possible local setup
- You are testing workflows or learning n8n
- You do not need persistence or multi-user access
Use Docker if
- You want a clean, isolated environment
- You need workflow and credential persistence
- You want a setup closer to production
Use Docker Compose if
- You want a production-like local environment
- You need authentication, environment variables, and control
- You plan to deploy n8n later to a server or cloud
You can always start simple and move to Docker later.
What is n8n?
n8n is an open-source workflow automation tool that allows you to connect applications, APIs, and services to automate repetitive tasks. It supports hundreds of integrations and gives you full control over execution logic.
Running n8n locally is ideal for:
- Developers prototyping automation logic
- Engineers testing integrations
- Privacy-conscious users
- Teams preparing workflows before production deployment
Unlike hosted tools, local n8n setups give you complete ownership of your data and execution environment.
Prerequisites and Requirements
Before installing n8n locally, make sure your system meets these requirements:
Operating systems
- Windows 10 or 11
- macOS Catalina or newer
- Linux (Ubuntu 18.04+ or equivalent)
Hardware
- Minimum 1 GB RAM (2 GB or more recommended)
- At least 500 MB free disk space
Software
- Node.js v18 or newer (for npm installation)
- npm (included with Node.js)
- Docker (optional but recommended)
Method 1: Install n8n Locally with npm (Fastest)
This is the quickest way to get n8n running on your local machine.
Step 1: Install Node.js and npm
Download the latest LTS version of Node.js (v18+) from the official site: https://nodejs.org
Verify installation:
node -v
npm -v
Step 2: Install n8n Globally
Run the following command:
npm install -g n8n
Step 3: Start n8n
Start n8n with:
n8n
Open your browser and visit:
http://localhost:5678
You should now see the n8n editor interface.
Advantages of npm Installation
- Extremely fast setup
- Easy updates via npm
- Ideal for learning, testing, and quick prototypes
Limitations
- No built-in persistence unless configured
- Not ideal for long-running or shared environments
Method 2: Install n8n Locally with Docker
Docker provides isolation and consistency, making it a safer choice for serious development.
Step 1: Install Docker
- Windows/macOS: https://www.docker.com/products/docker-desktop
- Linux: Follow the official Docker docs for your distro
Step 2: Run n8n in Docker
docker run -it --rm -p 5678:5678 n8nio/n8n
Open:
http://localhost:5678
This command downloads the latest n8n image (if not already cached) and runs it, exposing the UI on port 5678.
Persist Data with Docker (Important)
Without persistence, workflows and credentials will be lost on restart.
Use volume mounting:
docker run -it --rm -p 5678:5678 \
-v ~/.n8n:/home/node/.n8n \
n8nio/n8n
This ensures your data survives container restarts.
Method 3: Install n8n with Docker Compose (Recommended for Serious Use)
Docker Compose is ideal if you want a local environment that closely mirrors production.
Step 1: Create a docker-compose.yml file
Create a file named docker-compose.yml with the following content:
version: "3"
services:
n8n:
image: n8nio/n8n
ports:
- "5678:5678"
volumes:
- ~/.n8n:/home/node/.n8n
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=strongpassword
Step 2: Start n8n
Run the command:
docker-compose up -d
This starts n8n in detached mode.
Step 3: Access and Secure n8n
Visit:
http://localhost:5678
You will be prompted for authentication.
This setup is ideal if you plan to:
- Share access
- Migrate to cloud or VPS later
- Use external databases
OS-Specific Notes
Windows
- Use PowerShell or Command Prompt
- Ensure Node.js paths are added to PATH
- Docker Desktop requires Hyper-V or WSL2
macOS
- Terminal works for all commands
- Node.js can be installed via Homebrew:
brew install node
Linux (Ubuntu)
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
Additional Tips
Here are some additional tips that will help you update n8n and secure the n8n instance when needed.
Updating n8n
- For npm installs:
npm update -g n8n - For Docker installs:
docker pull n8nio/n8n
Securing Your n8n Instance
Enable Basic Authentication to protect your local n8n UI:
export N8N_BASIC_AUTH_ACTIVE=true
export N8N_BASIC_AUTH_USER=admin
export N8N_BASIC_AUTH_PASSWORD=yourpassword
Or set these in Docker Compose environment variables as shown above.
Troubleshooting Common Issues
| Problem | Cause | Solution |
|---|---|---|
n8n command not found | npm global path not in system PATH | Add npm global binaries path to PATH environment variable |
| Port 5678 already in use | Another application using port 5678 | Change n8n port with --port <new_port> or stop the conflicting app |
| Workflows lost after restart | No persistent storage configured | Set up volume mounting to persist data |
| Slow performance or errors | Outdated Node.js or dependencies | Update Node.js and n8n to latest versions |
Frequently Asked Questions
Yes, npm-based install runs n8n directly on Windows with Node.js installed.
Yes, it is safe. For additional security, enable basic auth or firewall rules.
Configure environment variables like DB_TYPE, DB_POSTGRESDB_HOST, etc., to connect n8n to Postgres or MySQL for production-grade persistence.
Yes, by using different ports or containers with isolated volumes.
Conclusion
Installing n8n locally gives you complete control over your workflows, data, and automation logic. Whether you choose npm for speed or Docker for reliability, a local setup lets you experiment safely before committing to production.
For quick testing and learning, npm is enough. For serious development, persistence, and security, Docker or Docker Compose is the better long-term choice.
Once your workflows mature, you can confidently move n8n to a server or cloud environment knowing exactly how it behaves.
If you found this guide useful, feel free to share it with your team or fellow developers and if you are planning a production-grade deployment, you now have the right foundation to build on.






