Sofia Lindström
April 4, 2026
28 min read
n8n has become the most popular open-source workflow automation platform for technical teams, with over 400 integrations and a thriving community of developers building everything from simple data syncs to complex AI-powered pipelines. Whether you want to automate repetitive tasks, connect APIs, or build intelligent agents, this complete n8n tutorial walks you through every step from installation to production deployment. By the end, you will have a fully working automation project that processes webhooks, transforms data, integrates with external services, and runs reliably in a Docker container.
This guide targets n8n 2.x (the latest stable release as of early 2026) and covers self-hosted deployment, the visual workflow editor, code nodes, AI capabilities, and enterprise-grade configurations. If you have ever used Zapier or Make and wanted more power, flexibility, and control over your automations, n8n is the tool you have been looking for.
Don’t miss new tech stories on Google
Add Tech Insider once in the Google app and our stories appear in your news suggestions.
What Is n8n and Why Should You Use It in 2026?
n8n (pronounced “nodemation”) is a fair-code licensed workflow automation platform that lets you connect any app, API, or database through a visual drag-and-drop editor or custom code. Unlike closed- or Make (which limits operations per month), n8n gives you unlimited executions when self-hosted, with full access to the
The platform reached a major milestone with the release of n8n 2.0 in December 2025, introducing enterprise-grade security by default, improved reliability, better scalability, and a modernized AI Agent node with enhanced token management. Version 2.x follows semantic versioning (MAJOR.MINOR.PATCH), with plans for one to two major releases per year going forward.
n8n stands out from its competitors for several reasons. First, it offers a hybrid approach: you can build workflows visually while also writing custom JavaScript or Python in Code nodes when you need advanced logic. Second, it provides over 400 built-in integrations (called nodes), covering everything from Slack and Google Sheets to Postgres, OpenAI, and custom HTTP endpoints. Third, self-hosting means your data never leaves your infrastructure, a critical requirement for enterprises handling sensitive information.
The 2026 automation landscape has shifted dramatically toward AI-driven workflows. n8n responded by upgrading its AI Agent node with better performance, improved token management, and native support for building agentic workflows that chain multiple LLM calls together. The ChatHub feature now supports image explanations and improved markdown rendering in streamed responses. For teams building AI-powered automation, n8n has become the go-to platform because it combines visual workflow design with the flexibility to run custom AI logic at any step.
Prerequisites and System Requirements
Before starting this n8n tutorial, make sure you have the following tools installed and meet the minimum system requirements. n8n 2.x requires a modern runtime environment and adequate resources to handle workflow executions efficiently.
Required Software
Node.js 18.x or higher is required if you plan to install n8nsion 18 is the minimum supported as of n8n 2.x. You can verify your installation by running node –version in your terminal
Docker 24.x or higher is the recommended deployment method for production. Docker provides isolation, easy updates, and consistent environments. If you are on macOS or Windows, install Docker Desktop. On Linux, install Docker Engine directly. Verify with docker --version.
Docker Compose v2.20 or higher is needed for multi-container setups that include n8n, a database, and optionally a reverse proxy. Check your version with docker compose version.
A code editor such as VS Code or Cursor for editing configuration files, writing custom code nodes, and managing your project files.
Git 2.40 or higher for version-controlling your n8n configuration and workflow exports.
System Requirements
For this n8n tutorial, we will use Docker Compose as the primary deployment method because it provides the most consistent experience across platforms and closely mirrors a production setup. If you prefer a quick local start for learning purposes, the npm method works well and we will cover that first.
Step 1: Install n8n Locally
The fastest way to get n8n running for development and learning is through npm. This method takes less than two minutes and gives you immediate access to the full visual workflow editor.
Open your terminal and install n8n globally:
# Install n8n globally via npm
npm install n8n -g
# Verify the installation
n8n --version
# Start n8n
n8n start
After running n8n start, you will see output like this:
n8n ready on 0.0.0.0, port 5678
Version: 2.0.3
Editor is now accessible via:
http://localhost:5678
Open your browser and navigate to http://localhost:5678. The first time you access n8n, it will prompt you to create an owner account with your email and password. This account has full administrative privileges over the instance.
To update n8n to the latest version, run npm update n8n -g. The n8n team releases weekly minor updates with bug fixes and new features, so keeping your installation current is important. However, for production environments, it is wise to wait a few days after a new release to let any edge-case issues surface in the community before upgrading.
Common Pitfall #1: Running npm install n8n -g without proper permissions on Linux may fail. Use sudo or configure npm to use a user-level directory by running npm config set prefix ~/.npm-global and adding ~/.npm-global/bin to your PATH.
Step 2: Deploy n8n with Docker Compose for Production
For any serious deployment, Docker Compose is the recommended approach. It packages n8n with a PostgreSQL database, handles persistent data storage, and makes upgrades straightforward. This setup is what you should use for production workloads where reliability matters.
Create a new project directory and add the following docker-compose.yml file:
# docker-compose.yml — n8n production setup with PostgreSQL
version: "3.8"
services:
postgres:
image: postgres:16-alpine
restart: always
environment:
POSTGRES_USER: n8n
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: n8n
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U n8n"]
interval: 10s
timeout: 5s
retries: 5
n8n:
image: n8nio/n8n:latest
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: ${POSTGRES_PASSWORD}
N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
N8N_HOST: ${N8N_HOST}
N8N_PORT: 5678
N8N_PROTOCOL: https
WEBHOOK_URL: https://${N8N_HOST}/
GENERIC_TIMEZONE: UTC
N8N_DIAGNOSTICS_ENABLED: false
volumes:
- n8n_data:/home/node/.n8n
depends_on:
postgres:
condition: service_healthy
volumes:
postgres_data:
n8n_data:
Create a .env file in the same directory with your secrets:
# .env — n8n environment variables
POSTGRES_PASSWORD=your_secure_password_here
N8N_ENCRYPTION_KEY=your_random_encryption_key_here
N8N_HOST=n8n.yourdomain.com
Generate a secure encryption key with openssl rand -hex 32. This key encrypts all stored credentials in the database, so keep it safe and backed up. Losing this key means losing access to all saved credentials.
Start the stack with docker compose up -d. Docker will pull the PostgreSQL and n8n images, create the volumes, and start both services. Check the logs with docker compose logs -f n8n to verify everything started correctly.
Common Pitfall #2: Forgetting to set N8N_ENCRYPTION_KEY means n8n generates a random one on first start. If you ever recreate the container without that same key, all your saved credentials become unreadable. Always set this explicitly and store it securely.
Common Pitfall #3: Using latest tag in production without pinning a version can cause unexpected breaking changes during upgrades. For production, pin to a specific version like n8nio/n8n:2.0.3 and upgrade deliberately after testing.
Step 3: Navigate the n8n Workflow Editor
Once n8n is running and you have created your owner account, you will land on the workflow dashboard. This is where all your automation workflows are listed, organized, and managed. Understanding the editor interface is essential before building your first workflow in this n8n tutorial.
Click “Add Workflow” to open the visual editor. The canvas is where you design your automation by connecting nodes. Each node represents an action: receiving a webhook, querying a database, calling an API, transforming data, or sending a notification. Nodes connect left-to-right, with data flowing from the output of one node into the input of the next.
The editor consists of four key areas. The canvas is the central workspace where you place and connect nodes. The node panel on the left lets you search and add nodes from the 400+ available integrations. The execution panel at the bottom shows the data flowing through each node during test runs. The settings bar at the top provides workflow-level options like naming, tagging, and activation.
Every workflow starts with a trigger node. Triggers define when the workflow runs: on a schedule (Cron), when a webhook is received, when a file appears in a folder, when a new row is added to a spreadsheet, or when triggered manually. You can only have one trigger per workflow, but n8n supports sub-workflows that let you chain multiple workflows together.
Testing workflows is immediate. Click “Test Workflow” to execute it with sample data. Each node shows its output data in the execution panel, making it easy to debug and verify transformations step by step. This rapid feedback loop is one of the biggest advantages of n8n over code-only automation approaches.
Common Pitfall #4: New users often confuse “Test Workflow” with activating the workflow. Testing runs the workflow once with test data. To make the workflow run automatically (responding to webhooks, scheduled triggers, etc.), you must toggle the “Active” switch in the top-right corner of the editor. Inactive workflows do not respond to triggers.
Step 4: Build Your First Workflow – Webhook to Slack Notification
Let us build a practical workflow that receives datapattern is one of the most common in workflow automation and demonstrates core n8n concepts: triggers, data transformation, and third-party integration
Start by creating a new workflow and adding a Webhook node as the trigger. Configure it with the HTTP method set to POST and the path set to /incoming-alert. The webhook URL will be https://your-n8n-domain.com/webhook/incoming-alert when the workflow is active, or a test URL when running in test mode.
Next, add a Set node to transform the incoming data. Connect it to the Webhook node. In the Set node, define the fields you want to extract and format. For example, map {{ $json.title }} to a field called “alertTitle” and {{ $json.severity }} to “alertSeverity”. The Set node uses n8n’s expression language, which supports JavaScript template literals for dynamic values.
Then add a Slack node and connect it to the Set node. You will need to configure Slack credentials first by creating a Slack app and adding an OAuth token. In the Slack node, select “Send Message” as the operation, choose the target channel, and compose the message using expressions:
// Slack message text using n8n expressions
🔔 *New Alert: {{ $json.alertTitle }}*
Severity: {{ $json.alertSeverity }}
Time: {{ $now.format('yyyy-MM-dd HH:mm:ss') }}
Source: {{ $json.source ?? 'Unknown' }}
View details: {{ $json.url ?? 'No URL provided' }}
Save the workflow and click “Test Workflow.” The Webhook node will provide a test URL. Send a test POST request using curl:
# Test the webhook with curl
curl -X POST https://your-n8n-domain.com/webhook-test/incoming-alert
-H "Content-Type: application/json"
-d '{
"title": "High CPU Usage on prod-api-3",
"severity": "critical",
"source": "Prometheus",
"url": "https://grafana.example.com/d/cpu-alert"
}'
If everything is configured correctly, you will see the Slack message appear in your channel within seconds. The execution panel in n8n will show the data at each step, letting you verify the transformation worked as expected. Once satisfied, activate the workflow to make it respond to real webhook calls.
Common Pitfall #5: Webhook URLs differ between test mode and production mode. The test URL contains /webhook-test/ while the production URL uses /webhook/. If you share the test URL with an external service and then stop testing, the URL stops working. Always share the production URL and keep the workflow active.
Step 5: Work with the Code Node for Custom Logic
While the visual editor handles most scenarios, there are times when you need custom logic that goes beyond what built-in nodes offer. The Code node is n8n’s escape hatch, letting you write JavaScript or Python to transform data, implement business logic, or interact with APIs in ways that no pre-built node supports.
The Code node in n8n 2.x supports both JavaScript (the default) and Python. The JavaScript environment runs in a Node.js sandbox with access to common libraries. The Python environment, upgraded in 2025, supports broader data libraries and is ideal for data processing tasks.
Here is a practical example. Suppose your webhook receives a list of user events and you need to aggregate them by user, calculate totals, and filter out inactive users:
// Code Node — JavaScript
// Aggregate user events and filter active users
const events = $input.all();
const userMap = new Map();
for (const item of events) {
const userId = item.json.userId;
const amount = parseFloat(item.json.amount) || 0;
if (userMap.has(userId)) {
const user = userMap.get(userId);
user.totalAmount += amount;
user.eventCount += 1;
user.lastActivity = item.json.timestamp;
} else {
userMap.set(userId, {
userId,
email: item.json.email,
totalAmount: amount,
eventCount: 1,
lastActivity: item.json.timestamp,
status: item.json.status
});
}
}
// Filter to active users with at least 2 events
const activeUsers = Array.from(userMap.values())
.filter(u => u.status === 'active' && u.eventCount >= 2)
.sort((a, b) => b.totalAmount - a.totalAmount);
return activeUsers.map(user => ({ json: user }));
The Code node receives data through $input.all() (all items from the previous node) or $input.first() (just the first item). It must return an array of objects, each wrapped in { json: {…} } format. This is n8n’s internal data structure, and forgetting the json wrapper is a common
You can also access data from other nodes using $('NodeName').all(), reference workflow-level variables with $vars, and use environment variables with $env. These features let you build sophisticated data pipelines that pull information from multiple sources within a single workflow.
For Python users, switch the Code node language to Python. The syntax differs slightly:
# Code Node — Python
# Process and enrich data with Python
from datetime import datetime
items = []
for item in _input.all():
data = item.json
# Add computed fields
data['processed_at'] = datetime.now().isoformat()
data['amount_usd'] = round(float(data.get('amount', 0)) * 1.0, 2)
data['category'] = 'premium' if data.get('amount_usd', 0) > 100 else 'standard'
items.append({"json": data})
return items
Common Pitfall #6: The Code node runs in a sandboxed environment with limited access to the filesystem and network. You cannot install npm packages or pip packages directly inside the Code node. If you need external libraries, use the HTTP Request node to call an external microservice, or extend n8n with custom nodes (covered in the advanced section).
Step 6: Connect to Databases and External APIs
Real-world automations rarely work in isolation. They need to read from and write to databases, call external APIs, and synchronize data across systems. n8n excels at this with dedicated database nodes and a powerful HTTP Request node that can call any REST API.
n8n includes native nodes for PostgreSQL, MySQL, MongoDB, Redis, Microsoft SQL Server, and SQLite. Each database node supports common operations: select, insert, update, delete, and execute custom queries. For example, connecting to PostgreSQL requires creating a credential with your host, port, database name, user, and password. Once configured, you can run parameterized queries directly in the workflow.
The HTTP Request node is arguably the most versatile node in n8n. It can call any REST API with support for all HTTP methods (GET, POST, PUT, PATCH, DELETE), custom headers, query parameters, request bodies (JSON, form data, binary), and multiple authentication methods including OAuth2, API keys, bearer tokens, and client certificates. The 2025 update enhanced the HTTP Request node with improved authentication flows and modern certificate handling.
A common pattern is building a data synchronization workflow. For example, you might poll a REST API every 5 minutes for new orders, compare them against your PostgreSQL database to find ones you have not processed, transform the data, and insert the new records. This pattern uses a Schedule Trigger, HTTP Request node, PostgreSQL node (select), IF node (to filter), Set node (to transform), and another PostgreSQL node (insert).
Credential management in n8n 2.x is significantly improved. All credentials are encrypted with your N8N_ENCRYPTION_KEY and stored in the database. Enterprise features include dynamic credentials behind license checks, meaning credentials can be rotated programmatically. For teams, credentials can be shared across users with fine-grained access controls, ensuring that workflow builders can use credentials without seeing the actual secrets.
When working with APIs that return paginated results, n8n’s HTTP Request node supports automatic pagination. You can configure it to follow next links in the response, increment page numbers, or use cursor-based pagination until all records are fetched. This eliminates the need for complex looping logic in most cases.
Step 7: Build an AI-Powered Workflow with the AI Agent Node
One of the most exciting features in n8n 2.x is the native AI Agent node, which lets you build intelligent, autonomous workflows that use large language models to make decisions, process natural language, and take actions. The AI capabilities were significantly upgraded in 2025 with better performance, improved token management, and support for tool-calling patterns.
The AI Agent node works by connecting to an LLM provider (OpenAI, Anthropic, Google, or any OpenAI-compatible API) and giving the model access to tools (other n8n nodes) that it can call to complete tasks. This is the same pattern used by frameworks like LangChain, but implemented visually in n8n’s workflow editor.
Let us build a practical AI workflow: an intelligent customer support router that reads incoming support emails, categorizes them by intent, drafts a response, and routes complex issues to the right team. Start with a trigger (Email Trigger or Webhook), then add an AI Agent node configured as follows:
Connect the AI Agent to an OpenAI Chat Model sub-node (or Anthropic Claude, depending on your preference). Set the system prompt to define the agent’s behavior:
You are a customer support triage agent. Analyze the incoming support
request and respond with a JSON object containing:
1. "category": one of ["billing", "technical", "feature_request", "bug_report", "general"]
2. "priority": one of ["low", "medium", "high", "urgent"]
3. "suggested_response": a professional, empathetic draft response (2-3 sentences)
4. "requires_human": boolean indicating if this needs human review
5. "assigned_team": the team to route to based on category
Always be accurate in categorization. When in doubt, set requires_human to true.
After the AI Agent node, add an IF node to branch based on the output. If requires_human is true, route to a Slack notification for the support team. If false, use the suggested response to auto-replyevery interaction for analytics and auditing
The AI Agent node also supports tools, which are sub-workflows or nodes that the AI can invoke. For example, you can give the agent access to a “Lookup Customer” tool that queries your database, a “Check Order Status” tool that calls your API, and a “Create Ticket” tool that opens a support ticket. The AI decides which tools to use based on the incoming request, making the workflow genuinely intelligent rather than just following rigid rules.
The ChatHub feature in n8n provides a built-in chat interface for testing AI workflows. It supports image explanations (send an image and the AI analyzes it), markdown rendering in streamed responses, and conversation history. This makes n8n a viable platform for building internal chatbots and AI assistants without any frontend development.
For teams already using tools like LangChain for RAG chatbots, n8n’s AI Agent provides a visual, no-code alternative that integrates directly with your existing automation workflows. You can combine AI reasoning with deterministic automation steps, giving you the best of both approaches.
Step 8: Error Handling and Workflow Reliability
Production automations must handle failures gracefully. n8n provides several mechanisms for error handling that ensure your workflows are resilient and self-healing. Neglecting error handling is one of the biggest mistakes teams make when moving from development to production.
Every node in n8n has an error output that you can connect to a separate error-handling branch. When a node fails (API timeout, invalid data, authentication error), the error output receives the error details along with the input data that caused the failure. You can use this to send alerts, log errors, retry operations, or queue items for manual review.
The retry on fail option is available on every node. When enabled, n8n automatically retries the node a configurable number of times with a delay between attempts. This handles transient errors like API rate limits or temporary network issues. Set the retry count to 3 with a wait time of 5 seconds for most API calls.
For workflow-level error handling, configure an Error Workflow in the workflow settings. This is a separate workflow that executes whenever any node in the main workflow fails unhandled. The error workflow receives the error details, the node name, the workflow name, and the execution ID, letting you build centralized error monitoring.
A reliable error-handling pattern for production looks like this: each critical node has retry-on-fail enabled (3 retries, 5-second delay). Nodes that interact with external services have their error outputs connected to a “Dead Letter Queue” workflow that stores failed items in a database table. A scheduled workflow runs every hour to retry items in the dead letter queue. A separate error workflow sends Slack notifications for any unhandled failures.
n8n 2.x also introduced improved execution reliability with better database operations, reduced memory usage, and fixes for workflow execution errors that plagued earlier versions. The platform now handles large datasets more efficiently, with optimizations for unpaginated workflow fetching and improved node configurations.
Common Pitfall #7: Not setting up an error workflow means silent failures. Your automation could stop working for days without anyone noticing. Always configure at minimum a Slack or email notification for workflow errors in production.
Step 9: Schedule Workflows and Manage Execution History
Many automations need to run on a schedule rather than in response to events. n8n’s Schedule Trigger node (previously called Cron) lets you configure workflows to run at fixed intervals, specific times, or complex cron patterns. Understanding scheduling and execution management is critical for running reliable automation at scale.
The Schedule Trigger supports several timing modes. Interval mode runs the workflow every N minutes, hours, or days. Cron expression mode accepts standard cron syntax for precise scheduling (for example, 0 9 * * 1-5 runs at 9 AM every weekday). Custom mode lets you set multiple schedules on a single trigger.
Execution history is stored in the database and accessible from the n8n UI. Each execution records the start time, end time, status (success, error, or waiting), and the full data at every node. This history is invaluable for debugging but can consume significant disk space over time. Configure the EXECUTIONS_DATA_MAX_AGE environment variable to automatically prune old execution data (for example, 168 for 7 days).
For workflows that process large volumes of data, consider these optimization strategies. Use the Split In Batches node to process items in chunks rather than all at once, preventing memory exhaustion. Enable manual execution data saving to avoid storing test run data. Set execution timeout to prevent runaway workflows from consuming resources indefinitely.
n8n’s execution model processes items sequentially by default. Each node processes all input items before passing them to the next node. For workflows that need to process items independently (for example, sending an individual API call per item), the Split In Batches node combined with a Wait node can throttle throughput to respect API rate limits.
Monitoring workflow health requires tracking execution success rates over time. Set up a scheduled workflow that queries n8n’s internal API (/api/v1/executions) to calculate success and failure rates, then sends a daily summary to your team. This proactive monitoring catches degradation before it becomes a critical issue.
Step 10: Secure Your n8n Instance for Production
n8n 2.0 introduced security-by-default as a core principle, but there are still several configuration steps you need to take to properly secure a production instance. Security hardening is especially important because n8n often handles credentials and has access to critical systems.
First, always run n8n behind a reverse proxy with TLS termination. Never expose port 5678 directly to the internet. Use Nginx or Caddy as a reverse proxy with a valid SSL certificate (Let’s Encrypt works well). Configure the proxy to forward requests to n8n and set the N8N_PROTOCOL environment variable to https.
Second, enable authentication. n8n 2.x requires authentication by default, but verify that the N8N_BASIC_AUTH_ACTIVE environment variable is not set to false. For teams, configure SSO through OIDC or SAML, which n8n enterprise supports with state and nonce validation. The 2025 updates improved OIDC integration for SSO in multi-main setups.
Third, restrict webhook access. By default, webhooks are publicly accessible. Use the N8N_AUTH_EXCLUDE_ENDPOINTS variable to whitelist specific endpoints while requiring authentication for the rest. For sensitive webhooks, add authentication checks within the workflow itself using an IF node that validates an API key or HMAC signature from the request headers.
Fourth, network isolation. Run n8n in a private network segment where it can only reach the services it needs. Use Docker network policies or cloud security groups to restrict outbound connections. This limits the blast radius if the instance is compromised.
Fifth, disable telemetry if required by your organization. Set N8N_DIAGNOSTICS_ENABLED=false to stop anonymous usage data collection. The 2025 updates improved telemetry transparency, but some organizations require it disabled entirely for compliance.
Sixth, back up regularly. Export all workflows and back up the PostgreSQL database daily. Store backups encrypted in a separate location. The encryption key (N8N_ENCRYPTION_KEY) must be backed up alongside the database, as credentials are useless without it
Complete Working Project: Multi-
Now let us combine everything into a complete working project that demonstrates n8n’s full capabilities. We will build a multi-he results, enriches them with AI, stores the output in PostgreSQL, and sends a daily summary report
This project uses: Schedule Trigger, HTTP Request nodes, Merge node, Code node, AI Agent node, PostgreSQL node, Slack node, and error handling. It represents a realistic production workflow that you can adapt for your own use cases.
The workflow architecture is as follows: A Schedule Trigger fires daily at 8 AM. Three parallel branches each call a different API (GitHub for repository stats, a CRM API for new leads, and a monitoring API for system health). The Merge node combines all three datasets. A Code node normalizes the data into a consistent format. An AI Agent node generates a natural language summary. The results are stored in PostgreSQL and the summary is sent to Slack.
Here is the complete workflow JSON that you can import directly into n8n
{
"name": "Daily Data Aggregator",
"nodes": [
{
"parameters": {
"rule": {
"interval": [{ "field": "cronExpression", "expression": "0 8 * * *" }]
}
},
"name": "Daily 8AM Trigger",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [250, 300]
},
{
"parameters": {
"url": "https://api.github.com/repos/{{ $vars.GITHUB_REPO }}/stats/commit_activity",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"options": { "timeout": 30000 }
},
"name": "Fetch GitHub Stats",
"type": "n8n-nodes-base.httpRequest",
"position": [500, 150]
},
{
"parameters": {
"url": "{{ $vars.CRM_API_URL }}/api/leads?created_after={{ $now.minus(1, 'day').toISO() }}",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth"
},
"name": "Fetch New Leads",
"type": "n8n-nodes-base.httpRequest",
"position": [500, 300]
},
{
"parameters": {
"url": "{{ $vars.MONITORING_API }}/api/v1/health/summary",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth"
},
"name": "Fetch System Health",
"type": "n8n-nodes-base.httpRequest",
"position": [500, 450]
},
{
"parameters": {
"mode": "multiplex"
},
"name": "Merge All Sources",
"type": "n8n-nodes-base.merge",
"position": [750, 300]
},
{
"parameters": {
"jsCode": "const github = $('Fetch GitHub Stats').all();nconst leads = $('Fetch New Leads').all();nconst health = $('Fetch System Health').all();nnreturn [{n json: {n date: $now.format('yyyy-MM-dd'),n github_commits_this_week: github[0]?.json?.total || 0,n new_leads_count: leads.length,n system_uptime: health[0]?.json?.uptime_percent || 'N/A',n critical_alerts: health[0]?.json?.critical_count || 0,n sources_collected: 3,n collected_at: $now.toISO()n }n}];"
},
"name": "Normalize Data",
"type": "n8n-nodes-base.code",
"position": [950, 300]
}
]
}
After importing, you need to configure credentials for each HTTP Request node and set the workflow variables (GITHUB_REPO, CRM_API_URL, MONITORING_API) in Settings → Variables. The workflow uses environment variables for API URLs, making it easy to switch between staging and production environments.
This project demonstrates several production patterns: parallel execution (three API calls run simultaneously), data merging from multiple sources, code-based transformation for normalization, AI-powered summarization, persistent storage, and notification delivery. Each pattern is reusable and can be extracted into sub-workflows for use across your organization.
Troubleshooting Common n8n Issues
Even with careful setup, you will encounter issues when building and running n8n workflows. Here are the most common problems and their solutions, drawn from the n8n community and real-world production deployments.
Issue 1: Webhook not receiving requests. Verify the workflow is active (toggled on). Check that you are using the production URL (/webhook/ not /webhook-test/). Ensure your reverse proxy forwards requests to port 5678 and that the WEBHOOK_URL environment variable matches your public domain. Test with curl from an external machine to rule out firewall issues.
Issue 2: “Credentials not found” error after container restart. This happens when the N8N_ENCRYPTION_KEY changes between restarts. Ensure the key is set explicitly in your Docker Compose or environment file, not auto-generated. If you have already lost the key, you will need to re-enter all credentials manually.
Issue 3: Workflow executions consuming too much memory. Large datasets processed in a single execution can exhaust container memory. Use the Split In Batches node to process items in chunks of 50-100. Increase the container memory limit in Docker Compose. Set EXECUTIONS_DATA_MAX_AGE=168 to auto-prune old execution data.
Issue 4: OAuth2 callback URL mismatch. When configuring OAuth2 credentials (Google, Microsoft, etc.), the callback URL must match exactly. In n8n, the callback URL is https://your-domain.com/rest/oauth2-credential/callback. Set N8N_HOST and N8N_PROTOCOL correctly so n8n generates the right callback URL.
Issue 5: Docker container not starting after upgrade. Breaking changes in major versions (like the 1.x to 2.0 migration) require database migrations. Check the logs with docker compose logs n8n for migration errors. Follow the official migration guide for your specific version jump. Back up the database before any major upgrade.
Issue 6: Scheduled workflows not firing. Verify the workflow is active. Check that the GENERIC_TIMEZONE environment variable is set correctly – cron expressions use this timezone. If running multiple n8n instances (scaling), only one instance should be the main instance handling schedules to prevent duplicate executions.
Issue 7: Code node returning empty results. The most common cause is forgetting to wrap return values in the { json: {...} } structure. Each item in the returned array must be an object with a json property. Also check for JavaScript errors in the browser console – the Code node’s error messages can sometimes be cryptic.
Issue 8: AI Agent node timing out. LLM calls can be slow, especially with large contexts. Increase the node’s timeout setting (default is 60 seconds). Reduce the context size by summarizing input data before sending it to the AI. Use a faster model (like GPT-4o Mini) for classification tasks that do not need the full capabilities of larger models.
Issue 9: PostgreSQL connection pool exhaustion. High-volume workflows can exhaust database connection pools. Add DB_POSTGRESDB_POOL_SIZE=20 to your environment variables to increase the pool. Monitor active connections with SELECT count(*) FROM pg_stat_activity. Consider using PgBouncer as a connection pooler for enterprise deployments.
Issue 10: Workflow editor slow or unresponsive. Workflows with more than 50 nodes can cause the editor to lag. Break large workflows into sub-workflows using the Execute Workflow node. This improves editor performance and makes individual workflows easier to test and maintain.
Advanced Tips for Power Users
Once you have mastered the basics of this n8n tutorial, these advanced techniques will help you build more sophisticated, maintainable, and performant automations.
Use sub-workflows for reusability. The Execute Workflow node lets you call one workflow from another, passing data in and receiving results back. Build a library of utility workflows (send Slack alert, log to database, validate data schema) that any workflow can call. This eliminates duplication and ensures consistent behavior across your automation platform.
Version control your workflows. Export workflows as JSON using the n8n CLI (n8n export:workflow --all --output=workflows/) and commit them to Git. Set up a CI/CD pipeline with GitHub Actions to automatically import updated workflows on deployment. This enables code review for workflow changes and rollback capabilities.
Build custom nodes. If you need an integration that does not exist, n8n lets you create custom nodes using TypeScript. Custom nodes are packaged as npm modules and installed into your n8n instance. This is particularly useful for internal APIs or proprietary systems. The n8n documentation provides a starter template and development tools for custom node creation.
Implement idempotent workflows. In production, workflows might execute twice due to retries or system glitches. Design your workflows to be idempotent – executing the same workflow with the same input twice should produce the same result without side effects. Use database upserts instead of inserts, check for existing records before creating new ones, and include deduplication logic for webhook handlers.
Monitor with external tools. While n8n provides basic execution history, production deployments benefit from external monitoring. Send execution metrics to Grafana or Datadog for dashboards and alerting. Track workflow duration, success rate, and throughput over time. Set up alerts for execution failures, high latency, and resource utilization.
Scale with queue mode. For high-volume deployments, n8n supports a queue mode that separates the web process (serving the UI and webhooks) from worker processes (executing workflows). This lets you scale workers independently based on load. Queue mode requires Redis as a message broker and is essential for enterprise deployments processing thousands of executions per hour.
Use workflow tags and naming conventions. As your n8n instance grows to dozens or hundreds of workflows, organization becomes critical. Establish naming conventions (prefix with team name or function), use tags for categorization (production, staging, utility, monitoring), and document each workflow’s purpose in its description. Future you – and your teammates – will thank you.
n8n Cloud vs Self-Hosted: Which Should You Choose?
n8n offers both a managed cloud service and the self-hosted option we have focused on in this tutorial. Each approach has distinct advantages depending on your team’s needs, technical capabilities, and compliance requirements.
n8n Cloud eliminates operational overhead. You get a managed instance with automatic updates, built-in SSL, daily backups, and scaling handled by the n8n team. Pricing is based on workflow executions, starting with a free tier for personal use. Cloud is ideal for small teams that want to focus on building automations rather than managing infrastructure.
Self-hosted n8n gives you complete control over your data, infrastructure, and configuration. There are no execution limits, no per-task pricing, and no dependency on n8n’s cloud availability. Self-hosting is required when regulations mandate that data stay within your own infrastructure (GDPR, HIPAA, SOC 2). It is also the right choice for teams running high-volume automations where cloud pricing would be prohibitive.
For most developers following this n8n tutorial to learn the platform, starting with n8n Cloud’s free tier or a local npm install makes sense. Once you have validated your use case and built workflows that deliver value, migrate to a self-hosted Docker deployment for production workloads. This approach minimizes upfront investment while giving you a clear upgrade path.
Related Coverage
For more tutorials and comparisons related to workflow automation and the tools discussed in this guide, explore our other in-depth resources:
- How to Get Started with Docker: Complete Beginner Tutorial (2026) – essential for deploying n8n in production.
- How to Master Docker Compose: Complete Tutorial with Multi-Container Apps (2026) – deep dive into the Docker Compose setup used in this guide.
- How to Automate Tasks with Python: Complete Automation Tutorial (2026) – complementary approach to automation using Python scripts.
- How to Build a RAG Chatbot with Python and LangChain: Complete Tutorial (2026) – building AI-powered applications that can integrate with n8n.
- How to Build a CI/CD Pipeline with GitHub Actions: Complete Tutorial (2026) – automate n8n workflow deployments with CI/CD.
- How to Master PostgreSQL 17: Complete Database Tutorial (2026) – the database powering production n8n deployments.
Frequently Asked Questions
Is n8n really free to use?
Yes, self-hosted n8n is free with unlimited workflow executions under the fair-code license. You can run as many workflows and process as many items as your server can handle. Enterprise features like SSO (OIDC/SAML), audit logging, and dynamic credentials require a paid enterprise license. n8n Cloud offers a free tier with limited executions for personal use, with paid plans scaling based on usage.
Can n8n replace Zapier or Make?
For technical teams, absolutely. n8n offers more power, flexibility, and cost efficiency than Zapier or Make. Where Zapier has more pre-built integrations (7,000+ vs 400+), n8n compensates with the HTTP Request node that can call any API, Code nodes for custom logic, and self-hosting for unlimited executions. Teams migrating from Zapier typically find n8n more capable for complex workflows while being significantly cheaper at scale.
What programming languages does n8n support?
The Code node supports JavaScript (running in a Node.js sandbox) and Python. JavaScript is the primary language with full access to n8n’s expression system. Python support was expanded in 2025 with broader data library access and improved performance. For most automation tasks, you do not need any coding – the visual editor and built-in nodes handle the majority of use cases.
How do I back up my n8n workflows?
Use the n8n CLI to export all workflows: n8n export:workflow --all --output=backups/. For credentials, export them separately: n8n export:credentials --all --output=backups/. Back up the PostgreSQL database using pg_dump. Store the N8N_ENCRYPTION_KEY alongside your backups, as encrypted credentials cannot be restored without it. Automate this process with a scheduled n8n workflow or a cron job.
Can I run n8n on a Raspberry Pi or low-powered device?
Yes, n8n can run on ARM devices including the Raspberry Pi 4 (4 GB RAM recommended). Use the Docker ARM image or installoads (a few dozen workflows with moderate execution frequency). For production workloads or AI-powered workflows, a more powerful server is recommended due to the compute requirements of LLM API calls and data processing
How does n8n handle sensitive data and credentials?
All credentials stored in n8n are encrypted at rest using the N8N_ENCRYPTION_KEY with AES-256 encryption. In the UI, credential values are masked and only accessible to users with appropriate permissions. For teams, credentials can be shared without exposing the actual secrets. Enterprise features add audit logging for credential access and dynamic credential rotation. Self-hosting ensures sensitive data never leaves your infrastructure.
What is the maximum number of workflows n8n can handle?
There is no hard limit on the number of workflows. Production instances commonly run hundreds of workflows simultaneously. The practical limit depends on your server resources and execution frequency. A well-configured self-hosted instance with 4 CPU cores, 8 GB RAM, and PostgreSQL can handle 200+ active workflows processing thousands of executions per day. For higher volume, use n8n’s queue mode with multiple worker processes.
Can n8n connect to on-premise systems behind a firewall?
Yes, this is one of the key advantages of self-hosting. Since n8n runs within your infrastructure, it can access on-premise databases, internal APIs, and services behind your firewall without exposing them to the internet. For n8n Cloud, you would need to set up a tunnel (like Cloudflare Tunnel or a VPN) to connect to on-premise resources, which adds complexity and latency.
![Automate 5 Workflows in 30 Min [2026] Automate 5 Workflows in 30 Min [2026]](https://tech-insider.org/wp-content/uploads/2026/04/n8n-tutorial-workflow-automation-complete-guide-2026.webp)