Automation

How to Run n8n Local: Complete Setup Guide (Docker & npm)

Want to run n8n local on your own machine? This guide walks you through everything you need to get a local n8n instance up and running – using Docker or npm – in under 10 minutes.

n8n is a powerful open-source workflow automation tool that connects apps and services without code. Running n8n locally means you keep full control over your data and workflows, with no monthly subscription required.

n8n Local vs. n8n Cloud: Which Should You Choose?

Before setting up n8n locally, it helps to understand the two options:

n8n Cloud is the managed SaaS version. You log in, pay a monthly fee and n8n handles hosting, updates and infrastructure. Convenient, but with ongoing costs and limited data control.

n8n local (also called n8n self-hosted) means you install and run n8n yourself – on your laptop, desktop, or a VPS. Benefits:

  • Full data control: Workflow data, credentials and execution logs stay on your own machine.
  • No usage limits: Unlimited workflows, executions and users – no plan upgrades.
  • Zero cost: Running n8n local on your own machine costs nothing – no server fees, no cloud subscription.
  • Fully customizable: Custom nodes, environment variables, integrations without restrictions.

For developers, freelancers and companies with data privacy requirements, running n8n locally is often the smarter choice.

How to Run n8n Local: Two Methods

There are two ways to run n8n locally: Docker (recommended) and Node.js with npm.

Docker is the most reliable way to run n8n locally because all dependencies are bundled inside a container. Works identically on Windows, Mac and Linux.

Download and install Docker Desktop from the official website first.

Then open your terminal and create a persistent volume so your n8n local data survives container restarts:

docker volume create n8n_data

Linux users: If you see a “permission denied” error, prefix with sudo: sudo docker volume create n8n_data.

Start your n8n local instance:

docker run -it --rm --name n8n -p 5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n

Open http://localhost:5678 in your browser. On first launch you’ll create an owner account – then you’re ready to build workflows.

Keep n8n Local Running with Docker Compose

For a more permanent local setup, use Docker Compose. Create a docker-compose.yml:

version: "3.8"
services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    ports:
      - "5678:5678"
    environment:
      - N8N_HOST=localhost
      - N8N_PORT=5678
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:

Start it with:

docker compose up -d

The -d flag runs n8n in the background. Stop it with docker compose down.

Method 2: Run n8n Local with Node.js (npm)

Use this if you prefer not to install Docker. n8n installs directly via npm.

n8n supports Node.js 18.x, 20.x and 22.x. Download Node.js from the official website, then install n8n globally:

npm install n8n -g

Linux/Mac users: May need sudo: sudo npm install n8n -g.

Start your local n8n instance:

n8n start

n8n is now running at http://localhost:5678. Set up your account and start automating.

n8n Local Configuration: Key Environment Variables

Once n8n is running locally, you can tune its behaviour with environment variables:

VariableDescription
N8N_HOSTHostname of your instance (e.g. n8n.yourdomain.com)
N8N_PORTPort n8n runs on (default: 5678)
N8N_PROTOCOLhttp or https
N8N_ENCRYPTION_KEYKey for encrypting stored credentials
WEBHOOK_URLPublic URL for webhooks (required for server deployments)
EXECUTIONS_DATA_PRUNEAutomatically prune old execution data

For any production setup, configure at least N8N_ENCRYPTION_KEY and WEBHOOK_URL.

From n8n Local to a Live Server

If you want to go beyond running n8n locally and deploy it on a public server, you’ll also need:

  1. A VPS or dedicated server (e.g. Hetzner, DigitalOcean, Contabo)
  2. A domain pointing to your server via DNS
  3. A reverse proxy (nginx or Caddy) for HTTPS
  4. An SSL certificate (e.g. via Let’s Encrypt)

With Docker Compose and Caddy, a production-ready n8n setup is achievable in under an hour.

Conclusion

Both Docker and npm get you a fully working n8n local instance. Docker is the better choice for most people: isolated, stable and easy to manage. npm is the quick alternative for a fast local test.

Running n8n locally gives you full control – over your data, your workflows and your budget.

Want to go beyond a local setup and automate real production processes? As a Full Stack Developer for Workflow Automation I help you build n8n workflows and self-hosted environments that genuinely save time.

Send me a message and let’s talk!

Subscribe to Newsletter

Get updates on new blog posts, tutorials and tips about Flutter, Laravel and more.