Installing and configuring n8n: running it locally with desktop mode and npx, choosing a self-hosted option via Docker, Docker Compose, and Kubernetes, getting to know n8n Cloud, as well as setting up the credential store, environment variables, and basic configuration before building workflows.

In episode 2 you understood n8n's architecture: the engine, credential store, database, and worker working behind the scenes. Now it's time to assemble everything on your machine.
This episode covers installation and basic setup — running n8n locally via desktop mode and npx, self-hosted options with Docker, Docker Compose, and Kubernetes, an introduction to n8n Cloud, as well as setting up the credential store, environment variables, and basic configuration. By the end of this episode, your n8n instance is alive and ready to receive your first workflow.
The easiest way to try it right away is to run n8n from Node.js. Since n8n is distributed as an npm package, a single command is enough:
npx n8n@latest startAfter a few seconds, the terminal will show a message that the editor is open at http://localhost:5678. The advantages of this approach: no global install, the version can always be updated, and it's perfect for quick experiments.
An alternative is the n8n desktop app — an application for Windows, macOS, and Linux that you download directly from the official n8n website. The desktop app packages n8n complete with its own runtime, so you don't need to set up Node.js manually. It's the most convenient option if you just want to focus on building workflows without touching the terminal.
For consistent, easily portable self-hosting, Docker is the primary choice. The official n8nio/n8n image already contains the entire runtime, ready to run:
docker run -it --rm -p 5678:5678 n8nio/n8nThe command above maps the container's port 5678 to the host and runs n8n temporarily. But note: without a volume, workflow data is lost when the container stops. For persistence, add a volume that stores n8n data in the ~/.n8n folder on the host.
For a tidy, repeatable setup, use Docker Compose. Create a docker-compose.yml file:
services:
n8n:
image: n8nio/n8n:latest
container_name: n8n
restart: unless-stopped
ports:
- "5678:5678"
environment:
- N8N_ENCRYPTION_KEY=GANTI_DENGAN_KUNCI_PANJANG
- GENERIC_TIMEZONE=Asia/Jakarta
- N8N_HOST=n8n.contoh.com
volumes:
- n8n_data:/home/node/.n8n
volumes:
n8n_data:Then run it with docker compose up -d. The n8n_data volume name keeps data persistent even if the container is deleted. For production with a PostgreSQL database and Redis — including queue mode — we'll put that together in the deployment episode.
Which one to choose? Start with npx or desktop for learning, move to Docker Compose when you need persistence and reproducibility, and consider Kubernetes or Cloud when you reach production stage.
n8n stores all credentials — API keys, OAuth tokens, passwords — in an encrypted credential store. Encryption is locked by an encryption key set via the N8N_ENCRYPTION_KEY environment variable. If this key changes, old credentials can no longer be decrypted — so store it safely and don't lose it.
Credentials are managed centrally in the Settings > Credentials menu and can be reused by many nodes. We'll explore this deeper in the integration and security episodes.
Here are some variables most often configured during setup:
| Variable | Function |
|---|---|
N8N_PORT | HTTP port, default 5678 |
N8N_HOST | Public hostname of the instance |
N8N_ENCRYPTION_KEY | Encryption key for the credential store |
GENERIC_TIMEZONE | Default timezone, e.g. Asia/Jakarta |
DB_TYPE | Database type, default SQLite, can be postgresdb |
All these values are passed via an .env file in Docker Compose or system environment variables — never commit secrets to Git.
Once the instance is running, open http://localhost:5678 in your browser. First steps:
Warning
A default n8n instance is unauthenticated before an owner is created. If port 5678 is exposed to the internet, create an owner account immediately and restrict network access — you don't want an instance open to everyone.
Also make sure the setup is running as expected:
docker compose psThe output shows the n8n container with a running status. Your instance is officially live — time to build your first workflow.
This episode took you from zero to a running n8n instance: running locally via npx or the desktop app, self-hosting with Docker and Docker Compose, understanding the Kubernetes and n8n Cloud options, and setting up a secure credential store and environment variables.
Key takeaways:
N8N_ENCRYPTION_KEY before storing credentials — credentials can't be decrypted without the same key.In the next episode, you'll build your first workflow — a simple workflow with a webhook trigger and an email action, complete with how to save, execute, debug, and read execution history and node output. See you there!