Cloud, NPM, Docker, and Docker Compose. Every method explained step by step.
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:
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.
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.
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.
npm install -g 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.
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.
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:
-it runs the container in interactive mode with a terminal attached--rm removes the container when it stops (the data persists in the volume)--name n8n gives the container a recognizable name-p 5678:5678 maps port 5678 on your host to port 5678 in the container-v ~/.n8n:/home/node/.n8n mounts a host directory as a volume so your data persists between container restartsAfter 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.
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.
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 crashesDB_TYPE=postgresdb switches n8n from SQLite to PostgreSQLdepends_on with a health check ensures n8n waits for PostgreSQL to be ready before startingN8N_ENCRYPTION_KEY encrypts stored credentials. Set this once and never change it, or you will lose access to all saved credentialsWEBHOOK_URL must match your public domain so webhook triggers work correctlyn8n_data, postgres_data) persist data independently of the containersdocker 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.
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.
N8N_HOST
The domain or IP address where n8n is accessible. Example: n8n.yourdomain.com. Used for generating correct URLs in the UI and webhook endpoints.
N8N_PORT
The port n8n listens on. Defaults to 5678. Change this if you have port conflicts or want to run on a different port.
N8N_PROTOCOL
Set to https when running behind a reverse proxy with SSL. Defaults to http.
WEBHOOK_URL
The public URL for incoming webhooks. Must include the protocol. Example: https://n8n.yourdomain.com/. If this is not set correctly, webhook triggers will generate URLs that external services cannot reach.
N8N_ENCRYPTION_KEY
A random string used to encrypt stored credentials. Set this once and never change it. If you lose or change this key, all saved credentials become unreadable and you will need to re-enter them. Generate one with openssl rand -hex 32.
DB_TYPE
The database backend. Options: sqlite (default) or postgresdb. Use PostgreSQL for any production deployment.
DB_POSTGRESDB_HOST, DB_POSTGRESDB_PORT, DB_POSTGRESDB_DATABASE, DB_POSTGRESDB_USER, DB_POSTGRESDB_PASSWORD
Connection details for your PostgreSQL database. Only needed when DB_TYPE=postgresdb.
EXECUTIONS_MODE
Set to queue to use Redis-backed queue mode for scaling n8n across multiple instances. Defaults to regular (single instance). Queue mode requires a Redis instance.
N8N_BASIC_AUTH_ACTIVE, N8N_BASIC_AUTH_USER, N8N_BASIC_AUTH_PASSWORD
Legacy basic authentication for the n8n UI. In current versions of n8n, user authentication is built in and these variables are deprecated. Only relevant if you are running an older version.
For the complete list of environment variables, see the official n8n environment variables reference.
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.
These are the problems people run into most often when setting up n8n. Click any issue to expand.
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.npx n8n instead of installing globally. This runs n8n without needing write permissions to global directories.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 logs n8n to see what is happening. Most issues show a clear error message.docker ps to see running containers.node (UID 1000). Make sure the host directory you mount has the correct permissions: sudo chown -R 1000:1000 ~/.n8n.depends_on health check is configured. Without it, n8n may try to connect before PostgreSQL is ready.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 exec -it n8n n8n user-management:reset to execute the reset command inside the running container.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.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.DB_POSTGRESDB_USER, DB_POSTGRESDB_PASSWORD, and DB_POSTGRESDB_DATABASE match what you configured in your PostgreSQL service.postgres), not localhost. Docker networking resolves service names automatically.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.DB_POSTGRESDB_PORT accordingly.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.