Get in Touch
Back to Documentation

n8n Workflow Automation Guide

Learn how to install and configure n8n for powerful workflow automation. This guide covers installation methods, creating workflows, connecting applications, and best practices for production deployments.

Introduction to n8n

n8n (pronounced "n-eight-n") is a fair-code workflow automation tool that allows you to connect various applications and services to automate tasks. Unlike many automation platforms, n8n is self-hostable, giving you complete control over your data and workflows.

With n8n, you can build workflows that trigger on specific events (like receiving an email or webhook), process data, and perform actions across hundreds of supported applications. The visual workflow editor makes it easy to see how data flows through your automation.

Key Features

  • Self-Hostable: Run n8n on your own infrastructure for complete control
  • 400+ Integrations: Connect with popular services like Slack, Gmail, Airtable, and more
  • Visual Workflow Editor: Build automations with a drag-and-drop interface
  • Custom Functions: Write JavaScript for complex data transformations
  • Error Handling: Built-in retry logic and error workflows
  • Scheduling: Run workflows on a schedule or trigger them manually

Common Use Cases

  • Automated data synchronization between systems
  • Lead processing and customer onboarding
  • Social media management and posting
  • Data migration and transformation
  • Monitoring and alerting systems
  • Report generation and distribution

Prerequisites

Before installing n8n, ensure you have:

  • Node.js: Version 16 or higher (18.10 or higher recommended)
  • npm or pnpm: Package manager for Node.js
  • Docker (optional): For containerized deployment
  • PostgreSQL or MySQL (optional): For production deployments
  • Domain name (optional): For webhook triggers and secure access

System Requirements

  • Minimum 1GB RAM (2GB+ recommended)
  • 1 CPU core minimum (2+ recommended for production)
  • Storage: 10GB minimum for installation and workflow data

Installation

Method 1: Using npx (Quickest)

The fastest way to try n8n is using npx, which doesn't require installation:

npx n8n

This will start n8n on http://localhost:5678. Access this URL in your browser to begin.

Note: Using npx is great for testing, but workflows and credentials are stored in memory. For persistent storage, use one of the installation methods below.

Method 2: npm Global Installation

Install n8n globally on your system:

# Install n8n
npm install n8n -g

# Start n8n
n8n start

Method 3: Docker Installation

Using Docker ensures consistent deployment across environments:

Quick Start

# Pull and run n8n
docker run -it --rm \
  --name n8n \
  -p 5678:5678 \
  -v ~/.n8n:/home/node/.n8n \
  n8nio/n8n

Using Docker Compose

Create a docker-compose.yml file:

version: '3.8'

services:
  n8n:
    image: n8nio/n8n
    restart: unless-stopped
    ports:
      - "5678:5678"
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=changeme
      - N8N_HOST=localhost
      - N8N_PORT=5678
      - N8N_PROTOCOL=http
      - WEBHOOK_URL=http://localhost:5678/
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:

Start the service:

docker compose up -d

Method 4: Production Setup with PostgreSQL

For production environments, use a database for better performance and reliability:

version: '3.8'

services:
  postgres:
    image: postgres:15
    restart: unless-stopped
    environment:
      - POSTGRES_USER=n8n
      - POSTGRES_PASSWORD=secure_password
      - POSTGRES_DB=n8n
    volumes:
      - postgres_data:/var/lib/postgresql/data

  n8n:
    image: n8nio/n8n
    restart: unless-stopped
    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=secure_password
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=changeme
      - N8N_HOST=yourdomain.com
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://yourdomain.com/
    depends_on:
      - postgres
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  postgres_data:
  n8n_data:

Creating Your First Workflow

Once n8n is running, access it at http://localhost:5678 and follow these steps:

Example: Schedule a Daily Report

Step 1: Add a Trigger Node

  1. Click the plus icon to add a new node
  2. Search for and select "Schedule Trigger"
  3. Configure it to run daily at 9:00 AM

Step 2: Add a Data Node

  1. Click the plus icon after the Schedule Trigger
  2. Search for and add an "HTTP Request" node
  3. Configure the node to fetch data from your API
# Example HTTP Request Configuration
Method: GET
URL: https://api.example.com/daily-stats
Authentication: None (or configure as needed)

Step 3: Add an Action Node

  1. Add an "Email" node or "Slack" node
  2. Configure it to send the fetched data
  3. Use expressions to include data from previous nodes

Step 4: Test and Activate

  1. Click "Execute Workflow" to test
  2. Check the output of each node
  3. Once working, toggle "Active" to enable the workflow

Tip: Use the "Sticky Note" node to document your workflows. This helps you and your team understand complex automation logic.

Understanding Nodes

Nodes are the building blocks of n8n workflows. Each node performs a specific task.

Node Types

Trigger Nodes

Trigger nodes start workflow execution. Common triggers include:

  • Webhook: Start workflows via HTTP requests
  • Schedule Trigger: Run workflows on a schedule (cron-based)
  • Manual Trigger: Start workflows manually
  • Email Trigger: Start when emails are received

Action Nodes

Action nodes perform operations like sending emails, creating records, or calling APIs.

Core Nodes

Core nodes provide essential functionality:

  • IF: Conditional branching based on data
  • Set: Modify data structure and values
  • Code: Execute custom JavaScript
  • Split In Batches: Process large datasets in chunks
  • Merge: Combine data from multiple branches

Working with Expressions

n8n uses expressions to reference data from previous nodes:

# Reference data from a previous node
{{ $json["fieldName"] }}

# Use data from the first node
{{ $node["HTTP Request"].json["data"] }}

# Current date
{{ $now }}

# Format date
{{ $now.format("YYYY-MM-DD") }}

Authentication and Credentials

Many nodes require authentication to connect with external services.

Adding Credentials

  1. In any node that requires authentication, click "Create New Credentials"
  2. Select the authentication type (API Key, OAuth2, Basic Auth, etc.)
  3. Enter the required credentials
  4. Test the connection if available
  5. Save the credentials

OAuth2 Authentication

For OAuth2 services, you'll need:

  • Client ID from the service provider
  • Client Secret from the service provider
  • Your n8n instance URL (for the OAuth callback)

Security: Credentials are encrypted and stored in your n8n database. Never share credentials or commit them to version control. Use environment variables for sensitive configuration.

Best Practices

Workflow Design

  • Keep workflows focused on a single purpose
  • Use descriptive names for workflows and nodes
  • Add Sticky Notes to document complex logic
  • Test workflows thoroughly before activating
  • Use the "Set" node to clean up data between operations

Error Handling

  • Enable "Continue on Fail" for non-critical nodes
  • Use the "Error Trigger" node to handle failures
  • Implement retry logic for unreliable services
  • Set up error notifications via email or Slack

Performance

  • Use "Split In Batches" for processing large datasets
  • Limit the number of items processed per execution
  • Schedule resource-intensive workflows during off-peak hours
  • Use database queries instead of fetching all records

Security

  • Always use HTTPS in production
  • Enable basic authentication or use a reverse proxy with authentication
  • Regularly update n8n to get security patches
  • Use environment variables for sensitive configuration
  • Implement webhook authentication for public endpoints

Monitoring

  • Regularly check execution history for failures
  • Set up health check workflows
  • Monitor system resources (CPU, memory, disk)
  • Keep logs for troubleshooting

Troubleshooting

Workflow Not Starting

If a workflow isn't executing:

  • Verify the workflow is marked as "Active"
  • Check the trigger node configuration
  • For webhooks, verify the URL is accessible
  • Review the execution history for error messages

Node Execution Errors

When a node fails:

  • Click the node to view the error details
  • Check the input data format
  • Verify credentials are still valid
  • Test API endpoints independently

Webhook Not Receiving Data

If webhooks aren't triggering:

  • Ensure WEBHOOK_URL is correctly configured
  • Check firewall rules allow incoming connections
  • Verify the webhook URL in the sending service
  • Test with a tool like curl or Postman
# Test webhook with curl
curl -X POST https://your-n8n-instance.com/webhook-test/webhook-id \
  -H "Content-Type: application/json" \
  -d '{"test": "data"}'

Performance Issues

If n8n is running slowly:

  • Check Docker container resource limits
  • Migrate to PostgreSQL if using SQLite
  • Optimize workflows to process fewer items
  • Increase server resources (CPU, RAM)

Getting Help

For additional support: