Setup Docker Cloud

How To Setup n8n

Cloud, NPM, Docker, and Docker Compose. Every method explained step by step.

Updated Jun 29, 2026 · By Anshul Namdev
3
Methods
2 min
Cloud Setup
Free
Community Ed.
Production Ready
01

Choose Your Method

n8n gives you three installation paths. Each one trades convenience for control. The right choice depends on what you need right now, not what you might need six months from now. You can always migrate later.

n8n Cloud is the managed option. You sign up, and n8n handles the server, SSL, backups, and updates. It takes about two minutes. NPM installs n8n as a global Node.js package on your local machine. It is fast for testing and learning, but not suitable for production. Docker is the standard for production deployments. It gives you isolation, reproducibility, and easy upgrades.

Quick comparison:

  • n8n Cloud – Easiest. Managed hosting, automatic updates, SSL included. Best for beginners and teams.
  • NPM – Fastest to start. Local only. Best for development and learning.
  • Docker – Production standard. Full control. Best for VPS and server deployments.
  • Docker Compose – Docker with PostgreSQL, environment config, and restart policies. The recommended production setup.

If you are brand new to n8n and just want to try it, start with Cloud. If you are a developer who wants to run n8n alongside other tools on your machine, use NPM. If you are deploying n8n for a team or a client, go straight to Docker Compose with PostgreSQL.

02

Method 1: n8n Cloud

n8n Cloud is the fully managed option. You do not install anything, configure any server, or worry about SSL certificates. n8n runs the infrastructure and you build workflows.

Go to app.n8n.cloud, create an account, and your workspace is ready in seconds. The free trial does not require a credit card. Once your trial starts, you get a fully functional n8n instance with a public URL, webhook endpoints, and the complete node library.

What you get with Cloud:

Cloud is best for beginners, solo operators, and teams who do not want to manage infrastructure. The tradeoff is cost: after the free trial, you pay a monthly fee based on your plan tier. For a detailed breakdown of pricing and features across tiers, see our n8n Cloud Plans guide.

Not sure whether Cloud or self-hosted is right for you? Read our Cloud vs. Self-Hosted comparison for a full breakdown of costs, control, and trade-offs.

03

Method 2: NPM (Local Development)

Installing n8n via NPM is the fastest way to get a local instance running. You need Node.js version 18 or higher installed on your machine. Check your version with node -v. If you need to install or update Node.js, use nodejs.org or a version manager like nvm.

Install n8n globally
npm install -g n8n
Start n8n
n8n start

After running n8n start, open your browser and go to http://localhost:5678. You will see the n8n setup screen where you create your owner account. All data is stored locally in ~/.n8n/ by default, including workflows, credentials, and execution logs.

You can also run n8n without installing it globally by using npx:

npx n8n

NPM is not recommended for production. It uses SQLite by default, has no built-in process management, and does not survive server reboots without additional configuration. Use it for local development, testing, and learning. For production, use Docker or Docker Compose.

Good for: local development, learning n8n, testing workflows before deployment, quick prototyping. Not good for: production servers, team environments, anything that needs to stay running 24/7.

04

Method 3: Docker

Docker is the production standard for self-hosted n8n. It gives you an isolated, reproducible environment that you can deploy on any VPS, cloud server, or local machine with Docker installed. Upgrades are as simple as pulling a new image.

Make sure Docker is installed on your machine. You can verify with docker --version. If you need to install it, follow the official instructions at docs.docker.com.

Run n8n with Docker
docker run -it --rm \
  --name n8n \
  -p 5678:5678 \
  -v ~/.n8n:/home/node/.n8n \
  docker.n8n.io/n8nio/n8n

Here is what each flag does:

After running this command, open http://localhost:5678 (or your server IP) in your browser. The volume mount at ~/.n8n ensures your workflows, credentials, and execution history survive container restarts and image upgrades.

For production use, remove the --rm flag and add --restart always so the container restarts automatically after reboots. Better yet, use Docker Compose as described in the next section.

For a complete guide on deploying n8n on a VPS with Docker, including domain setup and SSL, see our VPS Self-Hosting guide.

05

Docker Compose for Production

For any serious deployment, Docker Compose is the recommended approach. It lets you define n8n, its database, and all configuration in a single file. The setup below uses PostgreSQL instead of the default SQLite, which is critical for production. SQLite does not handle concurrent access well, and you will hit scaling limits quickly.

docker-compose.yml
version: "3.8"

services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    container_name: n8n
    restart: always
    ports:
      - "5678:5678"
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=n8n
      - DB_POSTGRESDB_USER=n8n
      - DB_POSTGRESDB_PASSWORD=changeme
      - N8N_HOST=your-domain.com
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://your-domain.com/
      - N8N_ENCRYPTION_KEY=your-random-encryption-key
    volumes:
      - n8n_data:/home/node/.n8n
    depends_on:
      postgres:
        condition: service_healthy

  postgres:
    image: postgres:16
    container_name: n8n-postgres
    restart: always
    environment:
      - POSTGRES_USER=n8n
      - POSTGRES_PASSWORD=changeme
      - POSTGRES_DB=n8n
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U n8n"]
      interval: 10s
      timeout: 5s
      retries: 5

volumes:
  n8n_data:
  postgres_data:

Key sections explained:

  • restart: always ensures both containers restart after server reboots or crashes
  • DB_TYPE=postgresdb switches n8n from SQLite to PostgreSQL
  • depends_on with a health check ensures n8n waits for PostgreSQL to be ready before starting
  • N8N_ENCRYPTION_KEY encrypts stored credentials. Set this once and never change it, or you will lose access to all saved credentials
  • WEBHOOK_URL must match your public domain so webhook triggers work correctly
  • Named volumes (n8n_data, postgres_data) persist data independently of the containers
Start the stack
docker compose up -d

Change the default passwords. Replace changeme with strong, unique passwords before deploying. Generate an encryption key with openssl rand -hex 32. Never commit secrets to version control.

Reverse proxy for SSL: In production, you should place a reverse proxy like Caddy or Nginx in front of n8n to handle SSL termination. Caddy is the easiest option because it provisions Let's Encrypt certificates automatically. Point your domain to your server, add a Caddyfile that reverse-proxies to localhost:5678, and you are done.

06

Environment Variables

n8n is configured almost entirely through environment variables. These are the ones you will use most often. Set them in your docker-compose.yml, your .env file, or your shell environment for NPM installs.

For the complete list of environment variables, see the official n8n environment variables reference.

07

First Steps After Setup

Once n8n is running and you have created your owner account, here is what to do next. These steps apply regardless of which installation method you used.

Create your first workflow. Click the "New Workflow" button, add a Manual Trigger node, connect it to a second node (try the HTTP Request node to fetch data from a public API), and execute it. This gets you familiar with the canvas, the node system, and how data flows between nodes. For a full walkthrough, see our Build Your First Workflow guide.

Set up credentials. Go to Settings → Credentials and add connections for the services you use. Gmail, Slack, Google Sheets, Notion, and similar services all require OAuth2 or API key credentials. n8n encrypts all credentials at rest using your N8N_ENCRYPTION_KEY.

Explore the node library. n8n has 400+ built-in nodes covering everything from databases to AI providers. Open the node panel (click the + button on the canvas) and browse by category. If a service you need is not listed, the HTTP Request node can connect to any REST API.

Enable community nodes. Community nodes are third-party integrations built by the n8n community. Go to Settings → Community Nodes to browse and install them. This unlocks hundreds of additional integrations. For more on the community edition and what it includes, see our Community Edition guide.

08

Troubleshooting Common Issues

These are the problems people run into most often when setting up n8n. Click any issue to expand.

Port 5678 is already in use
  • Cause: Another process is already using port 5678. This could be another n8n instance, a development server, or any other application.
  • Fix: Find what is using the port with lsof -i :5678 (macOS/Linux) or netstat -ano | findstr :5678 (Windows). Kill the process, or run n8n on a different port by setting N8N_PORT=5679 in your environment or passing -p 5679:5678 in your Docker command.
Permission denied on NPM install
  • Cause: Global npm packages require write access to system directories. This is common on macOS and Linux without a Node version manager.
  • Fix (recommended): Use npx n8n instead of installing globally. This runs n8n without needing write permissions to global directories.
  • Fix (alternative): Install Node.js via nvm (Node Version Manager), which installs packages in your home directory. Or use sudo npm install -g n8n if you understand the security implications.
Docker container won't start
  • Check the logs: Run docker logs n8n to see what is happening. Most issues show a clear error message.
  • Port conflict: Make sure port 5678 is not already in use. Use docker ps to see running containers.
  • Volume permissions: The n8n container runs as user node (UID 1000). Make sure the host directory you mount has the correct permissions: sudo chown -R 1000:1000 ~/.n8n.
  • Database not ready: If using Docker Compose with PostgreSQL, make sure the depends_on health check is configured. Without it, n8n may try to connect before PostgreSQL is ready.
Forgot owner account password
  • CLI reset: Run n8n user-management:reset from inside the container or on the host where n8n is installed. This resets the owner account and lets you set a new password on next login.
  • Docker: Run docker exec -it n8n n8n user-management:reset to execute the reset command inside the running container.
Webhook URL not working
  • Cause: The WEBHOOK_URL environment variable is not set or does not match your public domain. n8n generates webhook URLs based on this variable. If it points to localhost, external services cannot reach it.
  • Fix: Set WEBHOOK_URL=https://your-domain.com/ in your environment. Make sure the URL includes the protocol (https://) and a trailing slash. Restart n8n after changing the variable.
  • Also check: Your firewall allows incoming traffic on port 5678 (or your proxy port). Your reverse proxy is correctly forwarding requests. Your DNS points to the right server IP.
Database connection errors (PostgreSQL)
  • Wrong credentials: Double-check that DB_POSTGRESDB_USER, DB_POSTGRESDB_PASSWORD, and DB_POSTGRESDB_DATABASE match what you configured in your PostgreSQL service.
  • Host not reachable: If using Docker Compose, the host should be the service name (postgres), not localhost. Docker networking resolves service names automatically.
  • Database does not exist: Make sure the POSTGRES_DB environment variable on the PostgreSQL container matches DB_POSTGRESDB_DATABASE on the n8n container. PostgreSQL creates the database on first start if POSTGRES_DB is set.
  • Port mismatch: The default PostgreSQL port is 5432. If you changed it, update DB_POSTGRESDB_PORT accordingly.
Σ

The Short Version

For trying n8n: go to app.n8n.cloud and sign up. Two minutes, no credit card. For local development: npx n8n. For production: use the Docker Compose file above with PostgreSQL, set your N8N_ENCRYPTION_KEY and WEBHOOK_URL, put a reverse proxy in front for SSL, and you are production-ready. Everything else is configuration.

Anshul Namdev
Anshul Namdev
AI / Automation Eng.
← Back to Archive