← Back to Blog

Install Self-Hosted n8n: Docker, Node.js & Easy Options Covered

March 27, 2025
Israel Gaudette
Install Self-Hosted n8n: Docker, Node.js & Easy Options Covered

Hey there! πŸ‘‹ Ready to take control of your workflow automation? Let's talk about n8n (pronounced "n-eight-n"). It's a fantastic, flexible tool that lets you connect different apps and services to automate tasks, saving you time and effort. Think of it like a digital assistant that handles repetitive work by linking together the tools you use every day.

While n8n offers a convenient cloud version, you might be here because you're interested in self-hosting. And that's awesome! Self-hosting n8n puts you in the driver's seat. Here’s why it's a great choice:

  • Full Data Control & Privacy: Keep your sensitive workflow data entirely within your own infrastructure. This is super important if you handle confidential information or need to meet strict data regulations.
  • Customization: Want to tweak things? Self-hosting allows for deeper customization, even modifying the source code if you need to.
  • Potential Cost Savings: Especially for heavy users, self-hosting can be more budget-friendly in the long run compared to subscription fees.
  • Flexibility: Easily integrate n8n with internal systems or databases that might be tricky to access from the cloud. You also control when updates happen, avoiding unexpected disruptions.

Feeling motivated? Great! This guide will walk you through various ways to install your own n8n instance. We'll cover simplified options like Cloudron and Coolify for quick setups, as well as the more traditional Docker and Node.js methods for greater control. We'll break down each process step-by-step, so you can choose the path that best suits your technical comfort level and needs. Let's get started!

Pre-Installation Requirements And Considerations

Alright, before we jump into the actual installation, let's lay the groundwork. Planning ahead ensures a smoother setup and helps you choose the right path for your needs.

System Requirements

First things first, let's make sure your server or machine is up to the task.

Hardware Specifications

The resources n8n needs depend on how you use it. Simple workflows need less power than complex ones processing lots of data. Here are some general guidelines:

  • CPU: At least 1-2 vCPUs are recommended. n8n isn't usually CPU-heavy, but more cores help with parallel processing.
  • RAM: A minimum of 1-2 GB is needed, but 4 GB or more is recommended, especially if you plan on running many workflows or handling large datasets/files. Some nodes, like the Code node, can use more memory when processing data.
  • Storage: Plan for at least 20 GB of disk space. SSD storage is preferred for better performance. Keep in mind that workflow execution history and data can add up over time.
  • Network: A stable internet connection is essential for n8n to interact with external APIs and services.

Good to know: Mini PCs can be a cost-effective and energy-efficient option for self-hosting n8n, often consuming less than 10 watts.

Software Dependencies

n8n relies on a few key pieces of software:

  • Operating System: Linux (like Ubuntu, Debian, CentOS), macOS, or Windows. Linux is very common for server deployments.
  • Node.js: n8n is built on Node.js. You'll generally need version 16 or later. Version 18.x LTS or 20.x LTS are often recommended.
  • npm: Node Package Manager usually comes bundled with Node.js. Make sure it's up-to-date.
  • Database: While n8n uses SQLite by default, PostgreSQL is strongly recommended for production environments due to its robustness and scalability. MySQL/MariaDB are also supported, but PostgreSQL is the preferred direction.
  • Git (Optional but Recommended): Useful for managing installations or updates, especially if installing via Node.js directly.
  • Docker (Optional): Required if you choose the Docker installation method.
  • Reverse Proxy (Recommended for Production): Software like Nginx or Apache is highly recommended for handling SSL/HTTPS and making n8n accessible securely.
  • Process Manager (Recommended for Node.js installs): Tools like PM2 or systemd help keep your n8n instance running reliably in the background and automatically restart it if needed.
  • Build Tools (Sometimes Needed): build-essential on Debian/Ubuntu or similar packages might be needed for compiling certain dependencies during installation.
  • Python (Sometimes Needed): Some n8n features or custom nodes might require Python.

Choosing Your Installation Method

You've got options! The best method depends on your technical comfort and specific needs.

Docker vs Node.js Comparison

  • Docker: This is often the recommended method, especially for production.
    • Pros: Easier setup and updates, consistent environment, isolates n8n and its dependencies, simplifies deployment.
    • Cons: Requires Docker knowledge, might have limitations accessing host system resources directly (like GPUs on some setups).
  • Node.js (npm): Installing directly using the Node Package Manager.
    • Pros: Quick setup for testing/development, more direct control over the installation, potentially easier access to host system resources.
    • Cons: Requires manual management of Node.js versions and dependencies, needs additional setup (like process managers) for production reliability.

Database Options

  • SQLite: This is the default database n8n uses. It stores data in a single file (~/.n8n/database.sqlite by default).
    • Pros: Super simple, no extra setup needed. Great for testing or very light usage.
    • Cons: Not recommended for production or heavy workloads as it can lead to performance issues or data corruption under load.
  • PostgreSQL: Strongly recommended for production.
    • Pros: Robust, scalable, reliable, handles concurrent operations well. Preferred by the n8n team and most users.
    • Cons: Requires separate installation and configuration.
  • MySQL / MariaDB: Also supported options.
    • Pros: Widely used, familiar to many developers.
    • Cons: n8n has indicated a potential move towards focusing primarily on PostgreSQL in the future, meaning MySQL support might eventually be deprecated due to resource constraints.

Key Takeaway: For anything beyond basic testing, plan on using PostgreSQL.

Security Considerations

Running your own instance means you're responsible for security. Don't skip these steps!

SSL Certificates

Crucial for encrypting data between your browser and your n8n instance, especially if accessing it over the internet or handling sensitive credentials/data.

  • Recommendation: Use a reverse proxy (like Nginx, Apache, or Traefik) to handle SSL termination. Tools like Certbot can automate getting free Let's Encrypt certificates.
  • Alternative: You can configure n8n to handle SSL directly by providing certificate and key file paths via environment variables (N8N_SSL_CERT, N8N_SSL_KEY), but managing renewals yourself is more complex.
  • Domain: You'll typically need a domain name pointing to your server's IP address to get a standard SSL certificate.

Authentication Setup

By default, a fresh n8n installation might not require login. You absolutely need to secure access.

  • User Management: n8n has built-in user management. The first step after installation is usually creating an owner account.
  • Basic Auth: You can add an extra layer of simple password protection using environment variables (N8N_BASIC_AUTH_ACTIVE, N8N_BASIC_AUTH_USER, N8N_BASIC_AUTH_PASSWORD).
  • OAuth/SSO: For more advanced setups, n8n supports Single Sign-On (SSO) integrations.
  • Webhook Security: Secure your webhook endpoints. n8n allows various authentication methods for webhooks, including header auth and basic auth.
  • Other Measures: Consider firewall rules (e.g., using ufw) to restrict access to necessary ports, using tools like Fail2ban to block malicious IPs, and potentially using security layers like Cloudflare Zero Trust.

Phew! That covers the essential planning. Taking these points into account will set you up for a much smoother installation process. Next up, we'll look at some simplified installation options.

Simplified Installation Options

Okay, now that we've covered the essential planning, let's dive into some of the easier ways to get your n8n instance up and running. These platforms handle a lot of the underlying setup, making them great choices if you prefer a more streamlined approach.

Cloudron Installation Method

Cloudron is a platform designed to make self-hosting web applications incredibly simple. It provides a central dashboard to install, manage, back up, and update apps like n8n with just a few clicks.

Platform Setup

  • First, you need a server with Cloudron installed. Cloudron requires a server (VPS is common) running a specific Linux distribution (like Ubuntu 22.04 x64), with at least 2GB RAM and 20GB disk space. Ports 80 and 443 must be open.
  • You'll also need a domain name. Cloudron uses subdomains for its dashboard (e.g., my.yourdomain.com) and for each installed app (e.g., n8n.yourdomain.com). You'll need to point your domain's A record (and possibly AAAA for IPv6) and a wildcard record (*) to your server's IP address.
  • The Cloudron installation itself involves running a script on your fresh server and following the web-based setup wizard, where you'll configure your domain and create an admin account. Cloudron can often automatically configure DNS records if you use a supported provider.
  • For detailed steps on installing Cloudron itself, refer to the official Cloudron installation documentation.

One-Click Installation Steps

  1. Log in to your Cloudron dashboard (usually at my.yourdomain.com).
  2. Navigate to the "App Store".
  3. Search for "n8n".
  4. Click on the n8n application.
  5. Choose the subdomain you want to use for n8n (e.g., n8n.yourdomain.com).
  6. Click "Install".
  7. Cloudron will handle the installation, database setup (it uses PostgreSQL by default for apps), SSL certificate configuration (using Let's Encrypt), and user integration.

Post-Installation Configuration

  • Cloudron takes care of system-level management: automatic updates for n8n, backups, SSL certificates, and firewall rules.
  • You still need to perform the initial n8n setup: Access your n8n instance at the subdomain you chose (e.g., https://n8n.yourdomain.com). The first time you visit, n8n will guide you through creating the primary owner/admin account.
  • Cloudron integrates user management. You can configure which Cloudron users have access to the n8n app via the Cloudron dashboard.
  • If you need to set custom n8n environment variables (like timezone or enabling specific Node.js modules), you can do this via the File Manager in Cloudron for the n8n app, editing the /app/data/env.sh file and restarting the app.

Coolify Deployment Process

Coolify is an open-source, self-hostable Platform-as-a-Service (PaaS) – think of it like having your own Heroku or Netlify. It simplifies deploying applications, including n8n, often using Docker behind the scenes.

Platform Prerequisites

  • You need a server (VPS, dedicated, or even a local machine) where Coolify itself is installed. Coolify requires a server with SSH access, running a supported Linux distribution (Debian/Ubuntu recommended for the install script), with at least 2 CPU cores, 2 GB RAM, and 30 GB storage. Docker Engine (version 24+) must also be installed on the server where Coolify runs, and on any remote servers you intend to deploy applications to.
  • You'll typically install Coolify using their provided installation script after preparing your server (SSH access, firewall config).
  • After installation, you access the Coolify web UI via your server's IP and port 8000 initially, create an admin account, and ideally configure a domain name for secure HTTPS access (Coolify can manage SSL automatically).
  • You'll also need to add a "Destination" server within Coolify – this is the server where your applications (like n8n) will actually be deployed. This can be the same server Coolify is running on (using the local Docker engine) or a different remote server managed via SSH.

Deployment Steps

  1. Log in to your Coolify dashboard.
  2. Create a "Project" to organize your applications (e.g., "n8n-automation").
  3. Inside your project, click "Add Resource".
  4. Search for "n8n". Coolify often provides templates. You might see options like "n8n" (using SQLite) or "n8n with PostgreSQL" (recommended). Select the one you prefer (PostgreSQL is better for production).
  5. Configure the service:
    • Destination: Choose the server where you want n8n to run.
    • Domain/FQDN: Specify the domain or subdomain you want to use (e.g., n8n.yourdomain.com). Coolify will attempt to set up the reverse proxy and SSL automatically if DNS is pointed correctly.
    • Environment Variables: Add any necessary n8n environment variables here (e.g., WEBHOOK_URL if needed, timezone settings like TZ or GENERIC_TIMEZONE). The template might pre-fill database connection details if you chose the PostgreSQL option.
    • Ports: Ensure the default n8n port (usually 5678) is listed. Coolify's reverse proxy will handle mapping this to standard ports 80/443.
    • Volumes: Check if volumes are configured correctly for persistent data (like the n8n database file if using SQLite, or user data).
  6. Click "Save" and then "Deploy".
  7. Coolify will pull the necessary Docker images, configure the containers, set up networking, and start n8n. You can monitor the deployment logs in the Coolify UI.

Initial Setup

  • Once deployment is successful and the status shows as "Running" or "Healthy", access your n8n instance using the domain you configured (e.g., https://n8n.yourdomain.com).
  • Similar to Cloudron, the first time you access n8n, you'll need to create the owner account.
  • Coolify handles the deployment, reverse proxy, and SSL certificates. You can manage updates, view logs, and monitor resource usage directly from the Coolify dashboard.

Using Cloudron or Coolify significantly lowers the barrier to entry for self-hosting n8n, automating many of the tricky configuration steps. Next, we'll explore the more hands-on Docker method.

Docker Installation Method

Alright, let's roll up our sleeves and get into the Docker method. This is a popular and often recommended way to run n8n, especially for production, because it packages n8n and its dependencies neatly into containers.

Docker Environment Setup

Before we can run n8n in Docker, we need Docker itself!

Docker Installation

  • Docker needs to be installed on your host machine (server, laptop, etc.). The installation process varies depending on your operating system (Linux, macOS, Windows).
  • Linux: You can typically install Docker Engine using your distribution's package manager (like apt for Debian/Ubuntu or yum for CentOS/Fedora) after setting up Docker's official repository.
  • macOS & Windows: The easiest way is usually to install Docker Desktop. It includes Docker Engine, the Docker CLI (Command Line Interface), and Docker Compose. You can download it directly from the Docker website.
  • Post-Installation (Linux): On Linux, you might want to add your user to the docker group to run Docker commands without sudo. You'll need to log out and back in for this change to take effect.
  • Verification: After installation, you can verify it's working by running docker --version and docker compose version (or docker-compose --version for older standalone versions).

Docker Compose Configuration

  • While you can run n8n using just docker run commands, Docker Compose is highly recommended, especially when you need to manage multiple related containers (like n8n and a database). It uses a YAML file (usually docker-compose.yml) to define and configure your application's services, networks, and volumes.
  • Installation: Docker Compose is included with Docker Desktop for Mac and Windows. On Linux, if you installed Docker Engine, you might need to install the Docker Compose plugin separately, often via your package manager (docker-compose-plugin) or by downloading the binary.
  • docker-compose.yml File: You'll create a file named docker-compose.yml in a dedicated project directory. This file tells Docker how to set up and run your n8n service (and potentially a database service).

Here's a basic example docker-compose.yml for n8n using the default SQLite database:

version: '3.7' # Or a newer version like '3.8'

services:
  n8n:
    image: docker.n8n.io/n8nio/n8n:latest # Use the official n8n image
    container_name: n8n
    restart: unless-stopped
    ports:
      - "5678:5678" # Map host port 5678 to container port 5678
    environment:
      - GENERIC_TIMEZONE=Europe/Berlin # Set your timezone
      # Add other environment variables as needed (see below)
    volumes:
      - n8n_data:/home/node/.n8n # Mount a named volume for persistent data
    networks:
      - n8n-network

volumes:
  n8n_data: # Define the named volume

networks:
  n8n-network: # Define the network
    driver: bridge

Container Configuration

Inside the docker-compose.yml, we configure the specifics of the n8n container.

Environment Variables

These are crucial for configuring n8n's behavior. You set them under the environment: key in your docker-compose.yml or in a separate .env file. Key variables include:

  • GENERIC_TIMEZONE and TZ: Set the timezone for n8n and the underlying system (e.g., Europe/London, America/New_York).
  • WEBHOOK_URL: If you're running n8n behind a reverse proxy, set this to your public-facing n8n URL (e.g., https://n8n.yourdomain.com/).
  • Database Configuration (see section 3.3).
  • Authentication (N8N_BASIC_AUTH_ACTIVE, N8N_BASIC_AUTH_USER, N8N_BASIC_AUTH_PASSWORD).
  • Email setup (for user management, password resets, etc.).
  • NODE_FUNCTION_ALLOW_EXTERNAL: To allow specific npm packages in the Code node (e.g., axios, pg).
  • Execution modes (EXECUTIONS_MODE, QUEUE_BULL_REDIS_HOST, etc.) for scaling.
  • Refer to the n8n documentation for a full list of environment variables.
  • Security Tip: For sensitive variables like database passwords, consider using Docker secrets or appending _FILE to the variable name to load it from a file.

Volume Mapping

This is essential for data persistence. Without it, your workflows, credentials, and execution logs will be lost when the container is removed or recreated (e.g., during updates).

  • The line volumes: - n8n_data:/home/node/.n8n maps a Docker named volume called n8n_data to the /home/node/.n8n directory inside the container. This directory is where n8n stores its SQLite database (if used), configuration files, encryption key, and user data.
  • Important: Even if you use an external database like PostgreSQL, you must still mount a volume to /home/node/.n8n to persist the encryption key and other essential user files.
  • You can also mount specific host directories if needed (e.g., - /path/on/host:/files), but named volumes are generally preferred for managing application data within Docker.

Network Settings

  • Creating a dedicated Docker network (n8n-network in the example) is good practice. It improves isolation and allows containers within the same Compose file (like n8n and a database) to easily communicate using their service names (e.g., postgres or db).
  • The ports: - "5678:5678" line maps port 5678 on your host machine to port 5678 inside the n8n container, allowing you to access the n8n UI via http://<your-host-ip>:5678 or http://localhost:5678. If you use a reverse proxy, you might only expose the port to the proxy network or 127.0.0.1.

Database Connectivity

While n8n defaults to SQLite, using a more robust database is highly recommended for production.

Supported Databases

  • PostgreSQL: The strongly recommended database for production due to its reliability and performance. n8n development primarily focuses on PostgreSQL.
  • MySQL / MariaDB: Also supported, but n8n has indicated potential future deprecation.
  • SQLite: Default, suitable only for testing or very light single-user scenarios.

Connection Setup

(PostgreSQL Example)

  1. Add a Database Service: Add a PostgreSQL service to your docker-compose.yml.
  2. Configure n8n Environment Variables: Tell the n8n service how to connect to the database.

Here's an extended docker-compose.yml including a PostgreSQL service:

version: '3.8'

services:
  n8n:
    image: docker.n8n.io/n8nio/n8n:latest
    container_name: n8n
    restart: unless-stopped
    ports:
      - "5678:5678"
    environment:
      - DB_TYPE=postgresdb # Specify PostgreSQL
      - DB_POSTGRESDB_HOST=postgres # Service name of the DB container
      - DB_POSTGRESDB_PORT=5432 # Default PostgreSQL port
      - DB_POSTGRESDB_DATABASE=${POSTGRES_DB} # Use variables from .env or define here
      - DB_POSTGRESDB_USER=${POSTGRES_USER} # Use variables from .env or define here
      - DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD} # Use variables from .env or define here
      # - DB_POSTGRESDB_SCHEMA=public # Optional: specify schema if not 'public'
      - GENERIC_TIMEZONE=Europe/Berlin
      # Add other n8n variables as needed
    volumes:
      - n8n_data:/home/node/.n8n # Still required!
    networks:
      - n8n-network
    depends_on: # Wait for the database to be healthy before starting n8n
      postgres:
        condition: service_healthy

  postgres:
    image: postgres:15 # Or another supported version like 11, 12, 16
    container_name: postgres
    restart: unless-stopped
    environment:
      - POSTGRES_USER=${POSTGRES_USER} # Define in .env or here
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} # Define in .env or here
      - POSTGRES_DB=${POSTGRES_DB} # Define in .env or here
      # - POSTGRES_NON_ROOT_USER=${POSTGRES_NON_ROOT_USER} # Optional: for non-root DB access
      # - POSTGRES_NON_ROOT_PASSWORD=${POSTGRES_NON_ROOT_PASSWORD} # Optional
    volumes:
      - postgres_data:/var/lib/postgresql/data # Persist database data
    networks:
      - n8n-network
    healthcheck: # Check if the database is ready
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
      interval: 5s
      timeout: 5s
      retries: 10

volumes:
  n8n_data:
  postgres_data: # Define volume for PostgreSQL data

networks:
  n8n-network:
    driver: bridge

  • .env File: It's best practice to define sensitive values like database credentials (POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB) in a separate .env file in the same directory as your docker-compose.yml. Docker Compose automatically loads variables from this file.
    # .env file example
    POSTGRES_USER=n8nuser
    POSTGRES_PASSWORD=a_very_strong_password
    POSTGRES_DB=n8ndb
    
  • Initialization: When n8n starts and connects to the specified database, it will automatically create the necessary tables if they don't exist.

To start your n8n instance using Docker Compose, navigate to the directory containing your docker-compose.yml (and .env file) in your terminal and run:

docker compose up -d

The -d flag runs the containers in detached mode (in the background). You can then access n8n at http://localhost:5678 (or your server's IP/domain).

That covers the Docker installation! It offers a robust and manageable way to run n8n. Next, we'll look at the Node.js method.

Node.js Installation Method

Moving on from Docker, let's explore installing n8n directly using Node.js and its package manager, npm (or pnpm, which is often used in development contexts). This method gives you direct control over the installation but requires a bit more manual setup, especially for production use.

Node.js Setup

First, you need the foundation: Node.js and npm.

Version Requirements

  • n8n requires Node.js to run. Generally, Long Term Support (LTS) versions are recommended.
  • As of early 2025, you'll typically need Node.js version 18.x or 20.x. Some sources mention version 16 or later is the minimum, while development might require version 20.15 or newer. Sticking to an active LTS version (like 18 or 20) is usually the safest bet for stability and compatibility.
  • You can check your installed Node.js version by running node -v in your terminal.

NPM Configuration

  • NPM (Node Package Manager) usually comes bundled with Node.js. You can check its version with npm -v.
  • It's generally a good idea to keep npm updated: npm install -g npm@latest.
  • For development, n8n's repository uses pnpm, another package manager. If you plan on contributing or working directly with the source code, you might need pnpm as well.
  • Installation:
    • Linux: You can often install Node.js using a package manager (like apt for Debian/Ubuntu). Using NodeSource repositories is a common way to get specific versions. For example, for version 18.x on Debian/Ubuntu:
      curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
      sudo apt-get install -y nodejs
      
      Alternatively, using a version manager like NVM (Node Version Manager) is highly recommended. It allows you to easily install and switch between different Node.js versions without conflicts.
    • macOS/Windows: The easiest way is often to download the installer directly from the official Node.js website (nodejs.org). Using NVM (or NVM for Windows) is also a great option here. Homebrew on macOS is another popular method (brew install node).

n8n Installation Steps

You can install the n8n package either globally on your system or locally within a specific project directory.

Global Installation

  • This makes the n8n command available system-wide. It's often simpler for getting started quickly.
  • Command: npm install -g n8n (You might need sudo on Linux/macOS depending on your npm setup).
  • To run n8n after global installation, simply type n8n or n8n start in your terminal.

Project-Specific Installation

(using npx or local install)

  • Using npx: This is a quick way to run n8n without installing it globally or locally. npx downloads the package temporarily (if not already cached) and executes it.

    • Command: npx n8n
    • This is great for trying n8n out or running one-off instances. Data is still stored in ~/.n8n by default.
  • Local Installation: Install n8n as a dependency within a specific project folder. This is good practice for isolating dependencies if you're integrating n8n into a larger Node.js project.

    • Navigate to your project folder: cd /path/to/your/project
    • Initialize the project (if needed): npm init -y
    • Install n8n locally: npm install n8n (or npm install --save-dev n8n)
    • To run n8n installed locally, you'd use npx n8n from within the project directory or run the executable directly: ./node_modules/.bin/n8n.
  • Choosing Between Global and Local:

    • Global: Easier to start, command available everywhere. Updates require npm update -g n8n. Might lead to version conflicts if other global tools require different Node.js versions.
    • Local/npx: Better for project isolation, avoids potential global conflicts. npx n8n always uses the latest version (or the one specified).

Environment Configuration

Just like with Docker, you need to configure n8n using environment variables. How you set them depends on your operating system and how you run n8n.

Variable Setup

  • Linux/macOS (Temporary): You can set variables directly in your terminal before running n8n. These only last for the current session.
    export GENERIC_TIMEZONE="Europe/Berlin"
    export DB_TYPE="postgresdb"
    # ... other variables
    n8n # or pm2 start n8n
    
  • Linux/macOS (Permanent): Add the export lines to your shell profile file (like ~/.bashrc, ~/.zshrc, or ~/.profile) and then reload your shell or log out/in.
  • Windows (Command Prompt): set VARIABLE_NAME=value
  • Windows (PowerShell): $env:VARIABLE_NAME="value"
  • Windows (Permanent): Use the System Properties dialog ('Environment Variables' button).
  • .env Files: A common practice, especially for development or when using process managers like PM2, is to use a .env file in your n8n project directory to store variables. Tools like dotenv can load these, or PM2 can load them via its configuration file.
  • PM2 Ecosystem File: If using PM2 (highly recommended for production), you can define environment variables directly within its configuration file (often ecosystem.config.js).
    // ecosystem.config.js example
    module.exports = {
      apps : [{
        name   : "n8n",
        script : "/path/to/n8n/binary/if/needed/or/just/n8n", // Adjust if needed
        env: {
          "NODE_ENV": "production",
          "GENERIC_TIMEZONE": "Asia/Kolkata",
          "WEBHOOK_URL": "https://n8n.yourdomain.com/",
          "DB_TYPE": "postgresdb",
          // ... other DB vars
          // ... other n8n vars
        }
      }]
    }
    
    You'd then start n8n using pm2 start ecosystem.config.js.

Path Configuration

  • Data Folder: By default, n8n stores user data (credentials, workflows if using SQLite, encryption key) in a hidden folder named .n8n within the user's home directory (e.g., /home/username/.n8n on Linux, C:\Users\username\.n8n on Windows).
  • Changing the Data Folder: You can change this location by setting the N8N_USER_FOLDER environment variable to your desired path.
    export N8N_USER_FOLDER="/path/to/my/n8n-data"
    n8n
    
  • Custom Nodes Folder: When installing custom nodes manually (not via Community Nodes), they often go into a custom subfolder within the .n8n directory (e.g., ~/.n8n/custom).

Important for Production: If you install n8n using npm for a production environment, simply running n8n in the terminal is not enough. If the terminal closes or the server reboots, n8n will stop. You must use a process manager like PM2 or systemd to:

  • Keep n8n running in the background.
  • Automatically restart n8n if it crashes.
  • Manage logs.
  • Enable startup on system boot.

To install PM2: npm install -g pm2 To start n8n with PM2: pm2 start n8n (if installed globally) or use an ecosystem.config.js file. To make PM2 start on boot: pm2 startup (follow the instructions it provides).

This Node.js method offers flexibility but requires careful management, especially regarding process supervision and environment setup for reliable operation. Next, we'll cover essential post-installation steps regardless of the method you chose.

Post-Installation Setup

Fantastic! You've successfully installed n8n using one of the methods we discussed. But we're not quite done yet. These final steps are crucial for securing your instance, ensuring it works correctly, and making it accessible.

Initial Configuration

Once n8n is running, the first thing you need to do is access its web interface. If you installed locally (Docker or Node.js without a reverse proxy yet), this is usually http://localhost:5678 or http://<your-server-ip>:5678. If you used Cloudron, Coolify, or already set up a reverse proxy with a domain, use the URL you configured (e.g., https://n8n.yourdomain.com).

Admin Account Creation

  • The very first time you access your new n8n instance, it will prompt you to create an owner account. This is the primary administrative account for your n8n setup.
  • Follow the on-screen instructions: You'll typically need to provide your name, email address, and set a strong password.
  • Do not skip this step! Securing your n8n instance starts here. Once the owner account is created, anonymous access is disabled.
  • After creating the owner account, you can invite other users if needed (depending on your n8n license/setup).

Webhook Setup

(Crucial!)

  • Webhooks are URLs that n8n uses to receive data from external services (e.g., when a form is submitted or a payment is processed). For these to work correctly, especially when n8n is running behind a reverse proxy or in Docker, n8n needs to know its publicly accessible URL.
  • This is configured using the WEBHOOK_URL environment variable.
  • Set this variable (in your .env file, docker-compose.yml, PM2 config, Cloudron/Coolify settings, etc.) to the full base URL where your n8n instance can be reached from the internet.
  • Example: WEBHOOK_URL=https://n8n.yourdomain.com/
  • If you don't set this correctly, trigger nodes that rely on webhooks (like the Webhook node itself, GitHub trigger, Stripe trigger, etc.) will likely fail because they will generate URLs based on the internal container hostname or localhost, which external services cannot reach.
  • After setting or changing this variable, you'll need to restart n8n.

SSL Implementation

Running n8n over plain HTTP is insecure. Any data exchanged, including credentials within your workflows, could be intercepted. Setting up HTTPS (HTTP Secure) using SSL/TLS certificates is essential.

Certificate Installation

(Recommended: Reverse Proxy)

  • The most common and recommended approach is to use a reverse proxy like Nginx, Apache, Caddy, or Traefik.
  • How it works:
    1. The reverse proxy runs on your server, listening on the standard HTTPS port 443.
    2. It handles the incoming HTTPS connection from the user's browser.
    3. It manages the SSL/TLS certificate (obtaining and renewing it, often using Let's Encrypt).
    4. It decrypts the HTTPS traffic.
    5. It forwards the decrypted HTTP traffic to the n8n service running locally (e.g., on localhost:5678).
  • Setup Steps (General - using Nginx as an example):
    1. Install the reverse proxy software (e.g., sudo apt install nginx).
    2. Obtain an SSL certificate. Certbot is a popular tool that automates getting free certificates from Let's Encrypt. You typically run Certbot after setting up your domain's DNS A record to point to your server's IP. Certbot can often automatically configure Nginx/Apache for you.
    3. Configure the reverse proxy to listen for your domain (e.g., n8n.yourdomain.com), handle the SSL certificate, and proxy requests to http://localhost:5678 (or wherever your n8n instance is listening).
  • Benefits: Centralizes SSL management, simplifies n8n configuration (n8n itself doesn't need to handle SSL), allows hosting multiple services on the same server/IP.
  • Cloudron/Coolify: These platforms usually handle the reverse proxy and SSL setup automatically when you deploy n8n through them.
  • Traefik/Caddy: These are modern reverse proxies often used with Docker, known for their automatic service discovery and SSL management capabilities.

HTTPS Configuration

(Alternative: n8n Built-in SSL)

  • n8n can handle HTTPS directly, but it's generally less flexible and requires manual certificate management.
  • You need to provide the path to your SSL certificate and private key files using environment variables:
    • N8N_SSL_CERT: Path to your certificate file (e.g., /path/to/fullchain.pem).
    • N8N_SSL_KEY: Path to your private key file (e.g., /path/to/privkey.pem).
    • N8N_PROTOCOL=https
  • You would need to obtain these certificate files yourself and ensure they are accessible within the n8n environment (e.g., mounted into the Docker container). You'd also be responsible for renewing them manually.

Tunnel Service Setup

What if you're running n8n on your local machine (e.g., for development or testing) and need to receive webhooks from external services, or share access temporarily? A direct public IP and domain setup might not be feasible. This is where tunnel services come in handy.

Options Available

These services create a secure tunnel from a public URL to your local machine, effectively exposing your local n8n instance to the internet. Popular choices include:

  • ngrok: Very popular, easy to use, offers free and paid plans.
  • Cloudflare Tunnel (formerly Argo Tunnel): A robust and free option from Cloudflare, integrates well if you use Cloudflare for DNS.
  • localtunnel: An open-source alternative.
  • Tailscale Funnel: Part of the Tailscale VPN service, allows exposing ports on your Tailscale nodes.
  • Others: There are many other services like inlets, SirTunnel, etc.

Configuration Steps

(General - using ngrok as an example)

  1. Sign Up & Install: Create an account with the tunnel service (e.g., ngrok). Download and install their client software on the machine running n8n.
  2. Authenticate: Connect your client to your account, usually by adding an authentication token (e.g., ngrok config add-authtoken <your_token>).
  3. Start the Tunnel: Run a command to start the tunnel, pointing it to the local port where n8n is running (usually 5678).
    ngrok http 5678
    
  4. Get the Public URL: The service will provide you with a public URL (e.g., https://random-subdomain.ngrok-free.app). This URL now forwards traffic to your local http://localhost:5678.
  5. Configure n8n: Crucially, you must set the WEBHOOK_URL environment variable in your n8n configuration to this public tunnel URL (e.g., WEBHOOK_URL=https://random-subdomain.ngrok-free.app/) and restart n8n. This ensures webhook registrations use the correct, publicly accessible address.
  • Note: Free tiers of services like ngrok often provide a random URL that changes each time you restart the tunnel. Paid plans usually offer stable subdomains. Cloudflare Tunnel typically provides a stable subdomain linked to your Cloudflare account.

Completing these post-installation steps ensures your n8n instance is secure, functional, and ready to start automating! Next, let's tackle some frequently asked questions.

Frequently Asked Questions

Let's tackle some common questions you might have about self-hosting n8n.

  • Is n8n completely free when self-hosted? Mostly, yes! The core n8n software is available under a "fair-code" license (specifically, the Sustainable Use License). This means you can download, install, use, modify, and even redistribute the self-hosted version for free for your own internal business purposes or for non-commercial/personal use. You cannot directly resell n8n as a service or embed it into a paid product where its value substantially depends on n8n, without a separate commercial license. Some advanced features might also require a paid license or registration, but the core functionality for typical self-hosting is free.

  • Can I migrate from cloud-hosted to self-hosted n8n? Yes, but it's primarily a manual process. You can export/import workflows (as JSON), but credentials need to be recreated manually in the self-hosted instance. Execution history and user accounts cannot be directly migrated.

  • What database should I use for production deployment? PostgreSQL is the strongly recommended database for production due to its robustness and scalability. SQLite (the default) is only suitable for testing or very light use. MySQL/MariaDB are supported but might be deprecated in the future.

  • How do I backup my self-hosted n8n instance? A good backup strategy includes:

    1. Regularly backing up your database (e.g., using pg_dump for PostgreSQL).
    2. Backing up the n8n data directory (.n8n folder or the corresponding Docker volume), which contains the crucial encryption.key and other configuration files.
    3. Optionally exporting workflows/credentials via the n8n CLI as a supplement.
    4. Backing up configuration files (docker-compose.yml, .env, etc.).
    5. Storing backups off-site.
    6. Automating the process.
    7. Considering full server snapshots if using a VPS provider.
  • What are the minimum server requirements for running n8n? Requirements depend on workload, but a reasonable starting point is:

    • CPU: 1-2 vCPUs
    • RAM: 4 GB or more recommended (minimum 1-2 GB)
    • Storage: 20 GB+ SSD recommended
    • Network: Stable internet connection

Conclusion

And there you have it! We've journeyed through the various ways you can bring the power of n8n into your own infrastructure. From the simplified, near-automatic setups offered by platforms like Cloudron and Coolify, to the more hands-on but highly flexible Docker and Node.js methods, there's a path suitable for different needs and technical comfort levels.

Choosing the right approach is key. If you're new to self-hosting or prefer a managed experience where installation, updates, backups, and SSL are handled for you, Cloudron or Coolify are excellent choices and often the preferred method for beginners. They significantly lower the barrier to entry. For those who need more granular control or are comfortable managing server environments and containers, the Docker method provides a robust and scalable solution, while the Node.js approach offers direct interaction with the n8n process.

Regardless of the installation path you choose, remember those crucial post-installation steps:

  • Create the owner account immediately upon first access.
  • Set the WEBHOOK_URL environment variable correctly to your public-facing n8n address.
  • Implement SSL/HTTPS, ideally using a reverse proxy, to secure your instance.

By carefully considering your requirements and following the steps outlined, you're well on your way to running a successful self-hosted n8n deployment. Enjoy the freedom, control, and automation possibilities that come with having n8n running in your own environment! Happy automating! ✨