> This is part 1 of 15 of the full documentation (pages 1–100 of 1414).
> The content is paginated: fetch every part to see all of it.
> Next part: https://docs.n8n.io/llms-full.txt/1
> Page index: https://docs.n8n.io/llms.txt

# n8n Docs

Get set up on n8n, build your first workflow, and find inspiration for what to automate.

n8n is a fair-code licensed workflow automation tool that combines AI features with business process automation.

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-cover data-type="image">Cover image</th></tr></thead><tbody><tr><td><i class="fa-server">:server:</i> <strong>Get set up on n8n</strong></td><td><ul><li><a data-mention href="/deploy/use-n8n-cloud/start-your-free-trial">Try free then choose a plan</a></li><li><a data-mention href="/deploy/host-n8n/install-options/one-line-setup">One-line setup</a></li><li><a data-mention href="/deploy/host-n8n/install-options/install-using-docker-compose">Install using Docker Compose</a></li><li><a data-mention href="/deploy/host-n8n/install-options/use-a-cloud-provider">Use a cloud provider</a></li></ul></td><td></td><td><a href="https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-252f2c2b322104dd9b57b662049a6162b7094c3c%2Fstart.png?alt=media">start.png</a></td></tr><tr><td><i class="fa-draw-square">:draw-square:</i> <strong>Build your first workflow</strong></td><td><a data-mention href="/build-your-first-workflow">Build your first workflow</a></td><td></td><td><a href="https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-2422efb1618db051a64e2eaf9558228fdc6da5d4%2Fbuild.png?alt=media">build.png</a></td></tr><tr><td><i class="fa-stamp">:stamp:</i> <strong>Get inspiration for what to automate</strong></td><td><ul><li><a href="https://n8n.io/workflows/1750-creating-an-api-endpoint/">Creating an API endpoint</a></li><li><a href="https://n8n.io/workflows/1954-ai-agent-chat/">AI agent chat</a></li><li><a href="https://n8n.io/workflows/1951-scrape-and-summarize-webpages-with-ai/">Scrape and summarize web pages with AI</a></li><li><a href="https://n8n.io/workflows/1747-joining-different-datasets/">Joining different datasets</a></li></ul></td><td></td><td><a href="https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-46ac2996f03e642961eb3a3005c5ebd7fa7b7944%2Finspire.png?alt=media">inspire.png</a></td></tr><tr><td><i class="fa-lightbulb-gear">:lightbulb-gear:</i> <strong>Understand key concepts</strong></td><td><ul><li><a data-mention href="/build/work-with-data/transform-data/expressions-for-data-transformation">Expressions for data transformation</a></li><li><a data-mention href="/build/flow-logic">Flow logic</a></li><li><a data-mention href="/build/understand-workflows/understand-executions">Understand executions</a></li></ul></td><td></td><td><a href="https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-a79bf3f70430c9cd04c80ee5be3ececfa4992a90%2Fdeep.png?alt=media">deep.png</a></td></tr><tr><td><strong>Anthropic</strong> <strong>Claude Desktop</strong></td><td><a href="/connect/connect-to-n8n-mcp-server/mcp-client-examples#connecting-claude-desktop-to-n8n-mcp-server">Connecting Claude Desktop to n8n MCP server</a></td><td></td><td><a href="https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-96b771cc26a7abf72e3cf12f455ade2a288d352b%2FClaude_logo.jpeg?alt=media">Claude_logo.jpeg</a></td></tr><tr><td><strong>Anthropic</strong> <strong>Claude Code</strong></td><td><pre data-overflow="wrap"><code>claude mcp add --transport http n8n-mcp https:///mcp-server/http
</code></pre></td><td><a href="/connect/connect-to-n8n-mcp-server/mcp-client-examples#connecting-claude-code-to-n8n-mcp-server">Connecting Claude Code to n8n MCP server</a></td><td><a href="https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-9600c7e6fb192d011a44763446bac7e9b2017fe1%2FClaude_code_logo.jpeg?alt=media">Claude_code_logo.jpeg</a></td></tr><tr><td><strong>OpenAI</strong> <strong>Codex CLI</strong></td><td><pre data-overflow="wrap"><code>codex mcp add n8n-mcp --url https:///mcp-server/http
</code></pre></td><td><a href="/connect/connect-to-n8n-mcp-server/mcp-client-examples#connecting-codex-cli-to-n8n-mcp-server">Connecting Codex CLI to n8n MCP server</a></td><td><a href="https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-da5441ec462c0eed20806ac3b90f9f6305ea110c%2Fcodex_logo.jpeg?alt=media">codex_logo.jpeg</a></td></tr></tbody></table>


# Choose how to use n8n

Choose between n8n Cloud and self-hosting, and learn about licenses and plans.

n8n offers two primary deployment options: **n8n Cloud** (fully-managed) and **Self-hosted** (deploy on your own infrastructure). Choosing involves two decisions:

1. **Cloud or self-hosted?** Decide whether n8n manages the infrastructure or you do.
2. **Which plan or edition?** Within each option, pick the tier that has the features and limits you need.

This page helps with both.

<figure><picture><source srcset="https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-585df12f20d8ec428d7a197cb529824c1525d8e3%2Fchoose-your-n8n-diag-dark.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-dce340966fda22a205b3e42384797190568ff563%2Fchoose-your-n8n-diag-light.png?alt=media" alt="Decision flowchart: n8n Cloud offers the Starter, Pro, and Enterprise plans; self-hosted offers the Community, Registered Community, Business, and Enterprise editions"></picture><figcaption><p>Choosing your n8n deployment option, plan, and edition</p></figcaption></figure>

{% hint style="info" %}
**Want to try n8n quickly?**

**Start with n8n Cloud** for instant access with no installation required.

[Start free trial](https://n8n.io/cloud/)
{% endhint %}

## Decision 1: Cloud or self-hosted <a href="#decision-1-cloud-or-self-hosted" id="decision-1-cloud-or-self-hosted"></a>

Use this guide to choose a deployment option:

| Your situation                                               | Recommended option                  | Reason                                                                                     |
| ------------------------------------------------------------ | ----------------------------------- | ------------------------------------------------------------------------------------------ |
| Want to start right away                                     | **n8n Cloud**                       | No installation needed                                                                     |
| Don't have technical expertise                               | **n8n Cloud**                       | Fully managed, no setup or maintenance required                                            |
| Need production-ready deployment                             | **Both options work**               | Both n8n Cloud and self-hosted support production use                                      |
| Don't want to manage infrastructure                          | **n8n Cloud**                       | n8n handles hosting, updates, and scaling                                                  |
| Need full control over deployment                            | **Self-hosted**                     | You control the environment and configuration                                              |
| Have customized use cases                                    | **Self-hosted**                     | Full control over deployment and configuration                                             |
| Need enterprise features (SSO, environments, projects, etc.) | **Both options work**               | Enterprise plans (paid) are available with both. See the [Enterprise Hub](/enterprise-hub) |
| Have infrastructure and technical resources                  | **Self-hosted**                     | You can manage your own deployment                                                         |
| Want to run n8n for free                                     | **Self-hosted (Community edition)** | Free with almost the complete feature set                                                  |

For specific feature availability across different plans, see the [pricing page](https://n8n.io/pricing/).

### Pros and cons comparison <a href="#pros-and-cons-comparison" id="pros-and-cons-comparison"></a>

| Aspect                        | n8n Cloud                      | Self-hosted                                      |
| ----------------------------- | ------------------------------ | ------------------------------------------------ |
| **Setup & Deployment**        |                                |                                                  |
| Installation                  | ✅ No installation needed       | ❌ Requires setup (npm, Docker, or server)        |
| Technical expertise           | ✅ None required                | ❌ Required for installation and configuration    |
| **Infrastructure Management** |                                |                                                  |
| Hosting                       | ✅ Fully hosted by n8n          | ❌ You must provide and manage infrastructure     |
| Maintenance                   | ✅ Handled by n8n               | ❌ Your responsibility                            |
| **Control & Customization**   |                                |                                                  |
| Deployment control            | ❌ Managed by n8n               | ✅ Full control over deployment                   |
| Customization                 | ❌ Limited to available options | ✅ Recommended for customized use cases           |
| **Cost**                      |                                |                                                  |
| Free option                   | ⚠️ Free trial available        | ✅ Free Community edition with most features      |
| Paid options                  | ✅ Range of paid plans          | ✅ Paid Business and Enterprise options available |
| **Features**                  |                                |                                                  |
| Core features                 | ✅ Included                     | ✅ Included in free Community edition             |
| Enterprise features           | ❌ Requires paid plans          | ❌ Requires a paid plan (free Community limited)  |
| **Use Cases**                 |                                |                                                  |
| Quick start                   | ✅ Ideal for getting started    | ⚠️ Takes longer to set up                        |
| Production use                | ✅ Supported                    | ✅ Recommended for production                     |
| Custom requirements           | ⚠️ Limited customization       | ✅ Recommended for customized use cases           |

**Legend**: ✅ Advantage | ❌ Disadvantage | ⚠️ Mixed/depends on needs

For specific feature availability across different plans, see the [pricing page](https://n8n.io/pricing/).

## Decision 2: Choose a plan or edition <a href="#decision-2-choose-a-plan-or-edition" id="decision-2-choose-a-plan-or-edition"></a>

Once you've chosen a deployment option, pick a plan or edition. The [pricing page](https://n8n.io/pricing/) lists the definitive features, usage limits, and prices.

### Pick a plan for n8n Cloud <a href="#if-you-chose-n8n-cloud-pick-a-plan" id="if-you-chose-n8n-cloud-pick-a-plan"></a>

Every plan runs on the same underlying product with different features, usage limits, and computing power.

| Plan           | Designed for                                                                      |
| -------------- | --------------------------------------------------------------------------------- |
| **Free trial** | Trying n8n Cloud with Pro features for 14 days                                    |
| **Starter**    | Individuals and small projects getting started                                    |
| **Pro**        | Power users and small teams that need higher limits, admin accounts, and insights |
| **Enterprise** | Organizations that need advanced security, scaling, and dedicated support         |

For how to start a trial and upgrade, see [Try free then choose a plan](/deploy/use-n8n-cloud/start-your-free-trial). For what each plan includes, see the [pricing page](https://n8n.io/pricing/).

### Pick a plan or edition for self-hosted n8n <a href="#if-you-chose-self-hosted-pick-an-edition" id="if-you-chose-self-hosted-pick-an-edition"></a>

Every self-hosted installation runs on the same underlying product. You can stick with the free Community edition indefinitely, or register for free to unlock extra features. For paid features, subscribe to a plan to get a license key that unlocks them.

| Edition / Plan           | Cost                                                     | Designed for                                                                                         |
| ------------------------ | -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| **Community**            | Free                                                     | Self-hosting with almost the complete feature set                                                    |
| **Registered Community** | Free                                                     | Community plus folders, debug in editor, and custom execution data. Unlock by registering your email |
| **Business**             | Paid (license key when you subscribe to Business plan)   | Teams needing paid features like SSO, environments, and projects                                     |
| **Enterprise**           | Paid (license key when you subscribe to Enterprise plan) | Organizations needing the most advanced security, scaling, and governance                            |

For the differences between editions and how to register or license an instance, see [Compare plans and editions](/deploy/host-n8n/community-edition-features). For what each plan includes, see the [pricing page](https://n8n.io/pricing/).

To register a Community edition instance for the extra free features, go to **Settings > Plan & usage** and select **Unlock**.

## Which features need a paid plan or edition <a href="#which-features-need-a-paid-plan-or-edition" id="which-features-need-a-paid-plan-or-edition"></a>

Some features require certain paid plan subscriptions, including:

* Custom variables
* Environments
* External secrets
* External storage for binary data
* Log streaming (standard logging is included)
* Multi-main mode (queue mode is included)
* Projects
* SSO (SAML, LDAP)
* Workflow and credential sharing
* Version control using Git

Feature availability changes over time and differs by plan and edition. For exactly what each plan and edition includes, the [pricing page](https://n8n.io/pricing/) is the definitive source. See also [Compare plans and editions](/deploy/host-n8n/community-edition-features) for how the self-hosted plans and editions differ. For how your plan, platform, and n8n version determine access, and how maturity status (Preview, GA, deprecated, or removed) affects whether you can rely on a feature, see [Understand feature availability](/administer/understand-feature-availability).

## Getting started <a href="#getting-started" id="getting-started"></a>

Ready to begin?

* [**Get started with n8n Cloud**](https://n8n.io/cloud/) — sign up for instant access, then [choose a plan](/deploy/use-n8n-cloud/start-your-free-trial)
* [**Get started with self-hosted**](/deploy/host-n8n) — installation and deployment guides, then [choose a plan or edition](/deploy/host-n8n/community-edition-features)

For the current plans, editions, licenses, and prices, always check the [pricing page](https://n8n.io/pricing/).

## Related resources

* [n8n Docs](/)
* [Build your first workflow](/build-your-first-workflow)
* [Learning paths](/learning-paths)
* [Key concept glossary](/key-concept-glossary)


# Build your first workflow

Create your first workflow in n8n and learn some key concepts.

In this quick start, you’ll build a workflow that fetches the weather for Berlin every morning and turns it into a short report anyone can read at a glance. The workflow saves each report to a data table, so you build up a weather log over time.

![8 AM schedule trigger connected to Get Berlin weather, Add weather report, and Save weather log](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-a4ded6e98c65464468ab6d5de15287ad4ba5daab%2Fbuild-your-first-workflow.png?alt=media)

When it runs, your workflow produces a report like this:

```
The temperature in Berlin is 6.8 degrees C and it's currently cloudy.
```

You’ll build it with n8n Assistant, which turns a prompt into a working workflow. That takes less than five minutes. If you’d rather build it node by node, an optional section at the end walks you through the same workflow by hand.

You can also follow along with this video:

{% embed url="<https://www.youtube.com/embed/0BzaIm7Fwyo>" %}

Apart from n8n, you don’t need any coding experience. The weather data comes from Mockingbird, a sample-data service n8n provides for tutorials, so you’ll get similar results to this guide.

## Before you start

You need an n8n instance. Either:

* **n8n Cloud**: [sign up for a free trial](https://go.n8n.io/ekXKXJ), or
* **Self-hosted**: follow the [host n8n](/deploy/host-n8n) guide, then [set up n8n Assistant](/deploy/host-n8n/configure-n8n/set-up-n8n-assistant) with your own AI provider account

## Build the workflow with n8n Assistant

{% hint style="info" %}
**Feature availability**

n8n Assistant is available on:

* **n8n Cloud:** Starter, Pro
* **Self-hosted:** Community, Registered Community, Business

On n8n Cloud Enterprise and self-hosted Enterprise, contact your Customer Success Manager about preview access.
{% endhint %}

{% hint style="info" %}
Your results may differ from the screenshots in this guide.
{% endhint %}

n8n Assistant builds workflows from prompts. You describe what you want, approve each step, and end up with a workflow you can open, edit, and publish.

1. Log in to your n8n instance and select **New chat** in the left menu to talk to the n8n Assistant.

   ![New chat selected in the left menu, with the n8n Assistant chat box open](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-e93e6e4805142aca5ebd44f1f296f8678bbca267%2Fbuild-your-first-workflow-assistant-01.png?alt=media)
2. Enter this prompt, or dictate it, and select the send arrow:

   ```
   Build a workflow called Weather Log that runs every day at 8 AM:
   - Get the weather for Berlin from https://mockingbird.n8n.io/v1/weather/berlin
   - Add a report field that contains the city, temperature, and conditions e.g. The temperature in Berlin is 10°C. It's currently overcast.
   - Save the report to a new data table
   ```

   ![The weather workflow prompt entered in the n8n Assistant chat box](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-992ad780653bb1319d5f2664a9c2514d22140ee0%2Fbuild-your-first-workflow-assistant-02.png?alt=media)

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>Mockingbird is a sample API with weather for about 40 European cities. Other cities return an error.</p></div>
3. Approve any prompts from n8n Assistant with **Allow once**. As it builds the workflow, you'll see the progress on the canvas to the right of the chat.

   ![n8n Assistant asking the user for permission](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-f301c104b5cd3724a94e85a7535d9e3d00523cb4%2Fbuild-your-first-workflow-assistant-03.png?alt=media)
4. Approve a run if prompted by n8n Assistant. Otherwise, ask n8n Assistant to run a test for you.

   ![n8n Assistant asking to run a live test, with the finished workflow on the canvas](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-586d76136370c83ea062c40743c45236cfcca9ae%2Fbuild-your-first-workflow-assistant-04.png?alt=media)
5. Select **Publish and enable the schedule** if prompted by n8n Assistant, as the workflow only runs at 8 AM every day once you publish it. Otherwise, ask n8n Assistant to publish it for you.

   ![User asking assistant to publish workflow](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-e92833c9556ded8de6476082106adfc26376ec1d%2Fbuild-your-first-workflow-assistant-05.png?alt=media)
6. Select the `weather log` data table at the top of the right-hand pane to check the workflow ran as intended. Otherwise, ask n8n Assistant to show you the data table.

   ![weather log tab selected at the top of the right-hand pane](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-b2143070c5eb31e3ac4b7b7cbdac4bf64e34d3ed%2Fbuild-your-first-workflow-assistant-06.png?alt=media)
7. Select **Personal** in the left menu to see the workflow. n8n Assistant saves all workflows under **Personal**.

   ![weather log listed under Personal, marked as Published](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-e717e2dcfbfb1838ad2e85d35e2c611c97a41ae2%2Fbuild-your-first-workflow-assistant-07.png?alt=media)

## What your workflow does

Open **weather log** on the canvas and you'll see four [nodes](/build/understand-workflows/workflow-components/work-with-nodes), each doing one job and passing its result to the next:

| Node                   | What it does                                                                                                                                                                                                                                        |
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Every day at 8 AM**  | A [Schedule Trigger](/integrations/builtin/core-nodes/n8n-nodes-base.scheduletrigger) that starts the workflow at 8 AM every day.                                                                                                                   |
| **Get Berlin weather** | An [HTTP Request](/integrations/builtin/core-nodes/n8n-nodes-base.httprequest) node that fetches the weather from the Mockingbird API.                                                                                                              |
| **Add weather report** | An [Edit Fields (Set)](/integrations/builtin/core-nodes/n8n-nodes-base.set) node that builds the `report` text, using an [expression](/build/work-with-data/transform-data/expressions-for-data-transformation) to pull in the live weather values. |
| **Save weather log**   | A [Data table](/integrations/builtin/core-nodes/n8n-nodes-base.datatable) node that inserts the report as a new row in the table.                                                                                                                   |

{% hint style="info" %}
n8n Assistant chooses the node names itself, so yours may differ from the ones above.
{% endhint %}

## Optional: Build the workflow yourself

This section builds the weather log workflow by hand, one node at a time, without n8n Assistant.

You'll end up with a second workflow built from the same four nodes: **Every day at 8 AM**, **Get Berlin weather**, **Add weather report**, and **Save weather log**. You'll also create a new data table in the process.

### 1. Create the workflow

1. Select **Personal** in the left menu followed by **Create workflow**. This opens the canvas, where you’ll build your workflow and spend most of this section.

   ![Personal in the left menu and the create workflow button](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-25137bf3072eaff3007f357a95edde2f41b4f25e%2Fbuild-your-first-workflow-optional-01-01.png?alt=media)
2. Select the workflow’s name and change it to `Weather Log 2` (or something more creative). Select anywhere on the canvas to save the name.

### 2. Run it at 8 AM every day

You’ll use: **Schedule Trigger**

When building a workflow, the first question to answer is: “How should this workflow start?” On a schedule, for example 8 AM every day? When a user submits a form? When an application like Telegram sends a message?

For this build, you'll set it to run at 8 AM every day. While you build, you’ll run the workflow yourself to test it. Once you publish it at the end, the schedule runs it for you:

1. Select **Add first step**, then select **On a schedule**.

   ![On a schedule option](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-cc72b41fb23a0fa86e4ded75b5c3ce3772e02299%2Fbuild-your-first-workflow-optional-02-01.png?alt=media)
2. Select `8am` from the **Trigger at Hour** field in the Node details view. Select the close button in the top right to close the window.

   ![Trigger at Hour set to 8 AM](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-c06ced8528a912bde326efa09e6e3861e104c89c%2Fbuild-your-first-workflow-optional-02-02.png?alt=media)
3. Select the **Schedule Trigger** node and press space bar to open up the rename dialog box. Rename it to `Every day at 8 AM`.

   ![Renamed Schedule Trigger](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-d930e170605d957fcbd17ebc150c18889a8cacba%2Fbuild-your-first-workflow-optional-02-03.png?alt=media)

### 3. Get the weather for Berlin

You’ll use: **HTTP Request**

You’ve got your trigger, so it’s time to fetch the weather. The **HTTP Request** node sends a request to a web address, called an endpoint, and returns the data that address provides. Services that share data this way are APIs.

1. Select **+** after the trigger, type `http` in the **Search nodes** box, and select **HTTP Request**.

   ![HTTP Request in the search results](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-57f66f24a74bae5c39727fae3b95068af1492590%2Fbuild-your-first-workflow-optional-03-01.png?alt=media)
2. Paste `https://mockingbird.n8n.io/v1/weather/berlin` into the **URL** field in the Node details view.

   ![Mockingbird URL in the URL field](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-003dea0a8037113910cb3e0652992498b2d44701%2Fbuild-your-first-workflow-optional-03-02.png?alt=media)

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>Mockingbird is a sample API with weather for about 40 European cities. Other cities return an error.</p></div>
3. Press **Execute step**. You should see the weather for Berlin in the output, including the `city`, `temp_c`, and `condition` fields you’ll use in the next step.

   ![Berlin weather output](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-f7f7a69a8d0612a1825e7ce0cbfc6d5d1a3f766c%2Fbuild-your-first-workflow-optional-03-03.png?alt=media)
4. Rename the node to be `Get Berlin weather`.

### 4. Turn the weather into a report

You’ll use: **Edit Fields (Set)**

Next, you’ll turn the weather data into a short report that anyone can read at a glance.

1. Select **+** after **Get Berlin weather**, select **Data transformation**, then select **Edit Fields (Set)**.

   ![Edit Fields (Set) under Data transformation](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-5462d028a677b26be79dd0169cfb496785602620%2Fbuild-your-first-workflow-optional-04-01.png?alt=media)
2. Select **Add Field** in the middle of the Node details view. For **Name**, enter `report`.

   ![Add Field button](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-191e07b87920ea786cf3cf858b458f9bdd17f271%2Fbuild-your-first-workflow-optional-04-02-01.png?alt=media)

   ![Field named report](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-141c12de2737f40150f2c8fe4cb4673bea00999b%2Fbuild-your-first-workflow-optional-04-02-02.png?alt=media)
3. Enter `The temperature in` for **Value**, then drag `city` from the input panel on the left. When you drop a field in, n8n switches **Value** to **Expression** mode, and you see:

   ```
   The temperature in {{ $json.city }}
   ```

   ![city dragged into the Value field](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-db39374ab2fedbb37cf9d2878a495b96ce840a6b%2Fbuild-your-first-workflow-optional-04-03.png?alt=media)

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p><strong>What's an expression?</strong></p><p><code>{{ $json.city }}</code> is a placeholder, called an expression. When the workflow runs, n8n swaps it for the real value. The input panel shows the output from <strong>Get Berlin weather</strong>, which becomes the input to this node. You drag fields in rather than typing them, and the preview under the field shows you the finished sentence. To learn more, see <a href="/build/work-with-data/expressions-versus-data-nodes#expressions">Expressions</a>.</p></div>
4. Drag `temp_c` in and update the wording to:

   ```
   The temperature in {{ $json.city }} is {{ $json.temp_c }}°C.
   ```

   ![Value with city and temperature](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-05d6b75efbb015408530e3f01aa1803e7f9280a4%2Fbuild-your-first-workflow-optional-04-04-01.png?alt=media)

   Add `It's currently` to the end, then drag `condition` in:

   ```
   The temperature in {{ $json.city }} is {{ $json.temp_c }}°C. It's currently {{ $json.condition }}.
   ```

   ![Value with city, temperature, and condition](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-5f3deb81adbff4aaf4c7ba628a9d53d9fe61a408%2Fbuild-your-first-workflow-optional-04-04-02.png?alt=media)
5. Rename the node to `Add weather report` and select **Execute step**.

### 5. Save the data

You’ll use: **Data table**

You’ve fetched the data and formatted it, so now it’s time to store it. You'll create a data table in the process.

1. Add a **Data table** node after **Add weather report** and select **Insert row** as the action.

   ![Insert row action](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-8ed395442c2b6b202c1f2efce676c7bdcead39e0%2Fbuild-your-first-workflow-optional-05-01.png?alt=media)
2. Open the node, select the drop down under **Data table**, then select **Create new data table**:

   ![Create a new data table](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-3dfb64c5396a6220ad9ede3e7cd4090e8d54f4af%2Fbuild-your-first-workflow-optional-05-02.png?alt=media)

   A new browser tab will open.
3. Enter `weather log 2` for the name of your data table (or something creative!), and select **Create**:

   ![Name the new data table](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-d316e744709e8b7e1af3a32d954cc73709ee6c4f%2Fbuild-your-first-workflow-optional-05-03.png?alt=media)
4. Select **Add Column** on the top right and enter `report` before selecting **Add Column**. This will be the column the data from the `Add weather report` node gets saved to.

   ![Add a column to the new data table](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-0bf66180682f05f0ecfdd49de8a3df80aa02d601%2Fbuild-your-first-workflow-optional-05-04.png?alt=media)

   Navigate back to the workflow tab.
5. Select the data table you just created from the **Data table** list and change **Mapping Column Mode** to **Map Automatically**. The `report` field from **Add weather report** has the same name as the column in the data table, so n8n maps them for you.

   ![Data table node with the data table selected and Map Automatically set](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-3b4cd2cd6b9fda2db4dd37735b2c72f75380822b%2Fbuild-your-first-workflow-optional-05-05.png?alt=media)
6. Rename the node to `Save weather log`.

### 6. Test and publish the workflow

Your workflow is complete. Test it, then publish it so it runs every day at 8 AM.

1. Select **Execute** under the canvas to test it. You should see green check marks on all four nodes:

   ![Successful workflow run after execution](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-10479180cc9280bc28e3632dc8af29610a544a71%2Fbuild-your-first-workflow-optional-06-01.png?alt=media)
2. Navigate to **Personal** > **Data tables** to see the new row.
3. Select **Publish** in the Canvas header and follow the prompts to publish the workflow.

   ![Publish the workflow](https://2446198290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCxSeOtVxqqhfxMSac0AV%2Fuploads%2Fgit-blob-d969f80e0d19f877a0c3ebfaf06b4242a4aa65d8%2Fbuild-your-first-workflow-optional-06-03.png?alt=media)

## Next steps

* Take [courses at n8n Academy](https://go.n8n.io/gfzWgF).
* Explore more examples in [workflow templates](https://n8n.io/workflows/).

## Related resources

* [n8n Docs](/)
* [Choose how to use n8n](/choose-how-to-use-n8n)
* [Use n8n Assistant](/build/ways-of-building-workflows/n8n-assistant)
* [Learning paths](/learning-paths)
* [Key concept glossary](/key-concept-glossary)


# Learning paths

Interactive courses to learn n8n through hands-on exercises, quizzes, and real workflow building.

Learn n8n through interactive courses at [n8n Academy](https://learn.n8n.io/). Build real workflows, earn badges, and get certificates of completion.

All courses include:

* Hands-on workflow exercises
* Section quizzes and a final exam
* Badges and certificates upon completion (70% passing grade)
* Practice APIs (no external accounts needed for most courses)

For a complete list of courses, see [n8n Academy courses](https://learn.n8n.io/courses). To start building right away instead, see [Build your first workflow](/build-your-first-workflow).

## Related resources

* [n8n Docs](/)
* [Choose how to use n8n](/choose-how-to-use-n8n)
* [Build your first workflow](/build-your-first-workflow)
* [Key concept glossary](/key-concept-glossary)


# Key concept glossary

Definitions of the terms n8n uses for workflows, agents, AI, and hosting, with links to the pages that explain each concept.

This glossary defines the terms n8n uses for building, running, and managing workflows and agents. Each entry links to the page that explains the concept in full.

### Workflow building blocks

#### canvas (n8n) <a href="#canvas-n8n" id="canvas-n8n"></a>

The canvas is the main interface for building workflows in n8n's editor UI. You use the canvas to add and connect nodes to compose workflows. Learn more: [Create and run workflows](/build/understand-workflows/create-and-run-workflows).

#### community node (n8n) <a href="#community-node-n8n" id="community-node-n8n"></a>

A community node is a node built and shared by the community, not one of n8n's built-in nodes. You install community nodes on your instance to add integrations that n8n doesn't provide. Learn more: [Using community nodes](/integrations/community-nodes/using-community-nodes).

#### credential (n8n) <a href="#credential-n8n" id="credential-n8n"></a>

In n8n, credentials store authentication information to connect with specific apps and services. After creating credentials with your authentication information (username and password, API key, OAuth secrets, and so on), you can use the associated app node to interact with the service. Learn more: [Create and edit credentials](/build/understand-workflows/create-and-edit-credentials).

#### editor (n8n) <a href="#editor-n8n" id="editor-n8n"></a>

The n8n editor UI lets you create and manage workflows. The main area is the canvas, where you can compose workflows by adding, configuring, and connecting nodes. The side and top panels let you access other areas of the UI like credentials, templates, variables, executions, and more. Learn more: [Create and run workflows](/build/understand-workflows/create-and-run-workflows).

#### expression (n8n) <a href="#expression-n8n" id="expression-n8n"></a>

In n8n, expressions let you populate node parameters dynamically by executing JavaScript code. Instead of providing a static value, you can use the n8n expression syntax to define the value using data from previous nodes, other workflows, or your n8n environment. Learn more: [Expressions for data transformation](/build/work-with-data/transform-data/expressions-for-data-transformation).

#### node (n8n) <a href="#node-n8n" id="node-n8n"></a>

In n8n, nodes are individual components that you compose to create workflows. Some nodes start workflows; others fetch, send, and process data, define flow control logic, or connect with external services. Learn more: [Work with nodes](/build/understand-workflows/workflow-components/work-with-nodes).

#### sub-workflow (n8n)

A sub-workflow is a workflow that another workflow calls. Use sub-workflows to split a large workflow into smaller, reusable parts. Learn more: [Sub-workflows](/build/flow-logic/break-workflows-into-smaller-parts).

#### template (n8n) <a href="#template-n8n" id="template-n8n"></a>

n8n templates are pre-built workflows designed by n8n and community members that you can import into your n8n instance. When using templates, you may need to fill in credentials and adjust the configuration to suit your needs. Learn more: [Workflow templates](/build/ways-of-building-workflows/use-templates).

#### trigger node (n8n) <a href="#trigger-node-n8n" id="trigger-node-n8n"></a>

A trigger node is a special node responsible for executing the workflow in response to certain conditions. All production workflows need at least one trigger to determine when the workflow should run. Learn more: [Trigger nodes](/integrations/builtin/trigger-nodes).

#### workflow (n8n) <a href="#workflow-n8n" id="workflow-n8n"></a>

An n8n workflow is a collection of nodes that automate a process. Workflows begin execution when a trigger condition occurs, when you run them manually, or when another workflow calls them. They execute node by node, and can branch, merge, and loop to achieve complex tasks. Learn more: [Create and run workflows](/build/understand-workflows/create-and-run-workflows).

### Data

#### binary data (n8n)

Binary data is file-type data, such as images and documents. An item holds binary data in its `binary` object, separate from its `json` data. Learn more: [Binary data](/build/work-with-data/handle-special-data-types/work-with-files-and-images).

#### data pinning (n8n) <a href="#data-pinning-n8n" id="data-pinning-n8n"></a>

Data pinning lets you temporarily freeze the output data of a node during workflow development. This lets you develop workflows with predictable data without making repeated requests to external services. Production workflows ignore pinned data and request new data on each execution. Learn more: [Data mocking and pinning](/build/work-with-data/pin-and-mock-data).

#### data table (n8n)

A data table stores structured, tabular data inside n8n, so you don't need an external database. Data tables are scoped to a [project](#project-n8n), and workflows in that project can read and write them with the [Data Table node](/integrations/builtin/core-nodes/n8n-nodes-base.datatable). You can also manage them in the Data tables tab and through the [n8n API](/connect/n8n-api/api-reference). Data tables suit light to moderate storage. Learn more: [Data tables](/build/work-with-data/data-tables) and [Data Table node](/integrations/builtin/core-nodes/n8n-nodes-base.datatable).

#### variable (n8n)

A custom variable stores a read-only string that you reuse across workflows. A variable is either global, available across the whole instance, or scoped to a single project. Learn more: [Custom variables](/build/code-in-n8n/define-custom-variables).

### Agents and AI in n8n

#### agent (n8n)

An agent is an autonomous assistant you build in n8n. Each agent has a language model, instructions, and capabilities you configure, such as tools, [skills](#skill-n8n), memory, a [knowledge base](#knowledge-base-n8n), and [sub-agents](#sub-agent-n8n). Agents are separate items in your project, not part of a workflow, and people reach them through chat, channels, and schedules. Agents are in Preview. Don't confuse an agent with the [AI Agent node](#ai-agent-node-n8n), which runs inside a workflow. Learn more: [Build and manage agents](/build/build-and-manage-agents).

#### AI agent <a href="#ai-agent" id="ai-agent"></a>

An AI agent is an AI system that uses a large language model (LLM) to interpret a request and decide which actions to take, such as calling tools, to complete it. In n8n you can build an AI agent in two ways: as an [agent](#agent-n8n), or with the [AI Agent node](#ai-agent-node-n8n) in a workflow. Learn more: [What's an agent in AI?](/build/integrate-ai/understand-ai-components/what-agents-do).

#### AI Agent node (n8n)

The AI Agent node adds an AI agent to a workflow. It's a cluster node: a root node that you extend with sub-nodes, such as a chat model, tools, and memory. It's a different feature from an [agent](#agent-n8n) built in the Agent Builder. Learn more: [AI Agent node](/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent).

#### AI chain <a href="#ai-chain" id="ai-chain"></a>

An AI chain calls an LLM and other components in a fixed sequence. Unlike an agent, a chain doesn't decide which steps to take. AI chains in n8n don't use persistent memory, so you can't use them to reference previous context (use AI agents for this). Learn more: [What's a chain in AI?](/build/integrate-ai/understand-ai-components/what-chains-do).

#### AI memory <a href="#ai-memory" id="ai-memory"></a>

In an AI context, memory lets AI tools persist message context across interactions. This lets you have continuing conversations with AI agents, for example, without submitting ongoing context with each message. In n8n, agents and AI Agent nodes can use memory, but AI chains can't. Learn more: [What's memory in AI?](/build/integrate-ai/understand-ai-components/how-memory-works).

#### AI tool <a href="#ai-tool" id="ai-tool"></a>

In an AI context, a tool is an add-on resource that the AI can refer to for specific information or features when responding to a request. The AI model can use a tool to interact with external systems or complete specific, focused tasks. Learn more: [What's a tool in AI?](/build/integrate-ai/understand-ai-components/how-tools-work).

#### cluster node (n8n) <a href="#cluster-node-n8n" id="cluster-node-n8n"></a>

In n8n, cluster nodes are groups of nodes that work together to provide AI features in a workflow, such as agents, chains, and vector stores. They consist of a root node and one or more sub-nodes that extend the node's features. For example, the AI Agent root node uses sub-nodes for a chat model, memory, and tools. n8n represents most LangChain concepts as cluster nodes. Learn more: [Cluster nodes](/integrations/builtin/cluster-nodes).

#### knowledge base (n8n)

A knowledge base is a set of files that an [agent](#agent-n8n) can search and read for context when it answers. You upload files to the agent, such as CSV, PDF, Markdown, and text files. Knowledge bases are available on n8n Cloud, and in Preview on self-hosted instances. Learn more: [Build and manage agents](/build/build-and-manage-agents#upload-knowledge).

#### Model Context Protocol (MCP)

Model Context Protocol (MCP) is an open standard that lets AI clients connect to external tools and data. n8n supports both sides of it:

* **As an MCP client**, n8n lets agents and the AI Agent node use tools from MCP servers, either from the one-click server registry or through the MCP Client Tool node.
* **As an MCP server**, n8n lets MCP clients such as Claude connect to your instance. The instance-level MCP server lets a client build, edit, run, and test workflows and manage data tables and agents. The MCP Server Trigger node exposes a single workflow's tools as its own MCP server.

Learn more: [MCP servers](/build/integrate-ai/mcp-servers) and [Set up and use n8n MCP server](/connect/connect-to-n8n-mcp-server).

#### n8n Assistant

n8n Assistant is a chat-based agent in n8n that helps you create, edit, test, and troubleshoot workflows from natural language. It can also build agents and help with instance tasks. Learn more: [Use n8n Assistant](/build/ways-of-building-workflows/n8n-assistant).

#### root node (n8n) <a href="#root-node-n8n" id="root-node-n8n"></a>

Each n8n cluster node contains a single root node that defines the main function of the cluster, such as running an AI agent or a chain. One or more sub-nodes attach to the root node to extend its features. Learn more: [Cluster nodes](/integrations/builtin/cluster-nodes).

#### skill (n8n)

A skill bundles instructions with the tools an agent needs for a specific task. Add a skill to an agent to reuse that behavior. Learn more: [Build and manage agents](/build/build-and-manage-agents#bundle-capabilities-with-skills).

#### sub-agent (n8n)

A sub-agent is a published agent that another agent can hand work to. Use sub-agents when a task has separate parts and a specialized agent can handle each part better. Learn more: [Build and manage agents](/build/build-and-manage-agents#add-sub-agents).

#### sub-node (n8n) <a href="#sub-node-n8n" id="sub-node-n8n"></a>

n8n cluster nodes consist of one or more sub-nodes connected to a root node. Sub-nodes extend the features of the root node, providing access to specific services or resources, such as chat models, memory, and vector stores, or offering specific types of dedicated processing, like a calculator. Learn more: [Sub-nodes](/integrations/builtin/cluster-nodes/sub-nodes).

#### tool approval (n8n)

Tool approval is a human-in-the-loop check on an AI tool call. For a sensitive tool, the agent pauses and waits for a person to approve or reject the call before the tool runs. Learn more: [Build and manage agents](/build/build-and-manage-agents#approve-tool-calls) and [Human-in-the-loop for AI tool calls](/build/integrate-ai/ai-examples/human-in-the-loop-for-tools).

### Organize, run, and publish

#### draft (n8n)

A draft is the working version of a workflow, or of an agent. n8n saves your edits to the draft automatically, and the draft doesn't run in production until you publish it. See also [publish](#publish-n8n). Learn more: [Save and publish workflows](/build/understand-workflows/save-and-publish-workflows).

#### evaluation (n8n) <a href="#evaluation-n8n" id="evaluation-n8n"></a>

An evaluation tests a workflow by running a dataset of test cases through it and checking the results against expected outputs or metrics. Use evaluations to confirm that an AI workflow stays reliable as you change models, prompts, or logic. Learn more: [Evaluations](/build/integrate-ai/test-and-improve-ai-workflows/understand-why-to-test).

#### execution (n8n)

An execution is a single run of a workflow. A manual execution starts when you run the workflow from the editor. A production execution starts automatically when a published workflow's trigger fires. Learn more: [Executions](/build/understand-workflows/understand-executions).

#### project (n8n) <a href="#project-n8n" id="project-n8n"></a>

n8n projects let you separate workflows, variables, credentials, data tables, and agents into separate groups for easier management. Projects make it easier for teams to collaborate by sharing and compartmentalizing related resources. You assign each user a role in each project, so one person can have different access in different projects. Learn more: [RBAC projects](/administer/manage-users-and-access/set-permissions-and-roles-rbac/organize-work-in-projects).

#### publish (n8n)

n8n saves your changes to a workflow as you edit. When you're ready to put the workflow into production, you publish a version of it. The published version runs when its trigger fires. Learn more: [Save and publish workflows](/build/understand-workflows/save-and-publish-workflows).

### Hosting, editions, and licensing

#### edition (n8n) <a href="#edition-n8n" id="edition-n8n"></a>

When you self-host n8n, the edition is the variant of the software you run: Community, Registered Community, Business, or Enterprise. All editions share the same underlying product. The free Community edition runs without a license key. When you subscribe to a paid Business or Enterprise plan, you get a license key that unlocks the features for that plan. See also [plan](#plan-n8n) and [license](#license-n8n). Learn more: [Compare plans and editions](/deploy/host-n8n/community-edition-features).

#### entitlement (n8n) <a href="#entitlement-n8n" id="entitlement-n8n"></a>

In n8n, entitlements grant n8n instances access to plan-restricted features for a specific period of time.

Floating entitlements are a pool of entitlements that you can distribute among various n8n instances. You can reassign a floating entitlement to transfer its access to a different n8n instance. See also [license](#license-n8n) and [plan](#plan-n8n). Learn more: [License key](/deploy/host-n8n/configure-n8n/manage-your-license).

#### instance (n8n)

An instance is a single n8n installation, either hosted by n8n Cloud or self-hosted. Each instance has its own workflows, users, credentials, and settings. Learn more: [Choose how to use n8n](/choose-how-to-use-n8n).

#### license (n8n) <a href="#license-n8n" id="license-n8n"></a>

License has two senses in n8n. First, it's the legal terms n8n uses to distribute its source code. Second, it's the license key that unlocks the features for a paid plan. When you self-host and subscribe to a paid Business or Enterprise plan, you add the license key to your instance to activate it. See also [entitlement](#entitlement-n8n) and [plan](#plan-n8n). Learn more: [License key](/deploy/host-n8n/configure-n8n/manage-your-license).

#### plan (n8n) <a href="#plan-n8n" id="plan-n8n"></a>

A plan is a commercial subscription tier, such as Starter, Pro, Business, or Enterprise. Your plan sets the features, usage limits, and price for your subscription, whether you use n8n Cloud or self-host. See also [edition](#edition-n8n) and [license](#license-n8n). Learn more: [Compare plans and editions](/deploy/host-n8n/community-edition-features).

#### queue mode (n8n)

Queue mode is a self-hosted scaling setup. A main instance receives triggers and passes executions to worker instances, which run them in parallel. Learn more: [Queue mode](/deploy/host-n8n/configure-n8n/scaling/enable-queue-mode).

### Related resources

* [n8n Docs](/)
* [Choose how to use n8n](/choose-how-to-use-n8n)
* [Build your first workflow](/build-your-first-workflow)
* [Learning paths](/learning-paths)


# Enterprise Hub

Plan, deploy, and scale n8n Enterprise across your organization.

n8n Enterprise adds the security, governance, and scale features that organizations need to run n8n across many teams. You can use Enterprise on n8n Cloud, where n8n hosts it for you, or self-host it on your own infrastructure.

{% hint style="info" %}
**Not yet signed up to n8n Enterprise?**

Learn more about [pricing and plans](https://n8n.io/pricing/), or [contact Sales](https://n8n.io/contact/) for more information.
{% endhint %}

## Your Enterprise journey

Follow these five steps to go from first setup to an Enterprise rollout that grows with your organization.

{% stepper %}
{% step %}

#### [Install and configure n8n](#install-and-configure)

Start by preparing a secure, reliable n8n Enterprise instance. Self-host n8n on your own infrastructure, or skip setup with [n8n Cloud](/deploy/use-n8n-cloud).
{% endstep %}

{% step %}

#### [Publish first workflow](#publish-first-workflow-1)

With your instance ready, build and publish a workflow that delivers value.
{% endstep %}

{% step %}

#### [Set up governance, roles, and ownership](#set-up-governance-roles-and-ownership-1)

As adoption grows, define how teams access n8n, share work, and manage changes.
{% endstep %}

{% step %}

#### [Confirm business value](#confirm-business-value-1)

Measure the value your workflows create, then share those results across your organization.
{% endstep %}

{% step %}

#### [Expand and train](#expand-and-train-1)

Use your early results to bring more teams and use cases onto n8n. Give users the training they need to build confidently.
{% endstep %}
{% endstepper %}

## What Enterprise features does n8n offer?

These features help you secure, govern and scale n8n across your organization. The Enterprise plan gives you access to them, and some are also available on other plans. Check [pricing and plans](https://n8n.io/pricing/) for full availability by plan.

| Feature                          | What it does                                                                                                         | Learn more                                                                                                                |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| Single sign-on (SSO)             | Let users sign in with your identity provider using SAML, OIDC, or LDAP.                                             | [Verify user identity](/administer/manage-users-and-access/verify-user-identity)                                          |
| Role-based access control (RBAC) | Control what each user can do with built-in and custom roles.                                                        | [Set permissions and roles](/administer/manage-users-and-access/set-permissions-and-roles-rbac)                           |
| Projects                         | Group workflows and credentials by team, and control who can access them.                                            | [Organize work in projects](/administer/manage-users-and-access/set-permissions-and-roles-rbac/organize-work-in-projects) |
| Source control and environments  | Use Git to version your work and move it between development and production.                                         | [Use source control and environments](/administer/use-source-control-and-environments)                                    |
| External secrets                 | Keep credentials in your own secrets vault instead of in n8n.                                                        | [Use external secret stores](/administer/manage-credentials/use-external-secret-stores)                                   |
| Log streaming                    | Send n8n events to your external logging and monitoring tools.                                                       | [Stream logs to external systems](/administer/observe-and-log/stream-logs-to-external-systems)                            |
| Insights                         | Track workflow performance and time saved across your instance.                                                      | [Track usage with Insights](/administer/observe-and-log/track-usage-with-insights)                                        |
| Multi-main mode                  | Run several main instances for high availability on self-hosted n8n.                                                 | [Set up multi-main mode](/deploy/host-n8n/configure-n8n/scaling/enable-queue-mode#multi-main-setup)                       |
| Security policies                | Enforce instance-wide controls for two-factor authentication, personal spaces, workflow reviews, and data redaction. | [Manage security policies](/deploy/host-n8n/configure-n8n/security/manage-security-policies)                              |
| Data redaction                   | Hide workflow execution data while retaining execution status and timing details.                                    | [Redact execution data](/deploy/host-n8n/configure-n8n/security/redact-execution-data)                                    |
| Workflow history                 | View, restore, compare, and name previous workflow versions.                                                         | [View change history](/build/manage-workflows/view-change-history)                                                        |

## Install and configure

Your Enterprise journey begins with a dependable foundation. These guides help self-hosted teams prepare, secure, scale, and monitor their n8n instance. If you use n8n Cloud, n8n manages the infrastructure for you.

<table data-view="cards"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><i class="fa-clipboard-check">:clipboard-check:</i> <strong>Prepare</strong></td><td><ul><li><a href="/deploy/host-n8n/understand-the-architecture">Understand the architecture</a></li><li><a href="https://app.gitbook.com/s/jm0ZYRpZIPWge2ZSiDYO/host-n8n/install-options/production-requirements">Production requirements</a></li></ul></td></tr><tr><td><i class="fa-download">:download:</i> <strong>Install</strong></td><td><ul><li><a href="/deploy/host-n8n/install-options">Install options</a></li><li><a href="/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform">Deploy with Terraform</a></li><li><a href="/deploy/host-n8n/install-options/use-a-cloud-provider">Use a cloud provider</a></li><li><a href="/deploy/host-n8n/configure-n8n/choose-n8ns-database">Choose n8n's database</a></li><li><a href="/deploy/host-n8n/configure-n8n/manage-your-license">Add your license key</a></li></ul></td></tr><tr><td><i class="fa-layer-group">:layer-group:</i> <strong>Set up scaling &#x26; queue mode</strong></td><td><ul><li><a href="/deploy/host-n8n/configure-n8n/scaling/enable-queue-mode">Enable queue mode</a></li><li><a href="/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/queue-mode">Queue mode environment variables</a></li><li><a href="/deploy/host-n8n/configure-n8n/scaling/control-concurrency">Control concurrency</a></li><li><a href="/deploy/host-n8n/configure-n8n/scaling/use-external-storage">Use external storage</a></li><li><a href="/deploy/host-n8n/configure-n8n/set-up-task-runners">Set up task runners</a></li></ul></td></tr><tr><td><p><i class="fa-shield-halved">:shield-halved:</i> <strong>Secure your deployment</strong></p><ul><li><a href="/deploy/host-n8n/configure-n8n/security/set-up-ssl">Set up SSL</a></li><li><a href="/deploy/host-n8n/configure-n8n/security/run-security-audits">Run security audits</a></li><li><a href="/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/set-a-custom-encryption-key">Set a custom encryption key</a></li><li><a href="/deploy/host-n8n/configure-n8n/security/rotate-encryption-keys">Rotate encryption key</a></li></ul></td><td></td></tr><tr><td><i class="fa-wave-pulse">:wave-pulse:</i> <strong>Set up monitoring and logging</strong></td><td><ul><li><a href="/deploy/host-n8n/keep-n8n-running/set-up-logging">Set up logging</a></li><li><a href="/administer/observe-and-log/stream-logs-to-external-systems">Stream logs to external systems</a></li><li><a href="/deploy/host-n8n/keep-n8n-running/monitor-n8n">Monitor your instance</a></li><li><a href="/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/enable-prometheus-metrics">Enable Prometheus metrics</a></li><li><a href="/deploy/host-n8n/keep-n8n-running/visualize-metrics-with-grafana">Visualize metrics with Grafana</a></li></ul></td></tr><tr><td><i class="fa-arrow-up-right-dots">:arrow-up-right-dots:</i> <strong>Back up and upgrade</strong></td><td><ul><li><a href="/deploy/host-n8n/keep-n8n-running/update-n8n">Update n8n</a></li><li><a href="/deploy/host-n8n/keep-n8n-running/backup-and-restore">Back up your instance</a></li></ul></td></tr></tbody></table>

## Publish first workflow

With your Enterprise instance ready, move from setup to automation. Build and publish a production workflow to prove the path from an idea to a reliable result.

* [Build your first workflow](/build-your-first-workflow)
* [Understand workflows](/build/understand-workflows)

## Set up governance, roles, and ownership

After you publish your first workflow, create the guardrails for wider adoption. Set up secure access, clear ownership, and controlled ways for teams to share and change their work.

<table data-view="cards"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><i class="fa-user">:user:</i> <strong>Manage users</strong></td><td><ul><li><a href="/administer/manage-users-and-access">User management on n8n Cloud</a></li><li><a href="/deploy/host-n8n/configure-n8n/user-management">User management on hosted n8n</a></li><li><a href="/deploy/host-n8n/configure-n8n/security/configure-sso">Configure SSO</a></li><li><a href="/administer/manage-users-and-access/set-permissions-and-roles-rbac">Set permissions and roles (RBAC)</a></li><li><a href="/administer/manage-users-and-access/set-permissions-and-roles-rbac/organize-work-in-projects">Organize work in projects</a></li></ul></td></tr><tr><td><i class="fa-code-branch">:code-branch:</i> <strong>Set up source control and environments</strong></td><td><ul><li><a href="/administer/use-source-control-and-environments/understand-source-control">Understand source control</a></li><li><a href="/administer/use-source-control-and-environments">Use source control and environments</a></li><li><a href="/administer/use-source-control-and-environments/set-up-source-control">Set up source control</a></li><li><a href="/administer/use-source-control-and-environments/work-with-environments">Work with environments</a></li><li><a href="/administer/use-source-control-and-environments/move-work-between-environments">Move work between environments</a></li></ul></td></tr><tr><td><i class="fa-monitor-waveform">:monitor-waveform:</i> <strong>Monitor and log</strong></td><td><ul><li><a href="/administer/observe-and-log/track-usage-with-insights">Track usage with Insights</a></li><li><a href="/administer/observe-and-log/stream-logs-to-external-systems">Stream logs to external systems</a></li></ul></td></tr><tr><td><i class="fa-lock-keyhole">:lock-keyhole:</i> <strong>Manage security</strong></td><td><ul><li><a href="/deploy/host-n8n/configure-n8n/security/manage-security-policies">Manage security policies</a></li><li><a href="/deploy/host-n8n/configure-n8n/security/run-security-audits">Run security audits</a></li><li><a href="/deploy/host-n8n/configure-n8n/security/redact-execution-data">Redact execution data</a></li></ul></td></tr><tr><td><i class="fa-lock-keyhole">:lock-keyhole:</i> <strong>Manage credentials</strong></td><td><ul><li><a href="/administer/manage-credentials/share-credentials-securely">Share credentials securely</a></li><li><a href="/administer/manage-credentials/use-external-secret-stores">Use external secret stores</a></li><li><a href="/administer/manage-credentials/credential-overwrites">Credential overwrites </a>(self-hosted only)</li></ul></td></tr></tbody></table>

## Confirm business value

As your workflows run, measure the value they create and share it with your organization. Establish a baseline for each process before automating it. Then [track the time saved by each n8n workflow](/administer/observe-and-log/track-usage-with-insights#setting-the-time-saved-by-a-workflow) so Insights shows hours saved over time. Or use the [Time Saved node](/integrations/builtin/core-nodes/n8n-nodes-base.timesaved) to record savings dynamically when they vary by execution.

## Expand and train

With governance and measurable results in place, expand n8n with confidence. Bring more teams and use cases onto n8n, then help users build with the following resources.

* [n8n Academy](https://learn.n8n.io/) offers interactive courses, hands-on exercises, and quizzes.
* [n8n YouTube channel](https://www.youtube.com/c/n8n-io) shares product tutorials, workflow examples, and webinars.
* [n8n documentation](https://docs.n8n.io/) explains n8n features and configuration. Use **Ask AI** to get answers to any questions about how n8n works.
* [n8n community forum](https://community.n8n.io/?tl=en) connects you with other n8n users and the n8n team.


# Deploy

Deploy n8n on n8n Cloud or self-host it, and find guides for installing, configuring, and maintaining your instance.

n8n offers two different deployment methods. [n8n Cloud](/deploy/use-n8n-cloud) gives fast, managed setup on an instance run by n8n. [Self-hosted n8n](/deploy/host-n8n) lets you run n8n on your own machine or infrastructure.

**Deploy** documentation helps you deploy, configure, secure, and maintain n8n in either model.

<table data-view="cards"><thead><tr><th>Deployment option</th><th data-card-target data-type="content-ref">Go to section</th></tr></thead><tbody><tr><td><strong>Use n8n Cloud</strong><br>Managed by n8n. Get started fast, with less operational work.</td><td><a href="/deploy/use-n8n-cloud">Use n8n Cloud</a></td></tr><tr><td><strong>Self-host n8n</strong><br>Run n8n yourself with Docker, npm, Docker Compose, or a supported platform.</td><td><a href="/deploy/host-n8n">Host n8n</a></td></tr></tbody></table>

### Compare deployment options

Below is a high-level overview of each option. If you're still deciding, look at [Choose your n8n](/choose-how-to-use-n8n) for more guidance.

#### Use n8n Cloud

n8n Cloud is the managed option. n8n runs the instance for you.

Choose n8n Cloud if you want to:

* Start fast with minimal setup
* Reduce infrastructure and maintenance work
* Use Cloud-specific admin and configuration tools

{% content-ref url="/pages/TfRz19xNcFbNxlcQq9L7" %}
[Use n8n Cloud](/deploy/use-n8n-cloud)
{% endcontent-ref %}

#### Self-host n8n

Self-hosting gives you control over how n8n runs and how you manage your environment.

Choose self-hosting if you want to:

* Run n8n on your own infrastructure
* Finely control upgrades, configuration, and security
* Design for custom scaling or platform requirements

{% hint style="success" %}
**Want to try self-hosting right now?**

```bash
curl -fsSL https://get.n8n.io | sh
```

Requires Docker on Linux or macOS (or WSL on Windows). Sets up n8n locally in one step. See the [one-line setup guide](/deploy/host-n8n/install-options/one-line-setup) for details.
{% endhint %}

<table data-view="cards"><thead><tr><th>Self-hosted topic</th><th data-card-target data-type="content-ref">Open</th></tr></thead><tbody><tr><td><strong>Host n8n overview</strong><br>Start with the main self-hosted landing page.</td><td><a href="/deploy/host-n8n">Host n8n</a></td></tr><tr><td><strong>Install options</strong><br>Set up n8n with Docker, npm, Docker Compose, or a cloud provider.</td><td><a href="/deploy/host-n8n/install-options">Install options</a></td></tr><tr><td><strong>Configure n8n</strong><br>Manage databases, environment variables, users, licenses, and security settings.</td><td><a href="/deploy/host-n8n/configure-n8n">Configure n8n</a></td></tr><tr><td><strong>Keep n8n running</strong><br>Monitor, log, trace, and update your instance.</td><td><a href="/deploy/host-n8n/keep-n8n-running">Keep n8n running</a></td></tr><tr><td><strong>Understand the architecture</strong><br>Learn how n8n works and how it structures its database.</td><td><a href="/deploy/host-n8n/understand-the-architecture">Understand the architecture</a></td></tr></tbody></table>

{% content-ref url="/pages/dqi8Y1iZswob8wzg3QaO" %}
[Host n8n](/deploy/host-n8n)
{% endcontent-ref %}


# Use n8n Cloud

Manage your n8n Cloud trial, plan, and instance, including the n8n Cloud console and updates.

Manage your n8n Cloud trial, plan, and instance.

## In this section

* [Try free then choose a plan](/deploy/use-n8n-cloud/start-your-free-trial): start a free trial, then compare the Starter, Pro, and Enterprise plans. For Enterprise rollout guidance, see the [Enterprise Hub](/enterprise-hub).
* [Use the Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console): open the n8n Cloud console, where you manage your instance, plan, billing, and credits.
* [Update your version](/deploy/use-n8n-cloud/update-your-version): update your n8n version on Cloud.
* [Configure Cloud](/deploy/use-n8n-cloud/configure-cloud): set your timezone, find your IP addresses, and manage your data.
* [Gateway credits](/deploy/use-n8n-cloud/gateway-credits): use AI models and third-party services without provider accounts or API keys.
* [Assistant credits](/deploy/use-n8n-cloud/assistant-credits): understand the monthly n8n Assistant allowance in your plan and buy extra credits.
* [Understand concurrency](/deploy/use-n8n-cloud/understand-concurrency): how n8n Cloud handles concurrent executions.
* [Download workflows](/deploy/use-n8n-cloud/download-workflows): download workflows from an n8n Cloud backup in the Cloud console.

## Related resources

* [Deploy](/deploy)
* [Host n8n](/deploy/host-n8n)


# Try free then choose a plan

Start a free n8n Cloud trial, then compare the Starter, Pro, and Enterprise plans to choose the right one.

[n8n Cloud](/deploy/use-n8n-cloud) is the managed way to run n8n: n8n hosts your instance, so you don't set up or maintain any infrastructure. The best way to start is with a free trial, then move to a paid plan that fits your needs.

## Start with a free trial <a href="#start-with-a-free-trial" id="start-with-a-free-trial"></a>

When you create a new n8n Cloud trial, you have 14 days to try all the features of the [Pro plan](https://n8n.io/pricing/), including:

* Global variables
* Insights dashboard
* Execution search
* Five days of workflow history to roll back

The trial gives you Pro plan features with a limit of 1000 executions and the same computing power as the [Starter plan](https://n8n.io/pricing/).

## Compare n8n Cloud plans <a href="#compare-n8n-cloud-plans" id="compare-n8n-cloud-plans"></a>

After your trial, you can move to a paid plan. Each plan suits a different user and includes different features, usage limits, and computing power.

The following plans are available for n8n Cloud users:

| Plan           | Designed for                                                                      |
| -------------- | --------------------------------------------------------------------------------- |
| **Free trial** | Trying n8n Cloud with Pro features for 14 days                                    |
| **Starter**    | Individuals and small projects getting started                                    |
| **Pro**        | Power users and small teams that need higher limits, admin accounts, and insights |
| **Enterprise** | Organizations that need advanced security, scaling, and dedicated support         |

{% hint style="info" %}
**Always check current pricing and conditions**

Exact features, usage limits, and prices for each plan can change. For the current details, see the [pricing page](https://n8n.io/pricing/). This page explains what the plans are, not the specifics of what each one includes.
{% endhint %}

## Upgrade to a paid plan <a href="#upgrade-to-a-paid-account" id="upgrade-to-a-paid-account"></a>

You can upgrade to a paid plan at any time during your trial. To upgrade from the n8n Cloud console:

1. Open the [Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console).
2. Select **Upgrade plan** in the trial banner at the top of the page. You can also go to **Billing** and select **Upgrade plan**. n8n opens the **Choose a plan** page.
3. Choose **Monthly** or **Annual** billing.
4. Select **Select plan** on the plan you want.
5. Enter your payment details and complete the checkout.

In the n8n editor, the upgrade button in the trial banner at the top of the page opens the same **Choose a plan** page in the Cloud console.

## When your trial ends <a href="#trial-expiration" id="trial-expiration"></a>

If you don't upgrade by the end of your trial, the trial automatically expires and n8n deletes your instance.

{% hint style="info" %}
**Download your workflows**

You can [download your workflows](/deploy/use-n8n-cloud/download-workflows) to reuse them later. You have 90 days to download your workflows after your free trial ends.
{% endhint %}

### Cancelling your trial <a href="#cancelling-your-trial" id="cancelling-your-trial"></a>

You don't need to cancel your trial. Your trial automatically expires at the end of the trial period and no charges occur. n8n deletes all your data soon after.

## Enterprise trial <a href="#enterprise-trial" id="enterprise-trial"></a>

To test the [Enterprise plan](https://n8n.io/pricing/), contact the sales team. The Enterprise plan includes features such as:

* SSO (SAML and LDAP)
* Environments
* External secrets
* Log streaming
* Version control using Git

Select the **Contact** button on the [n8n website](https://n8n.io/pricing/). For guidance on rolling out Enterprise after you subscribe, see the [Enterprise Hub](/enterprise-hub).

## Related resources

* [Use n8n Cloud](/deploy/use-n8n-cloud)
* [Use the Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console)
* [Update your version](/deploy/use-n8n-cloud/update-your-version)
* [Configure Cloud](/deploy/use-n8n-cloud/configure-cloud)
* [Gateway credits](/deploy/use-n8n-cloud/gateway-credits)
* [Assistant credits](/deploy/use-n8n-cloud/assistant-credits)
* [Understand concurrency](/deploy/use-n8n-cloud/understand-concurrency)
* [Download workflows](/deploy/use-n8n-cloud/download-workflows)


# Use the Cloud console

How to open and find your way around the n8n Cloud console, where instance owners manage their n8n Cloud instance, plan, and credits.

The n8n Cloud console at [app.n8n.cloud](https://app.n8n.cloud) is where the instance owner manages their n8n Cloud instance, plan, billing, and credits.

Only the instance owner can open the Cloud console. Other users on the instance work in the n8n editor and don't have access to it.

## Pages in the Cloud console

The left sidebar of the Cloud console has these pages:

* **Overview**: your instance's status, with **Open instance** to go to the editor. It also shows your plan, execution usage, credit balances, n8n version, latest backup, and recent activity.
* **Instance settings**: change your n8n version, release track, update cadence, and maintenance window. Set the time zone and which executions to save, and turn Gateway credits and verified community nodes on or off. You can also restart your instance and delete your account here.
* **Assistant credits**: check and top up the [Assistant credits](/deploy/use-n8n-cloud/assistant-credits) that pay for n8n Assistant.
* **Gateway credits**: check and top up the [Gateway credits](/deploy/use-n8n-cloud/gateway-credits) that pay for AI models and services in your workflows.
* **Billing**: see your current plan, change or cancel it, change your payment method, and view your transaction history.
* **Export**: [download your workflows](/deploy/use-n8n-cloud/download-workflows) from a backup.

The **Assistant credits** and **Gateway credits** pages only appear if those features are available for your instance.

Select **Help & resources** at the bottom of the sidebar for links to the help center, documentation, community forum, and workflow templates.

## Open the Cloud console from n8n

1. Log in to your n8n instance as the instance owner.
2. In the left menu, select **Admin Panel**. n8n opens the Cloud console.

## Open the Cloud console with a magic link

You can sign in to the Cloud console with a magic link sent to your email. This works even if your instance is offline, for example because it can't start.

1. Go to [app.n8n.cloud/magic-link](https://app.n8n.cloud/magic-link).
2. In **Instance owner email**, enter the email address of the instance owner account.
3. Select **Send magic link**.
4. Open the email from n8n and select the link to sign in.

On the [app.n8n.cloud](https://app.n8n.cloud) sign-in page, you can also select **Don't know your instance name?**, then **Sign in to the Cloud console**, to reach the same page.

## Restart your instance

If your instance is offline or not responding, restart it from the Cloud console:

1. Open the Cloud console and select **Instance settings**.
2. Select **Restart** next to the instance status at the top of the page.
3. Select **Restart instance** to confirm.

Your instance is offline until the restart completes, and any running executions stop.

## Related resources

* [Use n8n Cloud](/deploy/use-n8n-cloud)
* [Try free then choose a plan](/deploy/use-n8n-cloud/start-your-free-trial)
* [Update your version](/deploy/use-n8n-cloud/update-your-version)
* [Configure Cloud](/deploy/use-n8n-cloud/configure-cloud)
* [Gateway credits](/deploy/use-n8n-cloud/gateway-credits)
* [Assistant credits](/deploy/use-n8n-cloud/assistant-credits)
* [Understand concurrency](/deploy/use-n8n-cloud/understand-concurrency)
* [Download workflows](/deploy/use-n8n-cloud/download-workflows)


# Update your version

How to update your n8n version on Cloud.

n8n recommends keeping your Cloud version up to date. In the **Updates** section of **Instance settings** in the n8n Cloud console, you choose which n8n version your instance runs, and control when and how automatic updates happen. Check the [Release notes](https://docs.n8n.io/changelog/) to learn about changes in each version.

{% hint style="info" %}
Only instance owners can change these settings. Contact your instance owner if you don't have permission to update n8n Cloud.
{% endhint %}

To open the settings:

1. Open the [Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console).
2. In the sidebar, select **Instance settings**. The **Updates** section is at the top of the page.

When you change a setting, a bar appears at the bottom of the page with the number of unsaved changes:

* If you changed the n8n version, select **Save and restart**. Your instance restarts and is unavailable for one to two minutes.
* If you only changed the release track, update cadence, or maintenance window, select **Save**. These settings apply without a restart.

Select **Discard all** to undo your unsaved changes.

## n8n version

The **n8n version** dropdown sets the version your instance runs. To compare versions before you change, select **Open changelog**.

To change the version:

1. Choose a version from the **n8n version** dropdown.
2. Select **Save and restart**.
3. If the new version is a major version or runs a database migration, n8n asks you to confirm. Read the warning, then select **Update and restart**. You can't roll back these updates to the previous version.

## Release track

The release track sets which n8n release stream your instance follows. n8n tests both tracks. They differ in how soon new releases reach your instance, and how long each release has run in production before it does:

* **Beta**: new releases delivered as soon as they're ready. Choose Beta to try the latest features first.
* **Stable**: a later, more proven patch of a release, cut after it's spent time on the Beta track. n8n recommends Stable for all mission-critical workloads.

You can switch between tracks at any time. For how n8n versions and feature availability relate to your release track, see [Understand feature availability](/administer/understand-feature-availability#feature-availability-by-n8n-version).

## Update cadence

The update cadence sets how often n8n upgrades your instance to a newer build. n8n upgrades every instance at least every two weeks, so security fixes reach everyone, whichever cadence you choose:

* **Every 2 weeks**: n8n upgrades your instance about every two weeks. Recommended for most instances.
* **Every new release**: upgrades to each new release as it ships, on average one release per day. Great for trying out new features.

## Maintenance window

The maintenance window sets when n8n can apply upgrades, so you can reduce disruption. Each upgrade takes one to two minutes of downtime. Times use your instance's time zone, shown in the setting's description.

* **Anytime**: n8n applies upgrades as soon as they're available.
* **Pick a window**: n8n only applies upgrades between the **Start time** and **End time** you set.

## Related resources

* [Use n8n Cloud](/deploy/use-n8n-cloud)
* [Try free then choose a plan](/deploy/use-n8n-cloud/start-your-free-trial)
* [Use the Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console)
* [Configure Cloud](/deploy/use-n8n-cloud/configure-cloud)
* [Gateway credits](/deploy/use-n8n-cloud/gateway-credits)
* [Assistant credits](/deploy/use-n8n-cloud/assistant-credits)
* [Understand concurrency](/deploy/use-n8n-cloud/understand-concurrency)
* [Download workflows](/deploy/use-n8n-cloud/download-workflows)


# Configure Cloud

Configure timezone, IP addresses, data management, and ownership settings for your n8n Cloud instance.

## In this section

* [Set your timezone](/deploy/use-n8n-cloud/configure-cloud/set-your-timezone): set your timezone on n8n Cloud.
* [Find your IP addresses](/deploy/use-n8n-cloud/configure-cloud/find-your-ip-addresses): the IP addresses n8n Cloud uses.
* [Manage your data](/deploy/use-n8n-cloud/configure-cloud/manage-your-data): manage your data on n8n Cloud.
* [Change instance ownership or username](/deploy/use-n8n-cloud/configure-cloud/change-instance-ownership-or-username): transfer ownership or change your username.

## Related resources

* [Use n8n Cloud](/deploy/use-n8n-cloud)
* [Try free then choose a plan](/deploy/use-n8n-cloud/start-your-free-trial)
* [Use the Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console)
* [Update your version](/deploy/use-n8n-cloud/update-your-version)
* [Gateway credits](/deploy/use-n8n-cloud/gateway-credits)
* [Assistant credits](/deploy/use-n8n-cloud/assistant-credits)
* [Understand concurrency](/deploy/use-n8n-cloud/understand-concurrency)
* [Download workflows](/deploy/use-n8n-cloud/download-workflows)


# Set your timezone

How to set your timezone on n8n Cloud.

You can change the timezone for your n8n instance. This affects the [Schedule Trigger](/integrations/builtin/core-nodes/n8n-nodes-base.scheduletrigger) and [Date & Time node](/integrations/builtin/core-nodes/n8n-nodes-base.datetime). Users can configure the timezone for individual workflows in [Workflow settings](/build/manage-workflows/configure-workflow-settings).

To change the instance timezone:

1. Open the [n8n Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console) and select **Instance settings**.
2. In the **Runtime** section, select the timezone you want from the **Time zone** dropdown. You can type to search the list.
3. Select **Save and restart** in the bar at the bottom of the page. Your instance restarts to apply the change, and is offline until the restart completes.

## Related resources

* [Configure Cloud](/deploy/use-n8n-cloud/configure-cloud)
* [Find your IP addresses](/deploy/use-n8n-cloud/configure-cloud/find-your-ip-addresses)
* [Manage your data](/deploy/use-n8n-cloud/configure-cloud/manage-your-data)
* [Change instance ownership or username](/deploy/use-n8n-cloud/configure-cloud/change-instance-ownership-or-username)


# Find your IP addresses

When a workflow on n8n Cloud sends an outbound request, for example from the **HTTP Request** node or an app node, the request comes from one of the IP addresses on this page. Use these addresses to allowlist n8n Cloud in a firewall or a service that limits access by IP address. Inbound webhook traffic to your instance doesn't use these addresses.

## How n8n Cloud outbound IP addresses work

n8n Cloud runs on shared infrastructure. Many instances share each address, so there's no address unique to your instance. Your instance normally keeps the same address. It changes only in rare cases where n8n has to move instances between clusters. n8n doesn't send advance notice of these changes.

Because these addresses are shared, an IP allowlist alone doesn't prove a request came from your instance. Always require authentication on the services you expose to n8n Cloud.

## n8n Cloud outbound IP address list

n8n recommends that you allowlist every address in this list. In practice, these addresses rarely change. The most reliable way to know which address your instance uses at any point in time is to [check it with a workflow](#find-the-address-your-instance-currently-uses). n8n may add new addresses over time, so if your allowlist starts blocking requests from n8n Cloud, check this page for new ones. Entries ending in `/28` are blocks of 16 addresses. Entries ending in `/32` are single addresses.

```
4.165.103.112/28
4.182.64.64/28
4.184.78.240/28
9.223.34.48/28
20.52.126.0/28
20.79.32.32/28
20.218.174.0/28
20.218.238.112/28
20.240.52.208/28
20.240.204.176/28
51.107.180.112/28
51.116.119.64/28
4.182.88.118/32
4.182.111.50/32
4.182.128.108/32
4.182.129.20/32
4.182.190.144/32
4.182.191.184/32
4.182.212.136/32
72.144.69.38/32
72.144.83.147/32
72.144.111.50/32
72.144.128.145/32
98.67.233.91/32
98.67.233.200/32
98.67.244.108/32
```

## Find the address your instance currently uses

To allowlist a narrower set, check which address your instance uses now:

1. Create a workflow with a **Manual Trigger** node and an **HTTP Request** node.
2. In the **HTTP Request** node, set **Method** to `GET` and **URL** to an IP echo service, for example `https://api.ipify.org?format=json`. A third party, not n8n, runs this example service.
3. Select **Execute workflow**. The **HTTP Request** node's output shows your instance's current outbound address in the `ip` field.

To confirm over time that the address hasn't changed, add a **Schedule Trigger** node, connect it to the **HTTP Request** node, and publish the workflow.

{% hint style="warning" %}
**A single address isn't guaranteed**

This workflow is a convenience, not a guarantee. Your instance's address can change without notice. If you allowlist only that address, your workflows may stop working when it changes.
{% endhint %}

## Related resources

* [Configure Cloud](/deploy/use-n8n-cloud/configure-cloud)
* [Set your timezone](/deploy/use-n8n-cloud/configure-cloud/set-your-timezone)
* [Manage your data](/deploy/use-n8n-cloud/configure-cloud/manage-your-data)
* [Change instance ownership or username](/deploy/use-n8n-cloud/configure-cloud/change-instance-ownership-or-username)


# Manage your data

How to manage your data on n8n Cloud.

There are two concerns when managing data on n8n Cloud:

* Memory usage: complex workflows processing large amounts of data can exceed n8n's memory limits. If this happens, the instance can crash and become inaccessible.
* Data storage: depending on your execution settings and volume, your n8n database can grow in size and run out of storage.

To avoid these issues, n8n recommends that you build your workflows with memory efficiency in mind, and don't save unnecessary data

## Memory limits on each n8n Cloud plan <a href="#memory-limits-on-each-cloud-plan" id="memory-limits-on-each-cloud-plan"></a>

Current plans:

* Trial: 640MiB RAM, 10 millicore CPU burstable
* Starter: 640MiB RAM, 10 millicore CPU burstable
* Pro-1 (10k executions): 640MiB RAM, 20 millicore CPU burstable
* Pro-2 (50k executions): 1280MiB RAM, 80 millicore CPU burstable
* Enterprise: 4096MiB RAM, 80 millicore CPU burstable

Legacy plans:

* Start: 320MiB RAM, 10 millicore CPU burstable
* Power: 1280MiB RAM, 80 millicore CPU burstable

n8n gives each instance up to 100GB of data storage.

## How to reduce memory consumption in your workflow <a href="#how-to-reduce-memory-consumption-in-your-workflow" id="how-to-reduce-memory-consumption-in-your-workflow"></a>

The way you build workflows affects how much data they consume when executed. Although these guidelines aren't applicable to all cases, they provide a baseline of best practices to avoid exceeding instance memory.

* Split the data processed into smaller chunks. For example, instead of fetching 10,000 rows with each execution, process 200 rows with each execution.
* Avoid using the Code node where possible.
* Avoid manual executions when processing larger amounts of data.
* Split the workflow up into sub-workflows and ensure each sub-workflow returns a limited amount of data to its parent workflow.

Splitting the workflow might seem counter-intuitive at first as it usually requires adding at least two more nodes: the [Loop Over Items](/integrations/builtin/core-nodes/n8n-nodes-base.splitinbatches) node to split up the items into smaller batches and the [Execute Workflow](/integrations/builtin/core-nodes/n8n-nodes-base.executeworkflow) node to start the sub-workflow.

However, as long as your sub-workflow does the heavy lifting for each batch and then returns only a small result set to the main workflow, this reduces memory consumption. This is because the sub-workflow only holds the data for the current batch in memory, after which the memory is free again.

Note that n8n itself consumes memory to run. On average, the software alone uses around 180MiB RAM.

Interactions with the UI also consume memory. Playing around with the workflow UI while it performs heavy executions could also push the memory capacity over the limit.

## How to manage execution data on n8n Cloud <a href="#how-to-manage-execution-data-on-cloud" id="how-to-manage-execution-data-on-cloud"></a>

Execution data includes node data, parameters, variables, execution context, and binary data references. It's text-based.

Binary data is non-textual data that n8n can't represent as plain text. This is files and media such as images, documents, audio files, and videos. It's much larger than textual data.

If a workflow consumes a large amounts of data and is past testing stage, it's a good option to stop saving the successful executions.

There are two ways you can control how much execution data n8n stores in the database:

In the n8n Cloud console:

1. Open the [Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console) and select **Instance settings**.
2. In the **Runtime** section, under **Executions to save**, deselect the execution types you don't want to log: **Manual**, **Failed**, or **Successful**.
3. Select **Save and restart** in the bar at the bottom of the page. Your instance restarts to apply the change.

In your workflow settings:

1. Select the **Options** <img src="https://2773773108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fjm0ZYRpZIPWge2ZSiDYO%2Fuploads%2Fgit-blob-f19a4d097d364587b73864eaed77b12bfd8f516b%2Fthree-dot-options-menu.png?alt=media" alt="Options menu" data-size="line"> menu.
2. Select **Settings**. n8n opens the **Workflow settings** modal.
3. Change **Save successful production executions** to **Do not save**.

## n8n Cloud data pruning and out of memory incident prevention <a href="#cloud-data-pruning-and-out-of-memory-incident-prevention" id="cloud-data-pruning-and-out-of-memory-incident-prevention"></a>

### Automatic data pruning <a href="#automatic-data-pruning" id="automatic-data-pruning"></a>

n8n automatically prunes execution logs after a certain time or once you reach the max storage limit, whichever comes first. The pruning always happens from oldest to newest and the limits depend on your n8n Cloud plan:

* Start and Starter plans: max 2500 executions saved and 7 days execution log retention;
* Pro plans: max 25000 executions saved and 30 days execution log retention;
* Enterprise plan: max 50000 executions saved and unlimited execution log retention time.

You reach the maximum storage limit either by exceeding the maximum number of saved executions or by exceeding the instance's database storage size. If the instance's database reaches this limit, n8n removes only the execution data and keeps the execution record. Pruning based on execution count or retention time, however, removes the record completely.

### Manual data pruning <a href="#manual-data-pruning" id="manual-data-pruning"></a>

Heavier executions and use cases can exceed database capacity despite the automatic pruning practices. In cases like this, n8n will manually prune data to protect instance stability.

1. An alert system warns n8n if an instance is at 85% disk capacity.
2. n8n prunes execution data. n8n does this by running a backup of the instance (workflows, users, credentials and execution data) and restoring it without execution data.

Due to the human steps in this process, the alert system isn't perfect. If warnings are triggered after hours or if data consumption rates are high, there might not be time to prune the data before the remaining disk space fills up.

## Related resources

* [Configure Cloud](/deploy/use-n8n-cloud/configure-cloud)
* [Set your timezone](/deploy/use-n8n-cloud/configure-cloud/set-your-timezone)
* [Find your IP addresses](/deploy/use-n8n-cloud/configure-cloud/find-your-ip-addresses)
* [Change instance ownership or username](/deploy/use-n8n-cloud/configure-cloud/change-instance-ownership-or-username)


# Change instance ownership or username

### Change instance ownership <a href="#change-instance-ownership" id="change-instance-ownership"></a>

You can change the ownership of an instance by navigating to the **Settings > Profile & preferences** page in the owner's account and editing the **Email** field. After making the changes, scroll down and press **Save**. Note that for the change to be effective, the new email address must not be associated with any other n8n account, as each instance can have only one **unique owner email**. If the intended email is already linked to an existing user, change or delete that user first so the email becomes available.

Changing emails will change the owner of the instance, the email you log in with, and the email your invoices and general communication gets sent to.

If the instance is deactivated, there will be no **Settings** page and no possibility to change the email address or the owner info.

### Change instance username <a href="#change-instance-username" id="change-instance-username"></a>

It's not currently possible to change usernames.

If you want your instance to have a different name you will need to create a new account and transfer your work into it. [The import/export documentation](/build/manage-workflows/export-and-import) explains how you can transfer your work to a new n8n instance.

### Related resources

* [Configure Cloud](/deploy/use-n8n-cloud/configure-cloud)
* [Set your timezone](/deploy/use-n8n-cloud/configure-cloud/set-your-timezone)
* [Find your IP addresses](/deploy/use-n8n-cloud/configure-cloud/find-your-ip-addresses)
* [Manage your data](/deploy/use-n8n-cloud/configure-cloud/manage-your-data)


# Understand concurrency

{% hint style="info" %}
**Only for n8n Cloud**

This document discusses concurrency in n8n Cloud. Read [self-hosted n8n concurrency control](/deploy/host-n8n/configure-n8n/scaling/control-concurrency) to learn how concurrency works with self-hosted n8n instances.
{% endhint %}

Too many concurrent executions can cause performance degradation and unresponsiveness. To prevent this and improve instance stability, n8n sets concurrency limits for production executions in regular mode.

Any executions beyond the limits queue for later processing. These executions remain in the queue until concurrency capacity frees up, and are then processed in FIFO order.

## Concurrency limits <a href="#concurrency-limits" id="concurrency-limits"></a>

n8n limits the number of concurrent executions for Cloud instances according to their plan. Refer to [Pricing](https://n8n.io/pricing/) for details.

You can view the number of active executions and your plan's concurrency limit at the top of a project's or workflow's executions tab.

## Details <a href="#details" id="details"></a>

Some other details about concurrency to keep in mind:

* Concurrency control applies only to production executions: those started from a webhook or trigger node. It doesn't apply to any other kinds, such as manual executions, sub-workflow executions, or error executions.
* [Test evaluations](#user-content-fn-1)[^1] don't count towards production concurrency limits. They use a separate per-plan limit for how many test cases can run in parallel within a single test run: self-hosted Community and n8n Cloud Pro run 1 (sequential), self-hosted Business runs 3, and Enterprise (both n8n Cloud and self-hosted) runs 5. You can adjust the value for a given run from the **Run Test** popover. Refer to [Metric-based evaluations](/build/integrate-ai/test-and-improve-ai-workflows/use-metrics-to-measure-quality#run-test-cases-in-parallel) for details.
* You can't retry queued executions. Cancelling or deleting a queued execution also removes it from the queue.
* On instance startup, n8n resumes queued executions up to the concurrency limit and re-enqueues the rest.

## Comparison to queue mode <a href="#comparison-to-queue-mode" id="comparison-to-queue-mode"></a>

{% hint style="info" %}
**Feature availability**

Queue mode is available for n8n Cloud Enterprise plans. To enable it, [contact n8n](https://n8n-community.typeform.com/to/y9X2YuGa).
{% endhint %}

Concurrency in queue mode is a separate mechanism from concurrency in regular mode. In queue mode, the concurrency settings determine how many jobs each worker can run in parallel. In regular mode, concurrency limits apply to the entire instance.

## Related resources

* [Use n8n Cloud](/deploy/use-n8n-cloud)
* [Try free then choose a plan](/deploy/use-n8n-cloud/start-your-free-trial)
* [Use the Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console)
* [Update your version](/deploy/use-n8n-cloud/update-your-version)
* [Configure Cloud](/deploy/use-n8n-cloud/configure-cloud)
* [Gateway credits](/deploy/use-n8n-cloud/gateway-credits)
* [Assistant credits](/deploy/use-n8n-cloud/assistant-credits)
* [Download workflows](/deploy/use-n8n-cloud/download-workflows)

[^1]: In n8n, evaluation allows you to tag and organize execution history and compare it against new executions. You can use this to understand how your workflow performs over time as you make changes. In particular, this is useful while developing AI-centered workflows.


# Gateway credits

Use Gateway credits to run AI models and third-party services in your n8n workflows without provider accounts or API keys.

Gateway credits let you use supported AI models and third-party services in your workflows without creating provider accounts or managing API keys. Instead of setting up a credential, you select Gateway credits on a supported node, and n8n bills the usage from a prepaid credit balance.

Gateway credits only pay for nodes in your workflows. They don't pay for n8n Assistant, which uses separate [Assistant credits](/deploy/use-n8n-cloud/assistant-credits), starting with a monthly allowance included in your plan. Topping up Gateway credits doesn't give n8n Assistant more credits.

## In this section

* [Top up Gateway credits](/deploy/use-n8n-cloud/gateway-credits/top-up-gateway-credits): add credit manually or automatically.
* [Track Gateway credit spend](/deploy/use-n8n-cloud/gateway-credits/track-gateway-credit-spend): monitor your balance, spend, and top-up history.

{% hint style="info" %}
**Feature availability**

Gateway credits are available on:

* **n8n Cloud:** Starter, Pro

They aren't available on n8n Cloud Enterprise or self-hosted n8n. Gateway credits are available from n8n 2.36.0. Free trials include Gateway credits, but you can't top up until you upgrade to a paid plan.
{% endhint %}

## How Gateway credits work

When you select **Use Gateway credits** on a supported node, n8n routes the node's requests through an n8n-managed gateway to the service provider. The gateway authenticates with the provider on n8n's behalf, so you don't need a provider account. n8n deducts the cost of each request from your credit balance.

n8n bills usage per request at the rates listed on the [service pricing page](https://app.n8n.cloud/service-pricing). Rates vary by model and service, and change as providers update their pricing, so the service pricing page is always the source of truth for current rates.

To learn how to select Gateway credits on a node and find supported nodes in the editor, see [Use Gateway credits](/build/understand-workflows/use-gateway-credits).

## Supported services

Gateway credits cover two categories of service:

* **AI models**: large language model providers such as OpenAI, Anthropic, and Google Gemini.
* **Tool services**: services for tasks like web search, web scraping, browser automation, and document parsing, such as Brave Search and Firecrawl.

The catalogue grows over time. For the current list of supported services and models, check the [service pricing page](https://app.n8n.cloud/service-pricing). In the editor, the **Included in n8n** section of the nodes panel shows the nodes you can use with Gateway credits.

Services that aren't in the catalogue still work in n8n the usual way: create a credential with your own API key. Refer to [Create and edit credentials](/build/understand-workflows/create-and-edit-credentials) for details.

## Your credit balance

Each Cloud instance has one credit balance, shared by everyone who uses Gateway credits on that instance. You can see the balance in the editor next to the Gateway credits option on a node, and on the **Gateway credits** page in the [n8n Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console), which also shows your spend over time. Refer to [Track Gateway credit spend](/deploy/use-n8n-cloud/gateway-credits/track-gateway-credit-spend) for details.

New Cloud users receive a small amount of free credit at sign-up, so you can try supported services before you buy credits. Free trials include Gateway credits too: you can use them from your first workflow.

When your balance reaches zero, nodes using Gateway credits stop working until you add credit. Nodes using your own credentials aren't affected. If the balance runs out in the middle of an execution, n8n lets the in-flight requests finish rather than stopping them partway through, and deducts the difference from your next top-up. On a paid plan, you can [top up your balance](/deploy/use-n8n-cloud/gateway-credits/top-up-gateway-credits) manually or automatically. Topping up isn't available during a free trial, so if you use up your free credit while trialing, upgrade to a paid plan to add more.

### Credit expiry and forfeiture

* n8n uses free credits before top-up credits, and uses the credits that expire soonest first.
* Top-up credits expire 12 months after purchase.
* Credits aren't cash and you can't transfer them to another account.
* Top-ups are final. n8n doesn't refund unused credits except where required by law.
* If you close your n8n account, you forfeit any remaining credits. Canceling your subscription doesn't forfeit credits while your account still exists.

## Gateway credits and other credit types

n8n has more than one kind of credit. They have separate balances and pay for different things:

| Credit type                                                  | What it pays for                                                                                                               | Where you see it                                                                                     |
| ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------- |
| Gateway credits                                              | AI models and tool services used by nodes in your workflows                                                                    | On supported nodes, and on the **Gateway credits** page in the Cloud console                         |
| [Assistant credits](/deploy/use-n8n-cloud/assistant-credits) | Your usage of [n8n Assistant](/build/ways-of-building-workflows/n8n-assistant), from a monthly allowance included in your plan | In the n8n Assistant panel in the editor, and on the **Assistant credits** page in the Cloud console |
| Free OpenAI API credits                                      | A legacy one-time OpenAI allowance for new Cloud users                                                                         | Only on instances without Gateway credits                                                            |

Topping up Gateway credits doesn't add Assistant credits, and using n8n Assistant doesn't spend your Gateway credit balance.

## Data handling

When a node runs on Gateway credits, n8n sends the request through its gateway to the service provider under n8n's own provider account. The provider receives the content of the request, such as the prompt you send to a model or the text you send to a parser, but not your identity or n8n account details. For more on how n8n handles your data, refer to [Privacy](https://docs.n8n.io/privacy-and-security/) and n8n's terms of service.

## Related resources

* [Use n8n Cloud](/deploy/use-n8n-cloud)
* [Try free then choose a plan](/deploy/use-n8n-cloud/start-your-free-trial)
* [Use the Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console)
* [Update your version](/deploy/use-n8n-cloud/update-your-version)
* [Configure Cloud](/deploy/use-n8n-cloud/configure-cloud)
* [Assistant credits](/deploy/use-n8n-cloud/assistant-credits)
* [Understand concurrency](/deploy/use-n8n-cloud/understand-concurrency)
* [Download workflows](/deploy/use-n8n-cloud/download-workflows)
* [Use Gateway credits](/build/understand-workflows/use-gateway-credits): select Gateway credits on a node and find supported nodes.
* [Service pricing page](https://app.n8n.cloud/service-pricing): current rates for all supported services and models.


# Top up Gateway credits

Add credit to your Gateway credits balance manually or with auto top-up in the n8n Cloud console.

When your [Gateway credits](/deploy/use-n8n-cloud/gateway-credits) balance runs low, top it up from the n8n Cloud console. You can add credit manually whenever you need it, or turn on auto top-up so n8n refills your balance for you.

Only the instance owner can top up, and topping up requires an active paid subscription. Free trials include Gateway credits, but not top-ups: if you use up your free credit during a trial, upgrade to a paid plan to add more.

## Topping up Gateway credits after subscription cancellation

Gateway credit top-ups are available only with an active paid n8n Cloud subscription on Starter or Pro plans. If you cancel your subscription renewal, you keep access to your instance and any remaining Gateway credits until the end of your current billing period. However, you can't purchase additional Gateway credits during this time, and the **Top up** option no longer appears on the Gateway credits page.

To buy more Gateway credits after canceling your subscription renewal, resubscribe to a paid Starter or Pro plan in the [Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console). After you resubscribe, you can select **Top up** again under **Gateway credits** → **Balance**.

{% hint style="warning" %}
**Gateway credits don't pay for n8n Assistant**

Gateway credits only pay for AI models and services that nodes use in your workflows. To get more credits for n8n Assistant, [top up Assistant credits](/deploy/use-n8n-cloud/assistant-credits/top-up-assistant-credits) instead. Top-ups are final, so check which balance you're topping up before you pay.
{% endhint %}

## Top up manually

1. Open the [Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console) and select **Gateway credits** in the sidebar.
2. On the **Balance** card, select **Top up**.
3. Choose an amount.
4. Read the credit terms and select the checkbox to accept them.
5. Select **Continue to checkout** and complete the payment. You can pay with the payment method saved on your subscription or with a different one. Taxes may apply depending on your billing country. n8n emails you an invoice.

Your new balance appears on the page once the payment completes.

## Set up auto top-up

Auto top-up refills your balance whenever it drops below a threshold you set, keeping it above zero so workflows that rely on Gateway credits keep running. Unlike manual top-ups, auto top-up always charges the payment method saved on your subscription.

1. Open the [Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console) and select **Gateway credits** in the sidebar.
2. On the **Auto top-up** card, turn on auto top-up.
3. Set **When balance drops to** (the balance that triggers a top-up) and **Top up to** (the balance to refill to).
4. Optionally, turn on **Monthly auto top-up limit** to cap how much auto top-up can add per month.
5. Select **Save changes**, then select **Turn on auto top-up** to confirm.

{% hint style="info" %}
If your balance is already below the threshold when you save, n8n triggers a one-time top-up straight away to reach your target balance. The page shows the estimated cost before you save.
{% endhint %}

How auto top-up behaves:

* n8n emails you an invoice each time auto top-up adds credit.
* If you set a monthly limit, auto top-up pauses once it adds that amount in the current month, and resumes the next month.
* If a payment fails, n8n retries. If the retries also fail, n8n turns auto top-up off and emails you. Because auto top-up always charges the payment method saved on your subscription, fix that payment method before turning it back on.

## Overspend

Your balance can run out in the middle of an execution. When that happens, n8n lets the in-flight Gateway requests finish rather than stopping them partway through, so your balance can dip slightly below zero. n8n deducts the overspent amount from your next top-up, and the deduction appears in your [top-up history](/deploy/use-n8n-cloud/gateway-credits/track-gateway-credit-spend#top-up-history).

## Refunds

Top-ups are final. n8n doesn't refund unused credits except where required by law. If you think a charge is wrong, [contact n8n support](https://www.n8n.io/contact). For expiry and forfeiture rules, refer to [Credit expiry and forfeiture](/deploy/use-n8n-cloud/gateway-credits#credit-expiry-and-forfeiture).

## Related resources

* [Gateway credits](/deploy/use-n8n-cloud/gateway-credits): how Gateway credits work.
* [Track Gateway credit spend](/deploy/use-n8n-cloud/gateway-credits/track-gateway-credit-spend): monitor your balance, spend, and top-up history.
* [Service pricing page](https://app.n8n.cloud/service-pricing): current rates for all supported services and models.


# Track Gateway credit spend

Monitor your Gateway credits balance, spend by model or workflow, and top-up history in the n8n Cloud console.

The **Gateway credits** page in the n8n Cloud console shows your balance, your spend over time, and your top-up history. To open it, go to the [Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console) and select **Gateway credits** in the sidebar. You can also select **Manage** next to your Gateway balance on the **Overview** page.

You can also see your current balance in the editor, next to the Gateway credits option on supported nodes.

## Balance

The balance card shows your remaining credit, including how much of your free sign-up credit is left. If you're on a paid plan, you can top up from here. Refer to [Top up Gateway credits](/deploy/use-n8n-cloud/gateway-credits/top-up-gateway-credits) for details.

## Spend

The spend chart shows how your credit usage breaks down over time. You can:

* Change the time range to see recent or longer-term usage.
* Group spend by model or service, to see which providers cost the most.
* Group spend by workflow, to see which of your workflows consume the most credit.

Grouping by workflow helps you find a workflow that's spending more than you expect, for example one that calls a model on a frequent schedule.

## Top-up history

The top-up history lists every credit added to your balance: your free sign-up credit, manual top-ups, and auto top-ups. Each entry shows the amount, the date, and when those credits expire. Refunded top-ups stay in the list, marked as refunded.

If your balance dipped below zero because n8n let in-flight requests finish, the overspent amount is deducted from your next top-up and shown here. Refer to [Overspend](/deploy/use-n8n-cloud/gateway-credits/top-up-gateway-credits#overspend) for details.

## Notifications

n8n emails the instance owner about balance changes:

* When your balance runs low, so you can top up before workflows stop.
* When your balance is empty.
* When an auto top-up adds credit, fails to charge your payment method, or pauses because it reached your monthly limit.

## When your balance runs out

When your balance reaches zero, nodes using Gateway credits fail until you add credit. Executions that don't use Gateway credits keep running as normal.

* On a paid plan, [top up your balance](/deploy/use-n8n-cloud/gateway-credits/top-up-gateway-credits) or set up auto top-up to avoid interruptions.
* On a free trial, top-ups aren't available: upgrade to a paid plan to add more credit.
* On any plan, you can switch the affected nodes to your own credentials. Refer to [Use Gateway credits](/build/understand-workflows/use-gateway-credits) for how to switch.

## Related resources

* [Gateway credits](/deploy/use-n8n-cloud/gateway-credits): how Gateway credits work.
* [Top up Gateway credits](/deploy/use-n8n-cloud/gateway-credits/top-up-gateway-credits): add credit manually or automatically.
* [Service pricing page](https://app.n8n.cloud/service-pricing): current rates for all supported services and models.


# Assistant credits

Understand Assistant credits: the monthly allowance included in your n8n Cloud plan, extra credits, and how n8n bills your n8n Assistant usage.

Assistant credits pay for your usage of [n8n Assistant](/build/ways-of-building-workflows/n8n-assistant). Your n8n Cloud plan includes a monthly allowance of Assistant credits that resets on the first day of every month, so you can use n8n Assistant without buying anything. If you use up your allowance before it resets, you can buy extra credits to keep going until the next reset.

Assistant credits only pay for n8n Assistant. They don't pay for AI model calls that your workflows or agents make when they run, such as the model behind an AI Agent node. Those calls use [Gateway credits](/deploy/use-n8n-cloud/gateway-credits) or your own provider credentials.

## In this section

* [Top up Assistant credits](/deploy/use-n8n-cloud/assistant-credits/top-up-assistant-credits): buy extra credits manually or automatically.
* [Track Assistant credit spend](/deploy/use-n8n-cloud/assistant-credits/track-assistant-credit-spend): monitor your balance, spend, and top-up history.

{% hint style="info" %}
**Feature availability**

Assistant credits are available on:

* **n8n Cloud:** Starter, Pro

They aren't available on n8n Cloud Enterprise or self-hosted n8n. Free trials include a one-time allowance of Assistant credits.
{% endhint %}

## How Assistant credits work

n8n Assistant uses credits based on the tokens that the underlying AI model processes for each message. Longer conversations, larger workflows, and debugging sessions use more credits than short, focused requests. A message you stop partway through, or one that ends in an error, still uses credits for the work n8n Assistant did before it stopped.

Your Assistant credit balance has two parts:

* **Included credits**: the monthly allowance that comes with your plan. It resets on the first day of every month.
* **Extra credits**: credits you buy on top of your allowance. They carry over from month to month.

n8n Assistant always uses your included credits first. When they run out, it draws from your extra credits at the same rate, so n8n Assistant works the same way whichever credits it's using. If you haven't bought any extra credits, n8n Assistant pauses until your included credits reset.

This is the main difference from [Gateway credits](/deploy/use-n8n-cloud/gateway-credits), which are a single prepaid balance: with Gateway credits, you only have what you've bought. With Assistant credits, your plan tops you up every month, and extra credits are optional.

Running a workflow doesn't use Assistant credits, even if n8n Assistant built it. Only your conversations with n8n Assistant do.

## Included monthly allowance

The size of your monthly allowance depends on your plan. For the current allowance on each plan, refer to [n8n plans and pricing](https://n8n.io/pricing/).

How the allowance works:

* Included credits reset on the first day of every calendar month, at midnight UTC. The reset doesn't follow your billing date.
* Unused included credits don't roll over. Each reset replaces any credits left over with a fresh allowance.
* If you start a paid plan partway through a month, you get the full monthly allowance for that month, not a reduced one.
* If you upgrade, your included credits for the current month change to the new plan's full allowance straight away.
* If you downgrade, you keep the higher allowance until the next reset. The lower allowance applies from then on.
* If you cancel your subscription, your included credits stop when the cancellation takes effect.

### Assistant credits during a free trial

Free trials include a one-time allowance of Assistant credits instead of a monthly one. The trial allowance doesn't reset. Topping up isn't available during a free trial, so if you use up your trial credits, upgrade to a paid plan to keep using n8n Assistant. Refer to [Try free then choose a plan](/deploy/use-n8n-cloud/start-your-free-trial) for details.

## Extra credits

Extra credits let you keep using n8n Assistant after you've used up your included credits for the month. They're optional: if you never buy any, n8n Assistant pauses when your included credits run out and resumes at the next reset.

* n8n Assistant only draws from extra credits after your included credits run out.
* Extra credits cost the same number of credits per message as included credits. Nothing changes in how n8n Assistant works.
* Extra credits carry over from month to month until they expire, 12 months after purchase.
* Only the instance owner can buy extra credits, and buying them requires an active paid subscription.

You can buy extra credits manually or set up auto top-up so n8n buys them for you. Refer to [Top up Assistant credits](/deploy/use-n8n-cloud/assistant-credits/top-up-assistant-credits) for details.

## Your Assistant credit balance

Each Cloud instance has one Assistant credit balance, shared by everyone who uses n8n Assistant on that instance. Included and extra credits both come from this shared balance.

You can see the balance in the editor, in the credits menu of the n8n Assistant panel, and on the **Assistant credits** page in the [n8n Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console). That page also shows your spend over time and which users use the most credits. Refer to [Track Assistant credit spend](/deploy/use-n8n-cloud/assistant-credits/track-assistant-credit-spend) for details.

## When your Assistant credits run out

When your included credits and your extra credits are both used up, n8n Assistant pauses for everyone on the instance:

* In the editor, n8n Assistant shows **You've run out of AI credits**, and you can't send new messages.
* On the **Assistant credits** page in the Cloud console, a banner shows **The Assistant is paused for your instance**.

If your credits run out in the middle of a message, n8n lets that message finish rather than stopping it partway through. Your usage can go slightly past your balance as a result.

To start using n8n Assistant again:

* On a paid plan, the instance owner can [buy extra credits](/deploy/use-n8n-cloud/assistant-credits/top-up-assistant-credits), or you can wait for your included credits to reset on the first day of the next month.
* On a free trial, upgrade to a paid plan.

Your workflows aren't affected. Workflows keep running when your Assistant credits run out, because running a workflow doesn't use Assistant credits.

## Credit expiry and forfeiture

Assistant credits follow the same expiry and forfeiture rules as Gateway credits:

* n8n uses included credits before extra credits. Among extra credits, n8n uses the credits that expire soonest first.
* Included credits expire when your allowance resets on the first day of the next month.
* Extra credits expire 12 months after purchase.
* Credits aren't cash and you can't transfer them to another account.
* Top-ups are final. n8n doesn't refund unused credits except where required by law.
* If you close your n8n account, you forfeit any remaining credits. Canceling your subscription doesn't forfeit extra credits while your account still exists.

## Assistant credits and Gateway credits

Assistant credits and Gateway credits are separate balances that pay for different things:

|                         | Assistant credits                                                                           | Gateway credits                                             |
| ----------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| What they pay for       | Your conversations with n8n Assistant, including when it builds a workflow or agent for you | AI models and tool services used by nodes in your workflows |
| What they don't pay for | AI model calls that your workflows or agents make when they run                             | n8n Assistant                                               |
| What your plan includes | A monthly allowance that resets on the first day of every month                             | A small one-time amount of free credit at sign-up           |
| Buying more             | Extra credits, used only after your included credits run out                                | Top-ups that add to your balance                            |
| Where you manage them   | The **Assistant credits** page in the Cloud console                                         | The **Gateway credits** page in the Cloud console           |

Topping up one doesn't add to the other. If n8n Assistant builds a workflow with a node that uses Gateway credits, running that node spends Gateway credits, not Assistant credits.

## n8n Assistant on self-hosted n8n

Self-hosted n8n doesn't use Assistant credits. On a self-hosted instance, n8n Assistant runs on AI models from your own provider account, which bills you directly. Refer to [Set up n8n Assistant](/deploy/host-n8n/configure-n8n/set-up-n8n-assistant) for details.

## Related resources

* [Use n8n Cloud](/deploy/use-n8n-cloud)
* [Try free then choose a plan](/deploy/use-n8n-cloud/start-your-free-trial)
* [Use the Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console)
* [Update your version](/deploy/use-n8n-cloud/update-your-version)
* [Configure Cloud](/deploy/use-n8n-cloud/configure-cloud)
* [Gateway credits](/deploy/use-n8n-cloud/gateway-credits)
* [Understand concurrency](/deploy/use-n8n-cloud/understand-concurrency)
* [Download workflows](/deploy/use-n8n-cloud/download-workflows)
* [Use n8n Assistant](/build/ways-of-building-workflows/n8n-assistant)
* [n8n plans and pricing](https://n8n.io/pricing/)


# Top up Assistant credits

Buy extra Assistant credits manually or with auto top-up in the n8n Cloud console, so you can keep using n8n Assistant after your monthly allowance runs out.

Your n8n Cloud plan includes a monthly allowance of [Assistant credits](/deploy/use-n8n-cloud/assistant-credits) that resets on the first day of every month. If you use up your included credits before the reset, top up with extra credits so you can keep using n8n Assistant. n8n Assistant only draws from extra credits after your included credits run out, and uses them at the same rate.

You can buy extra credits manually whenever you need them, or turn on auto top-up so n8n buys them for you.

Only the instance owner can top up, and topping up requires an active paid subscription. Free trials include a one-time allowance of Assistant credits, but not top-ups: if you use up your trial credits, upgrade to a paid plan to get more.

{% hint style="warning" %}
**Assistant credits only pay for n8n Assistant**

Extra Assistant credits only pay for your conversations with n8n Assistant. They don't pay for AI model calls that your workflows or agents make when they run. For those, [top up Gateway credits](/deploy/use-n8n-cloud/gateway-credits/top-up-gateway-credits) instead, or use your own provider credentials. Top-ups are final, so check which balance you're topping up before you pay.
{% endhint %}

## Top up manually

1. Open the [n8n Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console) and select **Assistant credits** in the sidebar.
2. On the **Balance** card, select **Top up**.
3. Choose a credit package.
4. Read the credit terms and select the checkbox to accept them.
5. Select **Continue to checkout** and complete the payment. Taxes may apply depending on your billing country.

Your new extra credits appear on the page once the payment completes. They expire 12 months after purchase.

## Set up auto top-up

Auto top-up buys extra credits whenever your extra credit balance drops below a threshold you set. Use it if you rely on n8n Assistant every day and don't want it to pause when your included credits run out. Auto top-up always charges the payment method saved on your subscription.

1. Open the [Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console) and select **Assistant credits** in the sidebar.
2. In the **Auto top-up extra credits** card, turn on auto top-up.
3. Set **When extra credits drop to** (the extra credit balance that triggers a top-up) and **Top up extra credits to** (the extra credit balance to refill to). The Cloud console shows the minimum values you can set.
4. Optionally, set a **Monthly auto top-up limit** to cap how much auto top-up can charge per month. The limit is on by default.
5. Select **Save changes**, then select **Turn on auto top-up** to confirm.

{% hint style="info" %}
Auto top-up only looks at your extra credits. Your included credits don't count toward the threshold, so auto top-up keeps a reserve of extra credits ready for when your included credits run out.
{% endhint %}

How auto top-up behaves:

* If you set a monthly limit, auto top-up pauses once it has charged that amount in the current calendar month (UTC), and resumes the next month.
* Auto top-up settings for Assistant credits are separate from auto top-up for [Gateway credits](/deploy/use-n8n-cloud/gateway-credits/top-up-gateway-credits). Turning one on doesn't turn on the other.

## Refunds

Top-ups are final. n8n doesn't refund unused credits except where required by law. If you think a charge is wrong, [contact n8n support](https://www.n8n.io/contact). For expiry and forfeiture rules, refer to [Credit expiry and forfeiture](/deploy/use-n8n-cloud/assistant-credits#credit-expiry-and-forfeiture).

## Related resources

* [Assistant credits](/deploy/use-n8n-cloud/assistant-credits)
* [Track Assistant credit spend](/deploy/use-n8n-cloud/assistant-credits/track-assistant-credit-spend)
* [Top up Gateway credits](/deploy/use-n8n-cloud/gateway-credits/top-up-gateway-credits)


# Track Assistant credit spend

Monitor your Assistant credit balance, spend, top users, and top-up history in the n8n Cloud console and the n8n Assistant panel.

The **Assistant credits** page in the n8n Cloud console shows your [Assistant credit](/deploy/use-n8n-cloud/assistant-credits) balance, spend over time, top users, and top-up history. To open it, go to the [Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console) and select **Assistant credits** in the sidebar. You can also select **Manage** next to your Assistant balance on the **Overview** page.

You can also check your balance in the editor, from the n8n Assistant panel.

## Balance

The balance card shows how many credits you have available, split into two parts:

* **Included**: how many of this month's included credits remain, and the date they reset.
* **Extra credits**: how many purchased extra credits remain. Extra credits carry over from month to month until they expire.

During a free trial, the card shows how much of your trial allowance remains.

A status label shows which credits n8n Assistant is using right now:

* **Within included**: n8n Assistant is using your included credits.
* **Using extra credits**: your included credits have run out, and n8n Assistant is using extra credits.
* **Paused — no extra credits**: you've used up both, and n8n Assistant stays paused until you top up or your included credits reset.

If you're the instance owner on a paid plan, you can top up from here. Refer to [Top up Assistant credits](/deploy/use-n8n-cloud/assistant-credits/top-up-assistant-credits) for details.

## Spend

The spend chart shows how many credits your instance used over the last 24 hours, 7 days, or 30 days. It splits usage into included credits and extra credits, so you can see how often you go past your monthly allowance.

If you use extra credits every month, compare the cost of topping up with the allowance on a higher plan. Refer to [n8n plans and pricing](https://n8n.io/pricing/).

## Top users

Everyone on your instance shares one Assistant credit balance. The top users card shows which users use the most credits, as a percentage of total usage, and groups everyone else under **Other users**.

## Top-up history

The top-up history lists the extra credits added to your balance, from both manual top-ups and auto top-ups. Each entry shows the amount, the date, and when those credits expire.

## Check your balance in the editor

In the editor, open the credits menu in the n8n Assistant panel to see:

* How many credits your instance has left. This number includes both included and extra credits.
* How many credits the current conversation has used so far.

When your balance drops to 10% or less, a banner above the chat input warns you that you're running low. You can dismiss the banner. It appears again the next time your balance crosses the threshold.

When your balance runs out, n8n Assistant shows **You've run out of AI credits**, and you can't send new messages. Refer to [When your Assistant credits run out](/deploy/use-n8n-cloud/assistant-credits#when-your-assistant-credits-run-out) for how to get more.

## Related resources

* [Assistant credits](/deploy/use-n8n-cloud/assistant-credits)
* [Top up Assistant credits](/deploy/use-n8n-cloud/assistant-credits/top-up-assistant-credits)
* [Track Gateway credit spend](/deploy/use-n8n-cloud/gateway-credits/track-gateway-credit-spend)


# Download workflows

How to download workflows from an n8n Cloud backup in the n8n Cloud console.

n8n Cloud instance owners can download their workflows from an n8n Cloud backup in the [n8n Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console). n8n creates backups automatically. They contain workflows only, never credentials.

## How to download workflows <a href="#how-to-download-workflows" id="how-to-download-workflows"></a>

1. Open the [Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console).
2. In the sidebar, select **Export**. n8n opens the **Data export** page.
3. In **Workflow backups**, use the **Backup** dropdown to choose which backup to export. If only one backup exists, n8n shows it instead of a dropdown.
4. Select **Download workflows**. The export opens in a new tab.

The **Latest backup** card on the **Overview** page shows when n8n created your most recent backup. Select **Download** on that card to go to the **Export** page.

If your instance is new or has been offline for a long time, it might not have any backups yet. In that case, the **Export** page shows **No backups available yet**.

Workflow export isn't available yet for instances that n8n hosts on PostgreSQL. For these instances, the **Export** page shows **Export is unavailable for this instance**, with a link to create a support ticket so n8n support can export your workflows.

## Accessing workflows after your free trial <a href="#accessing-workflows-after-your-free-trial" id="accessing-workflows-after-your-free-trial"></a>

You have **90 days** to download your workflows after your free trial ends. After that, all workflows will be **permanently deleted** and are unrecoverable.

## Related resources

* [Use n8n Cloud](/deploy/use-n8n-cloud)
* [Try free then choose a plan](/deploy/use-n8n-cloud/start-your-free-trial)
* [Use the Cloud console](/deploy/use-n8n-cloud/use-the-cloud-console)
* [Update your version](/deploy/use-n8n-cloud/update-your-version)
* [Configure Cloud](/deploy/use-n8n-cloud/configure-cloud)
* [Gateway credits](/deploy/use-n8n-cloud/gateway-credits)
* [Assistant credits](/deploy/use-n8n-cloud/assistant-credits)
* [Understand concurrency](/deploy/use-n8n-cloud/understand-concurrency)


# Host n8n

Access n8n hosting documentation and guides for setting up and managing self-hosted n8n instances.

You can self-host n8n on your own infrastructure, on-premises, or in a private cloud, using Docker Compose, one-line setup, or other deployment methods. Not sure if self-hosting is right for you? See [Choose how to use n8n](/choose-how-to-use-n8n).

{% hint style="success" %}
**Don't want to read the docs? Run this:**

```bash
curl -fsSL https://get.n8n.io | sh
```

Requires Docker on Linux or macOS (or WSL on Windows). Sets up n8n locally in one step. See the [one-line setup guide](/deploy/host-n8n/install-options/one-line-setup) for what it does, or keep reading to compare every installation method.
{% endhint %}

All self-hosted installations use the same core product. Without a license key, n8n runs as the free Community edition. Adding a Business or Enterprise license key enables those editions. See [Compare editions](/deploy/host-n8n/community-edition-features) for the differences between the self-hosted editions. For Enterprise rollout guidance, see the [Enterprise Hub](/enterprise-hub).

## In this section

* [Install options](/deploy/host-n8n/install-options): set up n8n with Docker, npm, Docker Compose, or a cloud provider.
* [Configure n8n](/deploy/host-n8n/configure-n8n): manage databases, environment variables, users, licenses, and security settings.
* [Keep n8n running](/deploy/host-n8n/keep-n8n-running): monitor, log, trace, and update your instance.
* [Understand the architecture](/deploy/host-n8n/understand-the-architecture): learn how n8n works and how it structures its database.
* [Deploy as an OEM integration](/deploy/host-n8n/deploy-as-an-oem-integration): embed n8n's interface inside your own product's UI.
* [Deploy with the AI starter kit](/deploy/host-n8n/deploy-with-the-ai-starter-kit): use n8n's curated self-hosted AI Starter Kit.
* [Compare editions](/deploy/host-n8n/community-edition-features): compare the self-hosted Community, Business, and Enterprise editions.

## Choose your installation method <a href="#choose-your-installation-method" id="choose-your-installation-method"></a>

Select the installation method that best fits your technical requirements and infrastructure:

* **One-line setup**

  **Best for:** Quick setup with minimal configuration.

  **Requirements:** Linux or macOS system with curl installed.

  Automated installation script that handles all dependencies and configuration for you.

  [One-line setup guide](/deploy/host-n8n/install-options/one-line-setup)
* **Docker Compose**

  **Best for:** Production deployments with databases and additional services.

  **Requirements:** Docker and Docker Compose installed on your system.

  Multi-container setup ideal for robust deployments with persistent data and scalability.

  [Docker Compose guide](/deploy/host-n8n/install-options/install-using-docker-compose)
* **AWS**

  Deploy on Amazon Web Services using EC2, ECS, or other AWS services.

  [AWS setup guide](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws)
* **Azure**

  Host n8n on Microsoft Azure with container instances or virtual machines.

  [Azure setup guide](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-azure)
* **Google Cloud**

  Run n8n on Google Cloud using Cloud Run or Kubernetes Engine.

  [Google Cloud Run](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-cloud-run) | [Kubernetes Engine](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-kubernetes)
* **DigitalOcean**

  Simple droplet-based hosting ideal for small to medium deployments.

  [DigitalOcean setup guide](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-digital-ocean)
* **Hetzner**

  Cost-effective European hosting option with excellent performance.

  [Hetzner setup guide](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-hetzner)
* **Heroku**

  Platform-as-a-service option for quick deployment with minimal configuration.

  [Heroku setup guide](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-heroku)
* **OpenShift**

  Enterprise Kubernetes platform for containerized applications.

  [OpenShift setup guide](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-openshift-local-crc)
* **npm**

  **Best for:** Local development or testing.

  **Requirements:** Node.js installed on your system.

  npm installation is deprecated from n8n 3.0. Consider using Docker Compose or one-line setup instead.

  Installs n8n directly using Node Package Manager. Quick to set up but requires managing Node.js versions and dependencies yourself.

  [npm installation guide](/deploy/host-n8n/install-options/install-with-npm)

## Related resources

* [Deploy](/deploy)
* [Use n8n Cloud](/deploy/use-n8n-cloud)


# Install options

Compare ways to install self-hosted n8n, including one-line setup, Docker, Docker Compose, npm, and cloud providers.

Compare ways to install self-hosted n8n.

## In this section

* [One-line setup](/deploy/host-n8n/install-options/one-line-setup): install n8n from the command line using a one-line setup.
* [Install using Docker Compose](/deploy/host-n8n/install-options/install-using-docker-compose): build a Docker Compose setup for self-hosted n8n.
* [Install with npm](/deploy/host-n8n/install-options/install-with-npm): install n8n directly using Node Package Manager.
* [Install with Docker](/deploy/host-n8n/install-options/install-with-docker): install and run n8n using Docker.
* [Use a cloud provider](/deploy/host-n8n/install-options/use-a-cloud-provider): deploy self-hosted n8n to DigitalOcean, AWS, Azure, Google Cloud, and more.
* [Production requirements](/deploy/host-n8n/install-options/production-requirements): check database, operating system, runtime, storage, and software requirements for a production deployment.

## Related resources

* [Host n8n](/deploy/host-n8n)
* [Configure n8n](/deploy/host-n8n/configure-n8n)
* [Keep n8n running](/deploy/host-n8n/keep-n8n-running)
* [Understand the architecture](/deploy/host-n8n/understand-the-architecture)
* [Deploy as an OEM integration](/deploy/host-n8n/deploy-as-an-oem-integration)
* [Deploy with the AI starter kit](/deploy/host-n8n/deploy-with-the-ai-starter-kit)
* [Compare editions](/deploy/host-n8n/community-edition-features)


# One-line setup

Install n8n from the command line using a one-line setup.

## Who this is for

This guide sets up a brand-new n8n instance with a single command that replaces the old `npm install n8n` / `npx n8n` approach, which no longer works from n8n 3.0. It's the fastest way to get n8n running, whether you've used Docker before or not.

It's meant for fresh installs, not for changing an existing setup:

* **Already self-hosting with your own Docker Compose file?** You don't need to switch to this script, but feel free to take inspiration from [the Docker Compose setup process](/deploy/host-n8n/install-options/install-using-docker-compose).
* **Currently installing n8n with npm?** From n8n 3.0, n8n is only distributed through Docker. Your existing npm install keeps working for now, but new installs (and future upgrades) should use this method instead.

## What you need before you start

This method uses Docker, a tool that runs n8n in a self-contained package so you don't have to install or configure anything else yourself. If you don't already have it:

* Install [Docker](https://docs.docker.com/get-docker/). This includes Docker Compose, which the setup command also needs.

You don't need to know Docker to use this guide; just have it installed and running in the background.

{% hint style="info" %}
The one-line setup command requires the `docker compose` v2 plugin specifically (not the older standalone `docker-compose` binary), and checks that the Docker daemon is running. If you're using Podman, Colima, or other Docker-compatible engines, install the `docker` CLI with the compose plugin and point `DOCKER_HOST` at their socket.
{% endhint %}

Watch a video guide covering this setup, from installing Docker to [turning on n8n Assistant](#optional-turn-on-n8n-assistant):

{% embed url="<https://www.youtube.com/embed/t5RBVTby9EU>" %}

## Run the command

Open a terminal and run:

```bash
curl -fsSL https://get.n8n.io | sh
```

This does everything for you:

1. Checks that Docker is installed and running, and tells you how to fix it if not.
2. Creates a new folder called `n8n` in your current directory to hold everything.
3. Writes the configuration files n8n needs to run.
4. Downloads n8n and starts it up.

It's safe to run more than once. If n8n is already set up in that folder, the command just tells you it's already there instead of changing anything.

A successful run looks like this:

```
$ curl -fsSL https://get.n8n.io | sh

✓ Docker found (24.0.6)
✓ Docker Compose found (v2.24.0)
✓ Created ./n8n/compose.yml
✓ Created ./n8n/searxng-settings.yml
✓ Created ./n8n/.env (unique secrets generated)
Pulling images and starting (this can take a few minutes on first run)...
✓ Started n8n 2.32.0 and sandbox services

n8n is running at: http://localhost:5678
Data stored in:    ./n8n (Docker volume: n8n-data)
Config files:      ./n8n/compose.yml, ./n8n/.env

To stop:      docker compose -f ./n8n/compose.yml down
To upgrade:   curl -fsSL https://get.n8n.io | sh -s -- --upgrade
To uninstall: docker compose -f ./n8n/compose.yml down -v   # -v DELETES all n8n data
              rm -rf ./n8n
```

{% hint style="warning" %}
n8n takes a moment to finish starting the first time. The command waits and only prints the URL once it's ready. If the page doesn't load right away, wait a bit and refresh.
{% endhint %}

## What's included by default

Running the command sets up everything below automatically. There's nothing extra to install:

| Component                          | What it's for                                                                                                                                                                                                                                                                                                |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **n8n**                            | The workflow editor itself, running at `http://localhost:5678`.                                                                                                                                                                                                                                              |
| **A built-in database**            | Stores your workflows, credentials, and execution history. This is [SQLite](https://www.sqlite.org/), a lightweight database that lives in a file. You don't need to install or manage a separate database server.                                                                                           |
| **n8n Assistant support services** | A sandbox that safely runs the code n8n Assistant writes, and a bundled search tool so it can look things up on the web. These start automatically alongside n8n, but the assistant itself stays switched off until you add an AI provider key. See [Turn on n8n Assistant](#optional-turn-on-n8n-assistant) |

If you're setting n8n up for a team or a production environment, consider a more robust database like Postgres rather than the built-in default. See [Install using Docker Compose](/deploy/host-n8n/install-options/install-using-docker-compose) for that setup.

{% hint style="warning" %}
The bundled sandbox is for development and testing, not production. Its runner (`sandbox-runner-1`) runs with `privileged: true` and Docker-in-Docker, which gives weak isolation. If code escapes the sandbox, it reaches the host, so treat the runner as equivalent to root on the host.

Run this setup on a dedicated machine or VM with nothing else on it, and never expose it to the internet. For production, see [Set up n8n Assistant](/deploy/host-n8n/configure-n8n/set-up-n8n-assistant). It describes the self-hosted option, which is the n8n sandbox service with Sysbox runners, ideally on Kubernetes. The managed option is Daytona, a third-party service that receives your workflow data.
{% endhint %}

## Optional: Turn on n8n Assistant

n8n works fully without n8n Assistant, which is an optional extra. Once n8n is running, the easiest way to turn it on is from the UI in the instance's AI settings. Add your model API key there. Prefer to configure it before you ever log in? Edit `.env` instead:

1. Open the `.env` file the command created (in `./n8n/.env` by default).
2. Add your AI provider key to the `N8N_INSTANCE_AI_MODEL_API_KEY` line.
3. Restart n8n: `docker compose -f ./n8n/compose.yml up -d`

Full setup steps, including the supported providers, are in [Set up n8n Assistant](/deploy/host-n8n/configure-n8n/set-up-n8n-assistant).

By default, n8n Assistant's web search runs through a bundled search tool with no setup needed. If you'd rather use Brave Search, add your Brave API key to `INSTANCE_AI_BRAVE_SEARCH_API_KEY` in the same `.env` file. It's used automatically once it's set.

{% hint style="info" %}
You don't need to open any extra ports or configure anything for these services. Only n8n itself (port `5678`) is ever reachable from outside your machine. Everything else stays private by default.
{% endhint %}

## Everyday commands

| To do this                     | Run this                                                          |
| ------------------------------ | ----------------------------------------------------------------- |
| Stop n8n                       | `docker compose -f ./n8n/compose.yml down`                        |
| Start it again                 | `docker compose -f ./n8n/compose.yml up -d`                       |
| Upgrade to the latest version  | `curl -fsSL https://get.n8n.io \| sh -s -- --upgrade`             |
| Remove n8n and delete its data | `docker compose -f ./n8n/compose.yml down -v` then `rm -rf ./n8n` |

### What an upgrade changes

The upgrade command moves both n8n and the bundled sandbox services to newer versions. It edits two lines in `.env`: `N8N_VERSION` and `N8N_SANDBOX_VERSION`. Your data, secrets, and other settings stay as they are.

If you installed before the sandbox version moved into `.env`, your `compose.yml` still names fixed sandbox image tags. The first upgrade rewrites those image lines to use `N8N_SANDBOX_VERSION`, switches the sandbox runner address (`SANDBOX_RUNNER_HTTP_BASE_URL`) from `http://` to `https://`, and prints a note that says so. Nothing else in `compose.yml` changes, so any edits you made stay in place.

## Flags (for more control)

Adding these to the end of the install command changes what it does:

| Flag         | What it does                                                                                                                                                                                                                                                                                                                                           |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `--version`  | On its own, shows the script's version and the latest n8n version it would install. Followed by a version number (for example, `--version 2.31.4`), installs or upgrades to that specific version.                                                                                                                                                     |
| `--no-start` | Sets up the configuration files without starting n8n yet.                                                                                                                                                                                                                                                                                              |
| `--upgrade`  | Upgrades an existing install to a newer n8n version and the matching sandbox service version. Only updates the version lines in `.env` and, on older installs, the sandbox image lines and runner address in `compose.yml`. See [What an upgrade changes](#what-an-upgrade-changes). Your data, settings, and any other customizations stay untouched. |
| `--help`     | Shows all available options.                                                                                                                                                                                                                                                                                                                           |

## Prefer not to run a script from the internet?

You can download and read it first, then run it yourself:

```bash
curl -fsSL https://get.n8n.io -o get-n8n.sh
less get-n8n.sh   # review it
sh get-n8n.sh
```

## Windows users

The one-line setup command needs a terminal that understands shell scripts, which the standard Windows Command Prompt or PowerShell don't. Run it instead from:

* **WSL** (Windows Subsystem for Linux), with Docker Desktop's WSL2 integration turned on.
* **Git Bash** (installed alongside [Git for Windows](https://git-scm.com/downloads/win)) with Docker Desktop running can also run POSIX shell scripts, but n8n hasn't verified it end-to-end for the one-line setup command. Stick with WSL unless you've confirmed Git Bash works for your setup.

## Related resources

* [Install options](/deploy/host-n8n/install-options)
* [Install using Docker Compose](/deploy/host-n8n/install-options/install-using-docker-compose)
* [Install with npm](/deploy/host-n8n/install-options/install-with-npm)
* [Install with Docker](/deploy/host-n8n/install-options/install-with-docker)
* [Production requirements](/deploy/host-n8n/install-options/production-requirements)
* [Use a cloud provider](/deploy/host-n8n/install-options/use-a-cloud-provider)


# Install using Docker Compose

Build a Docker Compose setup for self-hosted n8n, including the sandbox stack for n8n Assistant.

## Who this is for

This guide walks through building your own Docker Compose setup by hand, including the sandbox stack that powers n8n Assistant. Use it if you want full control over your configuration, or need to fold n8n into an existing Compose project.

The sandbox in this setup is for development and testing, not production. For production sandbox options, see [Set up n8n Assistant](/deploy/host-n8n/configure-n8n/set-up-n8n-assistant).

If you just want n8n (and n8n Assistant) running quickly without writing any files yourself, use the [one-line setup](/deploy/host-n8n/install-options/one-line-setup) instead. It sets up everything below automatically.

## What you need before you start

* Docker Engine and Docker Compose v2. Run `docker compose version` to check.
* At least 4 GB of RAM and 2 vCPUs. The sandbox that runs AI-generated code (`sandbox-runner-1`) uses Docker-in-Docker, which needs more headroom than a typical container.

{% hint style="warning" %}
`sandbox-runner-1` runs with `privileged: true` and Docker-in-Docker. That's weak isolation: code that escapes the sandbox reaches the host. Run this setup on a dedicated host or VM with nothing else on it.
{% endhint %}

{% hint style="info" %}
**Windows users:** Use WSL, with either Docker Desktop (WSL2 backend) or Docker Engine installed directly in your Linux distribution. Keep your project folder inside the WSL filesystem (for example, `~/n8n`), not under `/mnt/c/...`. Bind mounts across that boundary are slow and can cause permission issues.
{% endhint %}

## Step 1: Create a project folder

```bash
mkdir n8n && cd n8n
```

## Step 2: Create `.env`

This file holds the versions to run and the secrets the sandbox services use to talk to each other. Create a file named `.env` with your own values in place of the placeholders and keep this file out of version control.

```
# n8n version - get the version number of the latest stable release from https://github.com/n8n-io/n8n/releases
N8N_VERSION=change-me-version-number

# Sandbox service version - the API, runner, and sandbox images share one release.
# Get the number of the latest stable "service" release (not a staging prerelease) from https://github.com/n8n-io/n8n-sandbox-service/releases
N8N_SANDBOX_VERSION=change-me-sandbox-version-number

# n8n task runner authentication. Use a random secret you generate.
N8N_RUNNERS_AUTH_TOKEN=change-me-runner-auth-token

# Sandbox service secrets — pick your own values
SANDBOX_API_KEYS=change-me-api-key
SANDBOX_RUNNER_REGISTRATION_TOKEN=change-me-registration-token
SANDBOX_RUNNER_API_KEYS=change-me-runner-key

# Must match a value in SANDBOX_API_KEYS above — this is how n8n authenticates to the sandbox
N8N_SANDBOX_SERVICE_API_KEY=change-me-api-key

# Web search: secret for the bundled SearXNG instance — pick your own value
SEARXNG_SECRET=change-me-searxng-secret
N8N_INSTANCE_AI_SEARXNG_URL=http://searxng:8080
```

You don't need an AI provider key yet; see [Turn on n8n Assistant](#optional-turn-on-n8n-assistant) below once everything's running.

## Step 3: Create `searxng-settings.yml`

The stock SearXNG image only serves HTML; n8n's web search needs its JSON API, which this file turns on.

```yaml
use_default_settings: true
search:
  formats:
    - html
    - json
```

## Step 4: Create `compose.yml`

This defines every service you're setting up: n8n itself, the sandbox stack that lets n8n Assistant safely run code, and SearXNG for web search.

{% @github-files/github-code-block url="<https://github.com/n8n-io/n8n/blob/master/docker/get-n8n-compose.yml>" %}

## What you've just set up

| Component            | What it's for                                                                                      |
| -------------------- | -------------------------------------------------------------------------------------------------- |
| **n8n**              | The workflow editor itself, available at `http://localhost:5678`.                                  |
| **sandbox-certs**    | Runs once to generate the TLS certificates the other sandbox services need, then exits.            |
| **sandbox-api**      | The control plane n8n talks to when n8n Assistant needs to run code.                               |
| **sandbox-runner-1** | Does the actual work; a privileged Docker-in-Docker container that creates and runs the sandboxes. |
| **searxng**          | Bundled web search backend for n8n Assistant.                                                      |

This bundles n8n's own sandbox (`n8n-sandbox`), which is for development and testing only. Its runner is privileged, so it gives weak isolation. For a production instance, n8n recommends the n8n sandbox service with Sysbox runners, ideally on Kubernetes. If a third party can process your workflow data, Daytona is a managed alternative. See [Set up n8n Assistant](/deploy/host-n8n/configure-n8n/set-up-n8n-assistant) for how to configure each option.

There's no database service defined here. n8n falls back to its built-in SQLite database. The `n8n-data` volume in `get-n8n-compose.yml` stores the database and n8n's encryption key, so your data survives restarts and container recreation. For a production instance, swap in Postgres. See [Use PostgreSQL instead of SQLite](#optional-use-postgresql-instead-of-sqlite) below.

## Step 5: Start everything

```bash
docker compose up -d
docker compose ps
```

Wait until `sandbox-api` shows `healthy`; `sandbox-runner-1` and `n8n` will then start automatically.

## Step 6: Verify it's working

```bash
# sandbox-api is reachable from n8n
docker compose exec n8n wget -qO- http://sandbox-api:8080/healthz

# the runner registered itself with the API
docker compose logs sandbox-api | grep -i runner

# n8n is up
curl -sf http://localhost:5678/healthz
```

Launch n8n by pointing your web browser to `http://localhost:5678`

## Optional: Turn on n8n Assistant

Everything above runs the full sandbox stack, but n8n Assistant itself stays off until you give it a model to use. You can do this from the n8n UI (in the instance's AI settings) once n8n is running, or using `.env` if you'd rather configure it before first login:

1. Add your AI provider key to `.env`:

   ```
   N8N_INSTANCE_AI_MODEL_API_KEY=sk-ant-xxx
   ```
2. Restart n8n so it picks up the change:

   ```bash
   docker compose up -d n8n
   ```

Web search runs through the bundled SearXNG service by default. If you'd rather use Brave Search instead, you can set it from the UI or add your Brave API key to `.env`; it takes priority over SearXNG once set:

```
INSTANCE_AI_BRAVE_SEARCH_API_KEY=BSA-xxx
```

Full setup steps, including the supported model providers, are in [Set up n8n Assistant](/deploy/host-n8n/configure-n8n/set-up-n8n-assistant).

## Optional: Use PostgreSQL instead of SQLite

SQLite is fine for trying things out, but for a production instance that must handle more than a handful of users or workflows running around the clock use Postgres instead.

1. Add the Postgres credentials to `.env`, alongside the sandbox secrets:

   ```
   POSTGRES_USER=change-me-user
   POSTGRES_PASSWORD=change-me-password
   POSTGRES_DB=n8n
   ```
2. Add a `postgres` service to `compose.yml`, and a volume for its data:

   ```yaml
   volumes:
     db-storage:

   services:
     postgres:
       image: postgres:18
       restart: always
       environment:
         POSTGRES_USER: ${POSTGRES_USER}
         POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
         POSTGRES_DB: ${POSTGRES_DB}
         PGDATA: /var/lib/postgresql/data
       volumes:
         - db-storage:/var/lib/postgresql/data
       healthcheck:
         test: ["CMD-SHELL", "pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
         interval: 5s
         timeout: 5s
         retries: 10
   ```

   <div data-gb-custom-block data-tag="hint" data-style="warning" class="hint hint-warning"><p>Postgres 18 changed where it stores data by default. Setting `PGDATA` keeps it in the same folder as earlier versions, so the volume mount stays the same. Don't remove that line: without it, Postgres 18 writes somewhere the volume doesn't cover and your database starts empty.</p></div>

   <div data-gb-custom-block data-tag="hint" data-style="warning" class="hint hint-warning"><p>Already running an older Postgres? Moving straight to 18 is a major version upgrade, and Postgres can't open a data directory written by an older major. Bumping the image tag on an existing setup fails with `database files are incompatible with server`. Your data stays intact. Back up first with `pg_dumpall`, then follow the official [PostgreSQL upgrade guide](https://www.postgresql.org/docs/18/upgrading.html).</p></div>
3. Point n8n at it by adding these to the n8n service's environment block, and making it wait on Postgres too:

   ```yaml
   environment:
         # ...your existing N8N_ENABLED_MODULES, N8N_INSTANCE_AI_* settings stay as they are
         DB_TYPE: postgresdb
         DB_POSTGRESDB_HOST: postgres
         DB_POSTGRESDB_PORT: '5432'
         DB_POSTGRESDB_DATABASE: ${POSTGRES_DB}
         DB_POSTGRESDB_USER: ${POSTGRES_USER}
         DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}
     depends_on:
       sandbox-api:
         condition: service_healthy
       postgres:
         condition: service_healthy
   ```
4. Restart everything:

   ```bash
   docker compose up -d
   ```

   n8n migrates itself to the new Postgres database on startup. Existing SQLite data doesn't carry over automatically. This setup is for a fresh instance, not an in-place migration.

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>For a more hardened setup, such as a dedicated non-root Postgres user and an external task runner, see the [`withPostgres` example](https://github.com/n8n-io/n8n-hosting/tree/main/docker-compose/withPostgres) in the n8n hosting repository.</p></div>

## Troubleshooting

| Symptom                                                                 | Likely cause                                                                                                                                                                                                                                                                                                    |
| ----------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sandbox-api` or `sandbox-runner-1` fail to start, cert errors          | `sandbox-certs` didn't complete. Check `docker compose logs sandbox-certs`.                                                                                                                                                                                                                                     |
| `sandbox-api` never becomes `healthy`                                   | Check its logs; also confirm `wget` actually exists in that image.                                                                                                                                                                                                                                              |
| `sandbox-runner-1` crash-loops on startup with `... must be set` errors | It's missing required environment variables, most commonly `SANDBOX_RUNNER_API_KEYS` or `SANDBOX_RUNNER_REGISTRATION_TOKEN`. For the full list of environment variables the runner requires, run `strings /usr/local/bin/sandbox-runner \| grep -oE 'SANDBOX_[A-Z_]+ must be set'` inside the runner container. |
| Runner never registers with the API                                     | `SANDBOX_RUNNER_REGISTRATION_TOKEN` mismatch, or `SANDBOX_RUNNER_API_GRPC_ADDR` wrong.                                                                                                                                                                                                                          |
| n8n's sandbox calls fail                                                | Sandbox URL/key in `.env` doesn't match `sandbox-api`'s address or `SANDBOX_API_KEYS`.                                                                                                                                                                                                                          |
| Works on Linux, fails on WSL                                            | Usually a bind-mount path issue. Keep the project inside the WSL filesystem, not `/mnt/c/...`.                                                                                                                                                                                                                  |

## Security checklist

* `sandbox-runner-1` (`privileged: true`, Docker-in-Docker) is never exposed to the public internet. Treat it as equivalent to root on the host.
* Nothing else runs on the same host or VM as the Compose stack. If code escapes the sandbox, it reaches everything on that host.
* This setup isn't your production sandbox. For production, use the n8n sandbox service with Sysbox runners, ideally on Kubernetes. If a third party can process your workflow data, Daytona is a managed alternative. See [Set up n8n Assistant](/deploy/host-n8n/configure-n8n/set-up-n8n-assistant).
* Only n8n's port is open on your cloud firewall.
* `SANDBOX_API_KEYS`, the registration token, and the runner key are unique, not left as `change-me-...`, and rotated periodically.
* `sandbox-api` and `sandbox-runner-1` do **not** use `env_file: .env`. Each only receives the specific variables it needs, explicitly, in its `environment` block. The model API key, Brave key, Postgres password, and n8n encryption key never reach the sandbox containers.
* The mTLS keys under the `sandbox-tls` volume, including the root CA key, are locked down to `0600` and owned only by the service that needs them (`sandbox-api` for its own key; root for the runner's key and the CA key). None of them are world-readable.
* You have a plan to regenerate the `sandbox-tls` volume. The certs `sandbox-certs` generates don't autorenew.

## Service architecture

```mermaid
flowchart LR
    subgraph compose["docker-compose.yml (one project)"]
        n8n["n8n"]
        certs["sandbox-certs<br/>(runs once, then exits)"]
        api["sandbox-api"]
        runner["sandbox-runner-1<br/>(privileged, DinD)"]
        sandboxes["sandbox containers<br/>(per execution)"]

        certs -.->|TLS certs| api
        certs -.->|TLS certs| runner
        n8n -->|HTTP :8080| api
        api -->|control gRPC| runner
        runner --> sandboxes
    end

    classDef oneshot fill:#eee,stroke:#999,stroke-dasharray: 3 3;
    class certs oneshot
```

n8n sends code execution requests to `sandbox-api`, which hands them to `sandbox-runner-1`, which creates and runs the actual sandbox containers. `sandbox-runner-1` is the privileged component. In the production setup, Sysbox runners on Kubernetes replace it. `sandbox-certs` runs once at startup to generate the TLS certificates the other two need and then exits; everything else waits on it.

## Related resources

* [Install options](/deploy/host-n8n/install-options)
* [One-line setup](/deploy/host-n8n/install-options/one-line-setup)
* [Install with npm](/deploy/host-n8n/install-options/install-with-npm)
* [Install with Docker](/deploy/host-n8n/install-options/install-with-docker)
* [Production requirements](/deploy/host-n8n/install-options/production-requirements)
* [Use a cloud provider](/deploy/host-n8n/install-options/use-a-cloud-provider)
* [Set up n8n Assistant](/deploy/host-n8n/configure-n8n/set-up-n8n-assistant)


# Install with npm

{% hint style="warning" %}
**Feature availability**

npm-based installs are deprecated from n8n 3.0.
{% endhint %}

{% hint style="info" %}
**n8n Assistant not available**

n8n Assistant isn't available when using the npm installation method.
{% endhint %}

npm is a quick way to get started with n8n on your local machine. You must have [Node.js](https://nodejs.org/en/) installed. n8n requires a Node.js version between 20.19 and 24.x, inclusive.

### Try n8n with npx <a href="#try-n8n-with-npx" id="try-n8n-with-npx"></a>

You can try n8n without installing it using npx.

From the terminal, run:

```bash
npx n8n
```

This command will download everything that's needed to start n8n. You can then access n8n and start building workflows by opening <http://localhost:5678>.

### Install globally with npm <a href="#install-globally-with-npm" id="install-globally-with-npm"></a>

To install n8n globally, use npm:

```bash
npm install n8n -g
```

To install or update to a specific version of n8n use the `@` syntax to specify the version. For example:

```bash
npm install -g n8n@0.126.1
```

To install `next`:

```bash
npm install -g n8n@next
```

After the installation, start n8n by running:

```bash
n8n
# or <a href="#or" id="or"></a>
n8n start
```

#### Next steps <a href="#next-steps" id="next-steps"></a>

Try out n8n using the [Quickstarts](/build-your-first-workflow).

### Updating <a href="#updating" id="updating"></a>

To update your n8n instance to the `latest` version, run:

```bash
npm update -g n8n
```

To install the `next` version:

```bash
npm install -g n8n@next
```

### n8n with tunnel <a href="#n8n-with-tunnel" id="n8n-with-tunnel"></a>

{% hint style="danger" %}
Use this for local development and testing. It isn't safe to use it in production.
{% endhint %}

{% hint style="warning" %}
**Development tooling**

The tunnel feature is a convenience tool for local development. The underlying implementation may change between n8n versions.
{% endhint %}

Watch a video guide to setting up the tunnel using Cloudflare or ngrok:

{% embed url="<https://www.youtube.com/embed/O9dpO81dEQ0>" %}

To use webhooks for trigger nodes of external services like GitHub, n8n has to be reachable from the web. n8n provides a tunnel service using [cloudflared](https://github.com/cloudflare/cloudflared) that redirects requests from the web to your local n8n instance. Docker must be installed for the tunnel to work.

There are two ways to use the tunnel, depending on how you run n8n:

{% hint style="info" %}
**Docker required**

The tunnel uses cloudflared, which runs as a Docker container. Make sure [Docker](https://docs.docker.com/get-docker/) is installed on your machine, even when running n8n via npm.
{% endhint %}

For npm installations, use the **services only** approach. Start cloudflared as a standalone service, then run n8n locally:

```bash
# Terminal 1: Start the cloudflared tunnel service <a href="#terminal-1-start-the-cloudflared-tunnel-service" id="terminal-1-start-the-cloudflared-tunnel-service"></a>
pnpm --filter n8n-containers services --services cloudflared

# Terminal 2: Start n8n locally <a href="#terminal-2-start-n8n-locally" id="terminal-2-start-n8n-locally"></a>
pnpm dev
```

The `services` command starts cloudflared, fetches the public tunnel URL, and writes a `.env` file to `packages/cli/bin/.env` with `WEBHOOK_URL` and `N8N_PROXY_HOPS=1`. n8n picks up this `.env` automatically on startup.

Clean up when done:

```bash
pnpm --filter n8n-containers services:clean
```

For the full stack approach (n8n and cloudflared both in containers), refer to the [Docker tunnel setup](/deploy/host-n8n/install-options/install-with-docker#n8n-with-tunnel).

### Reverting an upgrade <a href="#reverting-an-upgrade" id="reverting-an-upgrade"></a>

Install the older version that you want to go back to.

If the upgrade involved a database migration:

1. Check the feature documentation and release notes to see if there are any manual changes you need to make.
2. Run `n8n db:revert` on your current version to roll back the database. If you want to revert more than one database migration, you need to repeat this process.

### Windows troubleshooting <a href="#windows-troubleshooting" id="windows-troubleshooting"></a>

If you're experiencing issues running n8n on Windows, verify your Node.js environment setup. Follow Microsoft's guide to [Install NodeJS on Windows](https://learn.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-windows).

### Related resources

* [Install options](/deploy/host-n8n/install-options)
* [One-line setup](/deploy/host-n8n/install-options/one-line-setup)
* [Install using Docker Compose](/deploy/host-n8n/install-options/install-using-docker-compose)
* [Install with Docker](/deploy/host-n8n/install-options/install-with-docker)
* [Production requirements](/deploy/host-n8n/install-options/production-requirements)
* [Use a cloud provider](/deploy/host-n8n/install-options/use-a-cloud-provider)


# Install with Docker

{% hint style="warning" %}
**This content is outdated.** Please refer to [Install using Docker Compose](/deploy/host-n8n/install-options/install-using-docker-compose) for the recommended installation method.
{% endhint %}

## Docker installation <a href="#docker-installation" id="docker-installation"></a>

n8n recommends using [Docker](https://www.docker.com/) for most self-hosting needs. It provides a clean, isolated environment, avoids operating system and tooling incompatibilities, and makes database and environment management simpler.

You can also use n8n in Docker with [Docker Compose](/deploy/host-n8n/install-options/use-a-cloud-provider/use-docker-compose). You can find Docker Compose configurations for various architectures in the [n8n-hosting repository](https://github.com/n8n-io/n8n-hosting).

{% hint style="info" %}
**Self-hosting knowledge prerequisites**

Self-hosting n8n requires technical knowledge, including:

* Setting up and configuring servers and containers
* Managing application resources and scaling
* Securing servers and applications
* Configuring n8n

n8n recommends self-hosting for expert users. Mistakes can lead to data loss, security issues, and downtime. If you aren't experienced at managing servers, n8n recommends [n8n Cloud](https://n8n.io/cloud/).
{% endhint %}

You can also follow along with this video guide:

{% embed url="<https://www.youtube.com/embed/6ET3G7GiqZA?si=mwCKbtyLqNCRc2pa>" %}

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

Before proceeding, install Docker:

* [Docker Desktop](https://docs.docker.com/get-docker/) is available for Mac, Windows, and Linux. Docker Desktop includes the Docker Engine and Docker Compose.
* [Docker Engine](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/linux/) are also available as separate packages for Linux. Use this for Linux machines without a graphical environment or when you don't want the Docker Desktop UI.

{% hint style="info" %}
**Stable and Beta versions**

n8n releases a new minor version most weeks. The `stable` version is for production use. `beta` is the most recent release. The `beta` version may be unstable. To report issues, use the [forum](https://community.n8n.io/c/questions/12).

Current `stable`: 2.47.7 Current `beta`: 2.48.4
{% endhint %}

### Starting n8n <a href="#starting-n8n" id="starting-n8n"></a>

From your terminal, run the following commands, replacing the `<YOUR_TIMEZONE>` placeholders with [your timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List):

```shell
docker volume create n8n_data

docker run -it --rm \
 --name n8n \
 -p 5678:5678 \
 -e GENERIC_TIMEZONE="<YOUR_TIMEZONE>" \
 -e TZ="<YOUR_TIMEZONE>" \
 -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true \
 -v n8n_data:/home/node/.n8n \
 n8nio/n8n
```

This command creates a volume to store persistent data, downloads the required n8n image, and starts the container with the following settings:

* Maps and exposes port `5678` on the host.
* Sets the timezone for the container:
  * the `TZ` environment variable sets the system timezone to control what scripts and commands like `date` return.
  * the [`GENERIC_TIMEZONE` environment variable](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/timezone-and-localization) sets the correct timezone for schedule-oriented nodes like the [Schedule Trigger node](/integrations/builtin/core-nodes/n8n-nodes-base.scheduletrigger).
* Enforces secure file permissions for the n8n configuration file.
* Mounts the `n8n_data` volume to the `/home/node/.n8n` directory to persist your data across container restarts.

{% hint style="warning" %}
**Feature availability**

`N8N_RUNNERS_ENABLED` is deprecated from n8n 2.0. You no longer need to set it. It's still supported in n8n 1.x, where you must set it to `true` to enable task runners.
{% endhint %}

Once running, you can access n8n by opening: <http://localhost:5678>

### Using with PostgreSQL <a href="#using-with-postgresql" id="using-with-postgresql"></a>

By default, n8n uses SQLite to save credentials[^1], past executions, and workflows. n8n also supports PostgreSQL, configurable using environment variables as detailed below.

{% hint style="info" %}
**Persisting the `.n8n` directory still recommended**

When using PostgreSQL, n8n doesn't need to use the `.n8n` directory for the SQLite database file. However, the directory still contains other important data like encryption keys, instance logs, and source control feature assets. While you can work around some of these requirements, (for example, by setting the [`N8N_ENCRYPTION_KEY` environment variable](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/deployment)), it's best to continue mapping a persistent volume for the directory to avoid potential issues.
{% endhint %}

To use n8n with PostgreSQL, execute the following commands, replacing the placeholders (depicted within angled brackets, for example `<POSTGRES_USER>`) with your actual values:

```shell
docker volume create n8n_data

docker run -it --rm \
 --name n8n \
 -p 5678:5678 \
 -e GENERIC_TIMEZONE="<YOUR_TIMEZONE>" \
 -e TZ="<YOUR_TIMEZONE>" \
 -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true \
 -e DB_TYPE=postgresdb \
 -e DB_POSTGRESDB_DATABASE=<POSTGRES_DATABASE> \
 -e DB_POSTGRESDB_HOST=<POSTGRES_HOST> \
 -e DB_POSTGRESDB_PORT=<POSTGRES_PORT> \
 -e DB_POSTGRESDB_USER=<POSTGRES_USER> \
 -e DB_POSTGRESDB_SCHEMA=<POSTGRES_SCHEMA> \
 -e DB_POSTGRESDB_PASSWORD=<POSTGRES_PASSWORD> \
 -v n8n_data:/home/node/.n8n \
 n8nio/n8n
```

You can find a complete `docker-compose` file for PostgreSQL in the [n8n hosting repository](https://github.com/n8n-io/n8n-hosting/tree/main/docker-compose/withPostgres).

### Updating <a href="#updating" id="updating"></a>

To update n8n, in Docker Desktop, navigate to the **Images** tab and select **Pull** from the context menu to download the latest n8n image:

![Docker Desktop Images tab with the row context menu open and Pull available](https://2773773108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fjm0ZYRpZIPWge2ZSiDYO%2Fuploads%2Fgit-blob-8f7ce604273f267f280888b409587631adcd9b47%2Fdocker_desktop.png?alt=media)

You can also use the command line to pull the latest, or a specific version:

```shell
# Pull latest (stable) version <a href="#pull-latest-stable-version" id="pull-latest-stable-version"></a>
docker pull n8nio/n8n

# Pull specific version <a href="#pull-specific-version" id="pull-specific-version"></a>
docker pull n8nio/n8n:1.81.0

# Pull next (unstable) version <a href="#pull-next-unstable-version" id="pull-next-unstable-version"></a>
docker pull n8nio/n8n:next
```

After pulling the updated image, stop your n8n container and start it again. You can also use the command line. Replace `<container_id>` in the commands below with the container ID you find in the first command:

```shell
# Find your container ID <a href="#find-your-container-id" id="find-your-container-id"></a>
docker ps -a

# Stop the container with the `<container_id>` <a href="#stop-the-container-with-the-lesscontaineridgreater" id="stop-the-container-with-the-lesscontaineridgreater"></a>
docker stop <container_id>

# Remove the container with the `<container_id>` <a href="#remove-the-container-with-the-lesscontaineridgreater" id="remove-the-container-with-the-lesscontaineridgreater"></a>
docker rm <container_id>

# Start the container <a href="#start-the-container" id="start-the-container"></a>
docker run --name=<container_name> [options] -d n8nio/n8n
```

#### Updating Docker Compose <a href="#updating-docker-compose" id="updating-docker-compose"></a>

If you run n8n using a Docker Compose file, follow these steps to update n8n:

```sh
# Navigate to the directory containing your docker compose file <a href="#navigate-to-the-directory-containing-your-docker-compose-file" id="navigate-to-the-directory-containing-your-docker-compose-file"></a>
cd </path/to/your/compose/file/directory>

# Pull latest version <a href="#pull-latest-version" id="pull-latest-version"></a>
docker compose pull

# Stop and remove older version <a href="#stop-and-remove-older-version" id="stop-and-remove-older-version"></a>
docker compose down

# Start the container <a href="#start-the-container" id="start-the-container"></a>
docker compose up -d
```

### n8n with tunnel <a href="#n8n-with-tunnel" id="n8n-with-tunnel"></a>

{% hint style="danger" %}
Use this for local development and testing. It isn't safe to use it in production.
{% endhint %}

{% hint style="warning" %}
**Development tooling**

The tunnel feature is a convenience tool for local development. The underlying implementation may change between n8n versions.
{% endhint %}

Watch a video guide to setting up the tunnel using Cloudflare or ngrok:

{% embed url="<https://www.youtube.com/embed/O9dpO81dEQ0>" %}

To use webhooks for trigger nodes of external services like GitHub, n8n has to be reachable from the web. n8n provides a tunnel service using [cloudflared](https://github.com/cloudflare/cloudflared) that redirects requests from the web to your local n8n instance. Docker must be installed for the tunnel to work.

There are two ways to use the tunnel, depending on how you run n8n:

#### Full stack <a href="#full-stack" id="full-stack"></a>

This runs n8n and cloudflared together in containers. The tunnel URL prints on startup and everything is wired automatically:

```shell
pnpm stack --tunnel
```

#### Services only <a href="#services-only" id="services-only"></a>

If you prefer to run n8n locally with `pnpm dev` or `pnpm start`, you can start cloudflared as a standalone service:

```shell
# Terminal 1: Start the cloudflared tunnel service <a href="#terminal-1-start-the-cloudflared-tunnel-service" id="terminal-1-start-the-cloudflared-tunnel-service"></a>
pnpm --filter n8n-containers services --services cloudflared

# Terminal 2: Start n8n locally <a href="#terminal-2-start-n8n-locally" id="terminal-2-start-n8n-locally"></a>
pnpm dev
```

The `services` command:

1. Starts cloudflared pointing at `host.docker.internal:5678` (your local n8n).
2. Fetches the public tunnel URL from cloudflared's metrics endpoint.
3. Writes a `.env` file to `packages/cli/bin/.env` with `WEBHOOK_URL` and `N8N_PROXY_HOPS=1`.
4. `pnpm dev` and `pnpm start` pick up that `.env` automatically using dotenv.

Clean up when done:

```shell
pnpm --filter n8n-containers services:clean
```

### Next steps <a href="#next-steps" id="next-steps"></a>

* Find more information about Docker setup in the README file for the [Docker image](https://github.com/n8n-io/n8n/tree/master/docker/images/n8n).
* Learn more about [configuring](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables) and [scaling](/deploy/host-n8n/configure-n8n/scaling) n8n.
* Or explore using n8n: try the [Quickstarts](/build-your-first-workflow).

## Related resources

* [Install options](/deploy/host-n8n/install-options)
* [One-line setup](/deploy/host-n8n/install-options/one-line-setup)
* [Install using Docker Compose](/deploy/host-n8n/install-options/install-using-docker-compose)
* [Install with npm](/deploy/host-n8n/install-options/install-with-npm)
* [Production requirements](/deploy/host-n8n/install-options/production-requirements)
* [Use a cloud provider](/deploy/host-n8n/install-options/use-a-cloud-provider)

[^1]: In n8n, credentials store authentication information to connect with specific apps and services. After creating credentials with your authentication information (username and password, API key, OAuth secrets, etc.), you can use the associated app node to interact with the service.


# Use a cloud provider

Deploy self-hosted n8n to a cloud provider, including DigitalOcean, AWS, Azure, and Google Cloud.

## In this section

Self-host with Docker Compose:

* [DigitalOcean](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-digital-ocean): self-host n8n on a DigitalOcean droplet with a real domain and automatic HTTPS.
* [Heroku](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-heroku): self-host n8n on Heroku.
* [Hetzner Cloud](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-hetzner): self-host n8n on a Hetzner Cloud server.

Self-host with Google Cloud Run (with access to n8n workflow tools for Google Workspace, for example Gmail and Drive):

* [Google Cloud Run](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-cloud-run): self-host n8n on Google Cloud Run, a serverless container runtime.

Starting points for a Kubernetes setup:

* [AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws): self-host n8n on Amazon Web Services with Postgres and Kubernetes.
* [AWS with Terraform](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform): deploy a production-grade, highly available n8n instance on AWS using the official Terraform module.
* [Azure](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-azure): self-host n8n on Azure with Postgres and Kubernetes.
* [Google Kubernetes Engine (GKE)](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-kubernetes): self-host n8n on Google Kubernetes Engine.
* [OpenShift Local (CRC)](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-openshift-local-crc): deploy n8n on a local OpenShift cluster for testing, without cloud costs.

Configuration guides to help you get started on other platforms:

* [Docker Compose](/deploy/host-n8n/install-options/use-a-cloud-provider/use-docker-compose): install and run n8n using Docker Compose.

## Related resources

* [Install options](/deploy/host-n8n/install-options)
* [One-line setup](/deploy/host-n8n/install-options/one-line-setup)
* [Install using Docker Compose](/deploy/host-n8n/install-options/install-using-docker-compose)
* [Install with npm](/deploy/host-n8n/install-options/install-with-npm)
* [Install with Docker](/deploy/host-n8n/install-options/install-with-docker)
* [Production requirements](/deploy/host-n8n/install-options/production-requirements)


# Deploy to Digital Ocean

This hosting guide shows you how to self-host n8n on a DigitalOcean droplet with a real domain and automatic HTTPS. It uses:

* [Caddy](https://caddyserver.com) (a reverse proxy) to allow access to the Droplet from the internet. Caddy also automatically creates and manages SSL/TLS certificates for your n8n instance.
* [Docker Compose](https://docs.docker.com/compose/) to create and define the application components and how they work together.

Once n8n is up and running, an optional last section covers adding n8n Assistant.

{% hint style="info" %}
**Self-hosting knowledge prerequisites**

Self-hosting n8n requires technical knowledge, including:

* Setting up and configuring servers and containers
* Managing application resources and scaling
* Securing servers and applications
* Configuring n8n

n8n recommends self-hosting for expert users. Mistakes can lead to data loss, security issues, and downtime. If you aren't experienced at managing servers, n8n recommends [n8n Cloud](https://n8n.io/cloud/).
{% endhint %}

{% hint style="info" %}
**Stable and Beta versions**

n8n releases a new minor version most weeks. The `stable` version is for production use. `beta` is the most recent release. The `beta` version may be unstable. To report issues, use the [forum](https://community.n8n.io/c/questions/12).

Current `stable`: 2.47.7 Current `beta`: 2.48.4
{% endhint %}

## Create a Droplet <a href="#create-a-droplet" id="create-a-droplet"></a>

1. [Log in](https://cloud.digitalocean.com/login) to DigitalOcean.
2. Select the project to host the Droplet, or [create a new project](https://docs.digitalocean.com/products/projects/how-to/create/).
3. In your project, select **Droplets** from the **Manage** menu.
4. [Create a new Droplet](https://docs.digitalocean.com/products/droplets/how-to/create/) using the [Docker image](https://marketplace.digitalocean.com/apps/docker) available on the **Marketplace** tab.

{% hint style="info" %}
**Droplet resources**

When creating the Droplet, DigitalOcean asks you to choose a plan. For most usage levels, a basic shared CPU plan is enough.
{% endhint %}

{% hint style="info" %}
**SSH key or Password**

DigitalOcean lets you choose between SSH key and password-based authentication. SSH keys are considered more secure.
{% endhint %}

## Log in to your Droplet and create new user <a href="#log-in-to-your-droplet-and-create-new-user" id="log-in-to-your-droplet-and-create-new-user"></a>

The rest of this guide requires you to log in to the Droplet using a terminal with SSH. Refer to [How to Connect to Droplets with SSH](https://docs.digitalocean.com/products/droplets/how-to/connect-with-ssh/) for more information.

You should create a new user, to avoid working as the root user:

1. Log in as root.
2. Create a new user:

   ```shell
   adduser <username>
   ```
3. Follow the prompts in the CLI to finish creating the user.
4. Grant the new user administrative privileges:

   ```shell
   usermod -aG sudo <username>
   ```

   You can now run commands with superuser privileges by using `sudo` before the command.
5. Follow the steps to set up SSH for the new user: [Add Public Key Authentication](https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-14-04#step-four-add-public-key-authentication-recommended).
6. Log out of the droplet.
7. Log in using SSH as the new user.

## Clone configuration repository <a href="#clone-configuration-repository" id="clone-configuration-repository"></a>

Docker Compose, n8n, and Caddy require a series of folders and configuration files. You can clone these from [this repository](https://github.com/n8n-io/n8n-docker-caddy) into the home folder of the logged-in user on your Droplet. The following steps will tell you which file to change and what changes to make.

Clone the repository with the following command:

```shell
git clone https://github.com/n8n-io/n8n-docker-caddy.git
```

And change directory to the root of the repository you cloned:

```shell
cd n8n-docker-caddy
```

## Default folders and files <a href="#default-folders-and-files" id="default-folders-and-files"></a>

The host operating system (the DigitalOcean Droplet) copies the two folders you created to Docker containers to make them available to Docker. The two folders are:

* `caddy_config`: Holds the Caddy configuration files.
* `local_files`: A folder for files you upload or add using n8n.

### Create Docker volumes <a href="#create-docker-volumes" id="create-docker-volumes"></a>

To persist the Caddy cache between restarts and speed up start times, create [a Docker volume](https://docs.docker.com/storage/volumes/) that Docker reuses between restarts:

```shell
sudo docker volume create caddy_data
```

Create a Docker volume for the n8n data:

```shell
sudo docker volume create n8n_data
```

## Set up DNS <a href="#set-up-dns" id="set-up-dns"></a>

n8n typically operates on a subdomain. Create a DNS record with your provider for the subdomain and point it to the IP address of the Droplet. The exact steps for this depend on your DNS provider, but typically you need to create a new "A" record for the n8n subdomain. DigitalOcean provide [An Introduction to DNS Terminology, Components, and Concepts](https://www.digitalocean.com/community/tutorials/an-introduction-to-dns-terminology-components-and-concepts).

## Open ports <a href="#open-ports" id="open-ports"></a>

n8n runs as a web application, so the Droplet needs to allow incoming access to traffic on port 80 for non-secure traffic, and port 443 for secure traffic.

Open the following ports in the Droplet's firewall by running the following two commands:

```shell
sudo ufw allow 80
sudo ufw allow 443
```

## Configure n8n <a href="#configure-n8n" id="configure-n8n"></a>

n8n needs some environment variables set to pass to the application running in the Docker container. The example `.env` file contains placeholders you need to replace with values of your own.

Open the file with the following command:

```shell
nano .env
```

The file contains inline comments to help you know what to change.

Refer to [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables) for n8n environment variables details.

## The Docker Compose file <a href="#the-docker-compose-file" id="the-docker-compose-file"></a>

The Docker Compose file (`docker-compose.yml`) defines the services the application needs, in this case Caddy and n8n. There's no separate database service — n8n uses its built-in SQLite database by default.

* The Caddy service definition defines the ports it uses and the local volumes to copy to the containers.
* The n8n service definition defines the ports it uses, the environment variables n8n needs to run (some defined in the `.env` file), and the volumes it needs to copy to the containers.

The Docker Compose file uses the environment variables set in the `.env` file, so you shouldn't need to change it's content, but to take a look, run the following command:

```shell
nano docker-compose.yml
```

## Configure Caddy <a href="#configure-caddy" id="configure-caddy"></a>

Caddy needs to know which domains it should serve, and which port to expose to the outside world. Edit the `Caddyfile` file in the `caddy_config` folder.

```shell
nano caddy_config/Caddyfile
```

Change the placeholder domain to yours. If you followed the steps to name the subdomain n8n, your full domain is similar to `n8n.example.com`. The `n8n` in the `reverse_proxy` setting tells Caddy to use the service definition defined in the `docker-compose.yml` file:

```
n8n.<domain>.<suffix> {
    reverse_proxy n8n:5678 {
      flush_interval -1
    }
}
```

If you were to use `automate.example.com`, your `Caddyfile` may look something like:

```
automate.example.com {
    reverse_proxy n8n:5678 {
      flush_interval -1
    }
}
```

## Start Docker Compose <a href="#start-docker-compose" id="start-docker-compose"></a>

Start n8n and Caddy with the following command:

```shell
sudo docker compose up -d
```

This may take a few minutes.

## Test your setup <a href="#test-your-setup" id="test-your-setup"></a>

In your browser, open the URL formed of the subdomain and domain name defined earlier. The first time you open it, n8n prompts you to create an owner account.

## Stop n8n and Caddy <a href="#stop-n8n-and-caddy" id="stop-n8n-and-caddy"></a>

You can stop n8n and Caddy with the following command:

```shell
sudo docker compose stop
```

## Optional: Add n8n Assistant <a href="#optional-add-n8n-assistant" id="optional-add-n8n-assistant"></a>

n8n Assistant needs a sandbox to run code in. You can add the same sandbox stack used in the [Docker Compose guide](/deploy/host-n8n/install-options/install-using-docker-compose) to this setup. A few things are worth knowing before you start:

* This sandbox is for development and testing only. The stack below uses n8n's own bundled sandbox (`n8n-sandbox`), whose runner runs with `privileged: true` and gives weak isolation. Since a DigitalOcean droplet with a public domain is often a real deployment, don't use this stack for production. Run nothing else on the droplet. If you need a more isolated sandbox on a single Linux VM, [install Sysbox on the VM](https://github.com/n8n-io/n8n-sandbox-service/blob/main/docs/quickstart-linux.md) and follow its steps to run the runner with Sysbox instead of `privileged: true`. The Compose file in this guide doesn't include those changes. See [Set up n8n Assistant](/deploy/host-n8n/configure-n8n/set-up-n8n-assistant) for other production options.
* **Resize if needed.** The sandbox runner uses Docker-in-Docker, which needs more headroom than n8n alone. Make sure you provision at least 4 GB RAM / 2 vCPU.
* **No networking changes required.** Caddy only ever proxies n8n itself; the sandbox services stay internal to the Compose network and don't need DNS, firewall, or Caddyfile changes.

1. Add the sandbox secrets to `.env`, alongside the variables already there:

   ```
   # Sandbox service secrets — pick your own values
   SANDBOX_API_KEYS=change-me-api-key
   SANDBOX_API_RUNNER_REGISTRATION_TOKEN=change-me-registration-token
   SANDBOX_API_RUNNER_API_KEY=change-me-runner-key

   # Web search: secret for the bundled SearXNG instance — pick your own value
   SEARXNG_SECRET=change-me-searxng-secret
   ```
2. Create a `searxng-settings.yml` file alongside your other config files (the stock SearXNG image only serves HTML; this turns on the JSON API n8n's web search needs):

   ```yaml
   use_default_settings: true
   search:
     formats:
       - html
       - json
   ```
3. Open `docker-compose.yml` and add the sandbox and search services alongside the existing `caddy` and `n8n` services:

   ```yaml
   volumes:
     sandbox-tls:

   services:
     sandbox-certs:
       image: ghcr.io/n8n-io/n8n-sandbox-service-api:latest
       user: '0:0'
       entrypoint: ['sh', '-c']
       command:
         - >
           bootstrap-mtls.sh --out-dir /tls --api-san sandbox-api
           --control-san-prefix sandbox-runner &&
           chown -R sandbox-api:sandbox-api /tls/api
       environment:
         NUM_RUNNERS: '1'
       volumes:
         - sandbox-tls:/tls

     sandbox-api:
       image: ghcr.io/n8n-io/n8n-sandbox-service-api:latest
       depends_on:
         sandbox-certs:
           condition: service_completed_successfully
       environment:
         SANDBOX_API_KEYS: ${SANDBOX_API_KEYS}
         SANDBOX_API_RUNNER_REGISTRATION_TOKEN: ${SANDBOX_API_RUNNER_REGISTRATION_TOKEN}
         SANDBOX_API_RUNNER_API_KEY: ${SANDBOX_API_RUNNER_API_KEY}
         SANDBOX_API_GRPC_TLS_CERT_FILE: /tls/api/grpc-server.crt
         SANDBOX_API_GRPC_TLS_KEY_FILE: /tls/api/grpc-server.key
         SANDBOX_API_GRPC_TLS_CLIENT_CA_FILE: /tls/api/ca.crt
         SANDBOX_API_RUNNER_CONTROL_GRPC_TLS_CA_FILE: /tls/api/ca.crt
         SANDBOX_API_RUNNER_CONTROL_GRPC_TLS_CERT_FILE: /tls/api/control-grpc-api-client.crt
         SANDBOX_API_RUNNER_CONTROL_GRPC_TLS_KEY_FILE: /tls/api/control-grpc-api-client.key
         SANDBOX_API_RUNNER_CONTROL_GRPC_TLS_SERVER_NAME: sandbox-runner-1
       volumes:
         - sandbox-tls:/tls:ro
       healthcheck:
         test: ["CMD", "wget", "-qO-", "http://localhost:8080/healthz"]
         interval: 5s
         timeout: 3s
         retries: 5
         start_period: 10s
       # Never publish 8080/9090 — Caddy never routes to this service, and it shouldn't.

     sandbox-runner-1:
       image: ghcr.io/n8n-io/n8n-sandbox-service-runner-dind:latest
       privileged: true
       depends_on:
         sandbox-api:
           condition: service_healthy
       environment:
         SANDBOX_RUNNER_API_KEYS: ${SANDBOX_API_RUNNER_API_KEY}
         SANDBOX_RUNNER_REGISTRATION_TOKEN: ${SANDBOX_API_RUNNER_REGISTRATION_TOKEN}
         SANDBOX_RUNNER_API_GRPC_ADDR: sandbox-api:9090
         SANDBOX_RUNNER_HTTP_BASE_URL: http://sandbox-runner-1:8080
         SANDBOX_RUNNER_CONTROL_GRPC_LISTEN_ADDR: ':9091'
         SANDBOX_RUNNER_CONTROL_GRPC_ADVERTISE_ADDR: sandbox-runner-1:9091
         SANDBOX_RUNNER_ID: runner-1
         SANDBOX_RUNNER_DOCKER_SANDBOX_IMAGE: ghcr.io/n8n-io/n8n-sandbox-service-sandbox:latest
         SANDBOX_RUNNER_REGISTRATION_GRPC_CA_FILE: /tls/runner/ca.crt
         SANDBOX_RUNNER_REGISTRATION_GRPC_CERT_FILE: /tls/runner/grpc-client.crt
         SANDBOX_RUNNER_REGISTRATION_GRPC_KEY_FILE: /tls/runner/grpc-client.key
         SANDBOX_RUNNER_REGISTRATION_GRPC_SERVER_NAME: sandbox-api
         SANDBOX_RUNNER_CONTROL_GRPC_TLS_CERT_FILE: /tls/runner/control-grpc-server.crt
         SANDBOX_RUNNER_CONTROL_GRPC_TLS_KEY_FILE: /tls/runner/control-grpc-server.key
         SANDBOX_RUNNER_CONTROL_GRPC_TLS_CLIENT_CA_FILE: /tls/runner/ca.crt
       volumes:
         - sandbox-tls:/tls:ro
       # Never expose this container's ports publicly — it runs privileged Docker-in-Docker.

     searxng:
       image: ghcr.io/searxng/searxng:latest
       environment:
         SEARXNG_SECRET: ${SEARXNG_SECRET}
       volumes:
         - ./searxng-settings.yml:/etc/searxng/settings.yml:ro
       # Internal-only: n8n reaches it by service name. Never publish its port, and don't route Caddy to it.
   ```
4. Add the matching sandbox variables to the existing `n8n` service's `environment` block:

   ```yaml
   environment:
    # ...your existing N8N_HOST, N8N_PORT, etc. stay as they are
    - N8N_ENABLED_MODULES=instance-ai
    - N8N_INSTANCE_AI_SANDBOX_ENABLED=true
    - N8N_INSTANCE_AI_SANDBOX_PROVIDER=n8n-sandbox
    - N8N_SANDBOX_SERVICE_URL=http://sandbox-api:8080
    - N8N_SANDBOX_SERVICE_API_KEY=${SANDBOX_API_KEYS}
    - N8N_INSTANCE_AI_SEARXNG_URL=http://searxng:8080
   depends_on:
    sandbox-api:
      condition: service_healthy
   ```
5. Restart everything so the new services pick up the changes:

   ```bash
   sudo docker compose up -d
   ```
6. Add your model API key. See [Set up n8n Assistant](/deploy/host-n8n/configure-n8n/set-up-n8n-assistant) for the full reference, including how to pick a model provider. Web search works out of the box via the bundled SearXNG service above; add a Brave Search key instead if you'd rather use that.

{% hint style="warning" %}
Replace the `change-me-...` placeholders in `.env` with your own unique secrets before exposing this Droplet to the internet. `sandbox-runner-1` runs privileged Docker-in-Docker. Never publish its ports, and don't route Caddy to it.
{% endhint %}

## Updating <a href="#updating" id="updating"></a>

If you run n8n using a Docker Compose file, follow these steps to update n8n:

```sh
# Navigate to the directory containing your docker compose file <a href="#navigate-to-the-directory-containing-your-docker-compose-file" id="navigate-to-the-directory-containing-your-docker-compose-file"></a>
cd </path/to/your/compose/file/directory>

# Pull latest version <a href="#pull-latest-version" id="pull-latest-version"></a>
docker compose pull

# Stop and remove older version <a href="#stop-and-remove-older-version" id="stop-and-remove-older-version"></a>
docker compose down

# Start the container <a href="#start-the-container" id="start-the-container"></a>
docker compose up -d
```

## Next steps <a href="#next-steps" id="next-steps"></a>

* Learn more about [configuring](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables) and [scaling](/deploy/host-n8n/configure-n8n/scaling) n8n.
* Or explore using n8n: try the [Quickstarts](/build-your-first-workflow).

## Related resources

* [Use a cloud provider](/deploy/host-n8n/install-options/use-a-cloud-provider)
* [Heroku](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-heroku)
* [Hetzner Cloud](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-hetzner)
* [AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws)
* [Azure](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-azure)
* [Google Cloud Run](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-cloud-run)
* [Google Kubernetes Engine](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-kubernetes)
* [OpenShift Local (CRC)](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-openshift-local-crc)
* [Use Docker Compose](/deploy/host-n8n/install-options/use-a-cloud-provider/use-docker-compose)


# Deploy to Heroku

This hosting guide shows you how to self-host n8n on Heroku. It uses:

* [Docker Compose](https://docs.docker.com/compose/) to create and define the application components and how they work together.
* [Heroku's PostgreSQL service](https://devcenter.heroku.com/categories/heroku-postgres) to host n8n's data storage.
* A **Deploy to Heroku** button offering a one click, with minor configuration, deployment.

{% hint style="info" %}
**Self-hosting knowledge prerequisites**

Self-hosting n8n requires technical knowledge, including:

* Setting up and configuring servers and containers
* Managing application resources and scaling
* Securing servers and applications
* Configuring n8n

n8n recommends self-hosting for expert users. Mistakes can lead to data loss, security issues, and downtime. If you aren't experienced at managing servers, n8n recommends [n8n Cloud](https://n8n.io/cloud/).
{% endhint %}

{% hint style="info" %}
**Stable and Beta versions**

n8n releases a new minor version most weeks. The `stable` version is for production use. `beta` is the most recent release. The `beta` version may be unstable. To report issues, use the [forum](https://community.n8n.io/c/questions/12).

Current `stable`: 2.47.7 Current `beta`: 2.48.4
{% endhint %}

## Use the deployment template to create a Heroku project <a href="#use-the-deployment-template-to-create-a-heroku-project" id="use-the-deployment-template-to-create-a-heroku-project"></a>

The quickest way to get started with deploying n8n to Heroku is using the **Deploy to Heroku** button:

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://dashboard.heroku.com/new?template=https://github.com/n8n-io/n8n-heroku/tree/main)

This opens the **Create New App** page on Heroku. Set a name for the project, and choose the region to deploy the project to.

### Configure environment variables <a href="#configure-environment-variables" id="configure-environment-variables"></a>

Heroku pre-fills the configuration options defined in the `env` section of the `app.json` file, which also sets default values for the environment variables n8n uses.

You can change any of these values to suit your needs. You must change the following values:

* **N8N\_ENCRYPTION\_KEY**, which n8n uses to [encrypt user account details](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/deployment) before saving to the database.
* **WEBHOOK\_URL** should match the application name you create to ensure that webhooks have the correct URL.

### Deploy n8n <a href="#deploy-n8n" id="deploy-n8n"></a>

Select **Deploy app**.

After Heroku builds and deploys the app it provides links to **Manage App** or **View** the application.

{% hint style="info" %}
**Heroku and DNS**

Refer to the [Heroku documentation](https://devcenter.heroku.com/categories/networking-dns) to find out how to connect your domain to a Heroku application.
{% endhint %}

## Changing the deployment template <a href="#changing-the-deployment-template" id="changing-the-deployment-template"></a>

You can make changes to the deployment template by forking the [repository](https://github.com/n8n-io/n8n-heroku) and deploying from you fork.

### The Dockerfile <a href="#the-dockerfile" id="the-dockerfile"></a>

By default the Dockerfile pulls the latest n8n image, if you want to use a different or fixed version, then update the image tag on the top line of the `Dockerfile`.

### Heroku and exposing ports <a href="#heroku-and-exposing-ports" id="heroku-and-exposing-ports"></a>

Heroku doesn't allow Docker-based applications to define an exposed port with the `EXPOSE` command. Instead, Heroku provides a `PORT` environment variable that it dynamically populates at application runtime. The `entrypoint.sh` file overrides the default Docker image command to instead set the port variable that Heroku provides. You can then access n8n on port 80 in a web browser.

{% hint style="info" %}
**Docker limitations with Heroku**

[Read this guide](https://devcenter.heroku.com/articles/container-registry-and-runtime#unsupported-dockerfile-commands) for more details on the limitations of using Docker with Heroku.
{% endhint %}

### Configuring Heroku <a href="#configuring-heroku" id="configuring-heroku"></a>

The `heroku.yml` file defines the application you want to create on Heroku. It consists of two sections:

* `setup` > `addons` defines the Heroku addons to use. In this case, the PostgreSQL database addon.
* The `build` section defines how Heroku builds the application. In this case it uses the Docker buildpack to build a `web` service based on the supplied `Dockerfile`.

## Next steps <a href="#next-steps" id="next-steps"></a>

* Learn more about [configuring](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables) and [scaling](/deploy/host-n8n/configure-n8n/scaling) n8n.
* Or explore using n8n: try the [Quickstarts](/build-your-first-workflow).

## Related resources

* [Use a cloud provider](/deploy/host-n8n/install-options/use-a-cloud-provider)
* [DigitalOcean](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-digital-ocean)
* [Hetzner Cloud](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-hetzner)
* [AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws)
* [Azure](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-azure)
* [Google Cloud Run](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-cloud-run)
* [Google Kubernetes Engine](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-kubernetes)
* [OpenShift Local (CRC)](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-openshift-local-crc)
* [Use Docker Compose](/deploy/host-n8n/install-options/use-a-cloud-provider/use-docker-compose)


# Deploy to Hetzner

This hosting guide shows you how to self-host n8n on a Hetzner cloud server. It uses:

* [Caddy](https://caddyserver.com) (a reverse proxy) to allow access to the Server from the internet.
* [Docker Compose](https://docs.docker.com/compose/) to create and define the application components and how they work together.

Once n8n is up and running, an optional last section covers adding n8n Assistant.

{% hint style="info" %}
**Self-hosting knowledge prerequisites**

Self-hosting n8n requires technical knowledge, including:

* Setting up and configuring servers and containers
* Managing application resources and scaling
* Securing servers and applications
* Configuring n8n

n8n recommends self-hosting for expert users. Mistakes can lead to data loss, security issues, and downtime. If you aren't experienced at managing servers, n8n recommends [n8n Cloud](https://n8n.io/cloud/).
{% endhint %}

{% hint style="info" %}
**Stable and Beta versions**

n8n releases a new minor version most weeks. The `stable` version is for production use. `beta` is the most recent release. The `beta` version may be unstable. To report issues, use the [forum](https://community.n8n.io/c/questions/12).

Current `stable`: 2.47.7 Current `beta`: 2.48.4
{% endhint %}

## Create a server <a href="#create-a-server" id="create-a-server"></a>

1. [Log in](https://console.hetzner.cloud/) to the Hetzner Cloud Console.
2. Select the project to host the server, or create a new project by selecting **+ NEW PROJECT**.
3. Select **+ CREATE SERVER** on the project tile you want to add it to.

You can change most of the settings to suit your needs, but as this guide uses Docker to run the application, under the **Image** section, select "Docker CE" from the **APPS** tab.

{% hint style="info" %}
**Type**

When creating the server, Hetzner asks you to choose a plan. For most usage levels, the CPX11 type is enough. If you plan to add n8n Assistant, choose a plan with at least 4 GB RAM / 2 vCPU instead. CPX11 doesn't have enough headroom once the sandbox is added.
{% endhint %}

{% hint style="info" %}
**SSH keys**

Hetzner lets you choose between SSH and password-based authentication. SSH is more secure. The rest of this guide assumes you are using SSH.
{% endhint %}

## Log in to your server <a href="#log-in-to-your-server" id="log-in-to-your-server"></a>

The rest of this guide requires you to log in to the server using a terminal with SSH. Refer to [Access with SSH/rsync/BorgBackup](https://docs.hetzner.com/robot/storage-box/access/access-ssh-rsync-borg) for more information. You can find the public IP in the listing of the servers in your project.

## Install Docker Compose <a href="#install-docker-compose" id="install-docker-compose"></a>

The Hetzner Docker app image doesn't have Docker compose installed. Install it with the following commands:

```shell
apt update && apt -y upgrade
apt install docker-compose-plugin
```

## Clone configuration repository <a href="#clone-configuration-repository" id="clone-configuration-repository"></a>

Docker Compose, n8n, and Caddy require a series of folders and configuration files. You can clone these from [this repository](https://github.com/n8n-io/n8n-docker-caddy) into the root user folder of the server. The following steps will tell you which file to change and what changes to make.

Clone the repository with the following command:

```shell
git clone https://github.com/n8n-io/n8n-docker-caddy.git
```

And change directory to the root of the repository you cloned:

```shell
cd n8n-docker-caddy
```

## Default folders and files <a href="#default-folders-and-files" id="default-folders-and-files"></a>

The host operating system (the server) copies the two folders you created to Docker containers to make them available to Docker. The two folders are:

* `caddy_config`: Holds the Caddy configuration files.
* `local_files`: A folder for files you upload or add using n8n.

### Create Docker volume <a href="#create-docker-volume" id="create-docker-volume"></a>

To persist the Caddy cache between restarts and speed up start times, create [a Docker volume](https://docs.docker.com/storage/volumes/) that Docker reuses between restarts:

```shell
docker volume create caddy_data
```

Create a Docker volume for the n8n data:

```shell
sudo docker volume create n8n_data
```

## Set up DNS <a href="#set-up-dns" id="set-up-dns"></a>

n8n typically operates on a subdomain. Create a DNS record with your provider for the subdomain and point it to the IP address of the server. The exact steps for this depend on your DNS provider, but typically you need to create a new "A" record for the n8n subdomain. DigitalOcean provide [An Introduction to DNS Terminology, Components, and Concepts](https://www.digitalocean.com/community/tutorials/an-introduction-to-dns-terminology-components-and-concepts).

## Open ports <a href="#open-ports" id="open-ports"></a>

n8n runs as a web application, so the server needs to allow incoming access to traffic on port 80 for non-secure traffic, and port 443 for secure traffic.

Open the following ports in the server's firewall by running the following two commands:

```shell
sudo ufw allow 80
sudo ufw allow 443
```

{% hint style="info" %}
If you add n8n Assistant later, its sandbox services stay internal to the Compose network. You don't need to open any additional ports for them.
{% endhint %}

## Configure n8n <a href="#configure-n8n" id="configure-n8n"></a>

n8n needs some environment variables set to pass to the application running in the Docker container. The example `.env` file contains placeholders you need to replace with values of your own.

Open the file with the following command:

```shell
nano .env
```

The file contains inline comments to help you know what to change.

Refer to [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables) for n8n environment variables details.

## The Docker Compose file <a href="#the-docker-compose-file" id="the-docker-compose-file"></a>

The Docker Compose file (`docker-compose.yml`) defines the services the application needs, in this case Caddy and n8n. There's no separate database service. n8n uses its built-in SQLite database by default.

* The Caddy service definition defines the ports it uses and the local volumes to copy to the containers.
* The n8n service definition defines the ports it uses, the environment variables n8n needs to run (some defined in the `.env` file), and the volumes it needs to copy to the containers.

The Docker Compose file uses the environment variables set in the `.env` file, so you shouldn't need to change it's content, but to take a look, run the following command:

```shell
nano docker-compose.yml
```

## Configure Caddy <a href="#configure-caddy" id="configure-caddy"></a>

Caddy needs to know which domains it should serve, and which port to expose to the outside world. Edit the `Caddyfile` file in the `caddy_config` folder.

```shell
nano caddy_config/Caddyfile
```

Change the placeholder subdomain to yours. If you followed the steps to name the subdomain n8n, your full domain is similar to `n8n.example.com`. The `n8n` in the `reverse_proxy` setting tells Caddy to use the service definition defined in the `docker-compose.yml` file:

```
n8n.<domain>.<suffix> {
    reverse_proxy n8n:5678 {
      flush_interval -1
    }
}
```

## Start Docker Compose <a href="#start-docker-compose" id="start-docker-compose"></a>

Start n8n and Caddy with the following command:

```shell
docker compose up -d
```

This may take a few minutes.

## Test your setup <a href="#test-your-setup" id="test-your-setup"></a>

In your browser, open the URL formed of the subdomain and domain name defined earlier. Enter the user name and password defined earlier, and you should be able to access n8n.

## Stop n8n and Caddy <a href="#stop-n8n-and-caddy" id="stop-n8n-and-caddy"></a>

You can stop n8n and Caddy with the following command:

```shell
sudo docker compose stop
```

## Optional: Add n8n Assistant <a href="#optional-add-n8n-assistant" id="optional-add-n8n-assistant"></a>

n8n Assistant needs a sandbox to run code in. You can add the same sandbox stack used in the [Docker Compose guide](/deploy/host-n8n/install-options/install-using-docker-compose) to this setup. A few things are worth knowing before you start:

* This sandbox is for development and testing only. The stack below uses n8n's own bundled sandbox (`n8n-sandbox`), whose runner runs with `privileged: true` and gives weak isolation. Since a Hetzner server with a public domain is often a real deployment, don't use this stack for production. Run nothing else on the server. If you need a more isolated sandbox on a single Linux VM, [install Sysbox on the VM](https://github.com/n8n-io/n8n-sandbox-service/blob/main/docs/quickstart-linux.md) and follow its steps to run the runner with Sysbox instead of `privileged: true`. The Compose file in this guide doesn't include those changes. See [Set up n8n Assistant](/deploy/host-n8n/configure-n8n/set-up-n8n-assistant) for other production options.
* **Resize if needed.** The sandbox runner uses Docker-in-Docker, which needs more headroom than n8n alone. Make sure you provision at least 4 GB RAM / 2 vCPU.
* **No networking changes required.** Caddy only ever proxies n8n itself; the sandbox services stay internal to the Compose network and don't need DNS, firewall, or Caddyfile changes.

1. Add the sandbox secrets to `.env`, alongside the variables already there:

   ```
   # Sandbox service secrets — pick your own values
   SANDBOX_API_KEYS=change-me-api-key
   SANDBOX_API_RUNNER_REGISTRATION_TOKEN=change-me-registration-token
   SANDBOX_API_RUNNER_API_KEY=change-me-runner-key

   # Web search: secret for the bundled SearXNG instance — pick your own value
   SEARXNG_SECRET=change-me-searxng-secret
   ```
2. Create a `searxng-settings.yml` file alongside your other config files (the stock SearXNG image only serves HTML; this turns on the JSON API n8n's web search needs):

   ```yaml
   use_default_settings: true
   search:
     formats:
       - html
       - json
   ```
3. Open `docker-compose.yml` and add the sandbox and search services alongside the existing `caddy` and `n8n` services:

   ```yaml
   volumes:
     sandbox-tls:

   services:
     sandbox-certs:
       image: ghcr.io/n8n-io/n8n-sandbox-service-api:latest
       user: '0:0'
       entrypoint: ['sh', '-c']
       command:
         - >
           bootstrap-mtls.sh --out-dir /tls --api-san sandbox-api
           --control-san-prefix sandbox-runner &&
           chown -R sandbox-api:sandbox-api /tls/api
       environment:
         NUM_RUNNERS: '1'
       volumes:
         - sandbox-tls:/tls

     sandbox-api:
       image: ghcr.io/n8n-io/n8n-sandbox-service-api:latest
       depends_on:
         sandbox-certs:
           condition: service_completed_successfully
       environment:
         SANDBOX_API_KEYS: ${SANDBOX_API_KEYS}
         SANDBOX_API_RUNNER_REGISTRATION_TOKEN: ${SANDBOX_API_RUNNER_REGISTRATION_TOKEN}
         SANDBOX_API_RUNNER_API_KEY: ${SANDBOX_API_RUNNER_API_KEY}
         SANDBOX_API_GRPC_TLS_CERT_FILE: /tls/api/grpc-server.crt
         SANDBOX_API_GRPC_TLS_KEY_FILE: /tls/api/grpc-server.key
         SANDBOX_API_GRPC_TLS_CLIENT_CA_FILE: /tls/api/ca.crt
         SANDBOX_API_RUNNER_CONTROL_GRPC_TLS_CA_FILE: /tls/api/ca.crt
         SANDBOX_API_RUNNER_CONTROL_GRPC_TLS_CERT_FILE: /tls/api/control-grpc-api-client.crt
         SANDBOX_API_RUNNER_CONTROL_GRPC_TLS_KEY_FILE: /tls/api/control-grpc-api-client.key
         SANDBOX_API_RUNNER_CONTROL_GRPC_TLS_SERVER_NAME: sandbox-runner-1
       volumes:
         - sandbox-tls:/tls:ro
       healthcheck:
         test: ["CMD", "wget", "-qO-", "http://localhost:8080/healthz"]
         interval: 5s
         timeout: 3s
         retries: 5
         start_period: 10s
       # Never publish 8080/9090 — Caddy never routes to this service, and it shouldn't.

     sandbox-runner-1:
       image: ghcr.io/n8n-io/n8n-sandbox-service-runner-dind:latest
       privileged: true
       depends_on:
         sandbox-api:
           condition: service_healthy
       environment:
         SANDBOX_RUNNER_API_KEYS: ${SANDBOX_API_RUNNER_API_KEY}
         SANDBOX_RUNNER_REGISTRATION_TOKEN: ${SANDBOX_API_RUNNER_REGISTRATION_TOKEN}
         SANDBOX_RUNNER_API_GRPC_ADDR: sandbox-api:9090
         SANDBOX_RUNNER_HTTP_BASE_URL: http://sandbox-runner-1:8080
         SANDBOX_RUNNER_CONTROL_GRPC_LISTEN_ADDR: ':9091'
         SANDBOX_RUNNER_CONTROL_GRPC_ADVERTISE_ADDR: sandbox-runner-1:9091
         SANDBOX_RUNNER_ID: runner-1
         SANDBOX_RUNNER_DOCKER_SANDBOX_IMAGE: ghcr.io/n8n-io/n8n-sandbox-service-sandbox:latest
         SANDBOX_RUNNER_REGISTRATION_GRPC_CA_FILE: /tls/runner/ca.crt
         SANDBOX_RUNNER_REGISTRATION_GRPC_CERT_FILE: /tls/runner/grpc-client.crt
         SANDBOX_RUNNER_REGISTRATION_GRPC_KEY_FILE: /tls/runner/grpc-client.key
         SANDBOX_RUNNER_REGISTRATION_GRPC_SERVER_NAME: sandbox-api
         SANDBOX_RUNNER_CONTROL_GRPC_TLS_CERT_FILE: /tls/runner/control-grpc-server.crt
         SANDBOX_RUNNER_CONTROL_GRPC_TLS_KEY_FILE: /tls/runner/control-grpc-server.key
         SANDBOX_RUNNER_CONTROL_GRPC_TLS_CLIENT_CA_FILE: /tls/runner/ca.crt
       volumes:
         - sandbox-tls:/tls:ro
       # Never expose this container's ports publicly — it runs privileged Docker-in-Docker.

     searxng:
       image: ghcr.io/searxng/searxng:latest
       environment:
         SEARXNG_SECRET: ${SEARXNG_SECRET}
       volumes:
         - ./searxng-settings.yml:/etc/searxng/settings.yml:ro
       # Internal-only: n8n reaches it by service name. Never publish its port, and don't route Caddy to it.
   ```
4. Add the matching sandbox variables to the existing `n8n` service's `environment` block:

   ```yaml
   environment:
    # ...your existing N8N_HOST, N8N_PORT, etc. stay as they are
    - N8N_ENABLED_MODULES=instance-ai
    - N8N_INSTANCE_AI_SANDBOX_ENABLED=true
    - N8N_INSTANCE_AI_SANDBOX_PROVIDER=n8n-sandbox
    - N8N_SANDBOX_SERVICE_URL=http://sandbox-api:8080
    - N8N_SANDBOX_SERVICE_API_KEY=${SANDBOX_API_KEYS}
    - N8N_INSTANCE_AI_SEARXNG_URL=http://searxng:8080
   depends_on:
    sandbox-api:
      condition: service_healthy
   ```
5. Restart everything so the new services pick up the changes:

   ```bash
   sudo docker compose up -d
   ```
6. Add your model API key. See [Set up n8n Assistant](/deploy/host-n8n/configure-n8n/set-up-n8n-assistant) for the full reference, including how to pick a model provider. Web search works out of the box via the bundled SearXNG service above; add a Brave Search key instead if you'd rather use that.

{% hint style="warning" %}
Replace the `change-me-...` placeholders in `.env` with your own unique secrets before exposing this Droplet to the internet. `sandbox-runner-1` runs privileged Docker-in-Docker. Never publish its ports, and don't route Caddy to it.
{% endhint %}

## Updating <a href="#updating" id="updating"></a>

If you run n8n using a Docker Compose file, follow these steps to update n8n:

```sh
# Navigate to the directory containing your docker compose file <a href="#navigate-to-the-directory-containing-your-docker-compose-file" id="navigate-to-the-directory-containing-your-docker-compose-file"></a>
cd </path/to/your/compose/file/directory>

# Pull latest version <a href="#pull-latest-version" id="pull-latest-version"></a>
docker compose pull

# Stop and remove older version <a href="#stop-and-remove-older-version" id="stop-and-remove-older-version"></a>
docker compose down

# Start the container <a href="#start-the-container" id="start-the-container"></a>
docker compose up -d
```

## Next steps <a href="#next-steps" id="next-steps"></a>

* Learn more about [configuring](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables) and [scaling](/deploy/host-n8n/configure-n8n/scaling) n8n.
* Or explore using n8n: try the [Quickstarts](/build-your-first-workflow).

## Related resources

* [Use a cloud provider](/deploy/host-n8n/install-options/use-a-cloud-provider)
* [DigitalOcean](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-digital-ocean)
* [Heroku](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-heroku)
* [AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws)
* [Azure](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-azure)
* [Google Cloud Run](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-cloud-run)
* [Google Kubernetes Engine](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-kubernetes)
* [OpenShift Local (CRC)](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-openshift-local-crc)
* [Use Docker Compose](/deploy/host-n8n/install-options/use-a-cloud-provider/use-docker-compose)


# Deploy to AWS

This hosting guide shows you how to self-host n8n with Amazon Web Services (AWS). It uses n8n with Postgres as a database backend using Kubernetes to manage the necessary resources and reverse proxy.

## Hosting options <a href="#hosting-options" id="hosting-options"></a>

AWS offers several ways suitable for hosting n8n, including EC2 (virtual machines), and EKS (containers running with Kubernetes).

This guide uses [EKS](https://aws.amazon.com/eks/) as the hosting option. Using Kubernetes requires some additional complexity and configuration, but is the best method for scaling n8n as demand changes.

{% hint style="info" %}
**Looking for a production-grade, highly available setup?**

For a multi-main deployment with managed PostgreSQL, Redis, and autoscaling workers, see [Deploy to AWS with Terraform](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform).
{% endhint %}

## Prerequisites <a href="#prerequisites" id="prerequisites"></a>

The steps in this guide use a mix of the AWS UI and [the eksctl CLI tool for EKS](https://eksctl.io).

While not mentioned in the documentation for eksctl, you also need to [install the AWS CLI tool](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html), and [configure authentication of the tool](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html).

{% hint style="info" %}
**Self-hosting knowledge prerequisites**

Self-hosting n8n requires technical knowledge, including:

* Setting up and configuring servers and containers
* Managing application resources and scaling
* Securing servers and applications
* Configuring n8n

n8n recommends self-hosting for expert users. Mistakes can lead to data loss, security issues, and downtime. If you aren't experienced at managing servers, n8n recommends [n8n Cloud](https://n8n.io/cloud/).
{% endhint %}

{% hint style="info" %}
**Stable and Beta versions**

n8n releases a new minor version most weeks. The `stable` version is for production use. `beta` is the most recent release. The `beta` version may be unstable. To report issues, use the [forum](https://community.n8n.io/c/questions/12).

Current `stable`: 2.47.7 Current `beta`: 2.48.4
{% endhint %}

## Create a cluster <a href="#create-a-cluster" id="create-a-cluster"></a>

Use the eksctl tool to create a cluster specifying a name and a region with the following command:

```shell
eksctl create cluster --name n8n --region <your-aws-region>
```

This can take a while to create the cluster.

Once the cluster is created, eksctl automatically sets the kubectl context to the cluster.

## Clone configuration repository <a href="#clone-configuration-repository" id="clone-configuration-repository"></a>

Kubernetes and n8n require a series of configuration files. You can clone these from [this repository](https://github.com/n8n-io/n8n-hosting). The following steps tell you what each file does, and what settings you need to change.

Clone the repository with the following command:

```shell
git clone https://github.com/n8n-io/n8n-hosting.git 
```

And change directory:

```shell
cd n8n-hosting/kubernetes
```

## Configure Postgres <a href="#configure-postgres" id="configure-postgres"></a>

For larger scale n8n deployments, Postgres provides a more robust database backend than SQLite.

### Configure volume for persistent storage <a href="#configure-volume-for-persistent-storage" id="configure-volume-for-persistent-storage"></a>

To maintain data between pod restarts, the Postgres deployment needs a persistent volume. The default AWS storage class, [gp3](https://docs.aws.amazon.com/ebs/latest/userguide/general-purpose.html#gp3-ebs-volume-type), is suitable for this purpose. This is defined in the `postgres-claim0-persistentvolumeclaim.yaml` manifest.

```yaml
…
spec:
  storageClassName: gp3
  accessModes:
    - ReadWriteOnce
…
```

### Postgres environment variables <a href="#postgres-environment-variables" id="postgres-environment-variables"></a>

Postgres needs some environment variables set to pass to the application running in the containers.

The example `postgres-secret.yaml` file contains placeholders you need to replace with values of your own for user details and the database to use.

PostgreSQL uses a root user (`POSTGRES_USER`) for setup and administration, but it’s best practice to create a separate non-root user (`POSTGRES_NON_ROOT_USER`) for n8n. The root user has full control, while n8n only needs the non-root user permissions to run. Configuring both improves security and helps prevent accidental changes to the database system.

The `postgres-deployment.yaml` manifest then uses the values from this manifest file to send to the application pods.

## Configure n8n <a href="#configure-n8n" id="configure-n8n"></a>

### Create a volume for file storage <a href="#create-a-volume-for-file-storage" id="create-a-volume-for-file-storage"></a>

While not essential for running n8n, using persistent volumes helps maintain files uploaded while using n8n and if you want to persist [manual n8n encryption keys](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/deployment) between restarts, which saves a file containing the key into file storage during startup.

The `n8n-claim0-persistentvolumeclaim.yaml` manifest creates this, and the n8n Deployment mounts that claim in the `volumes` section of the `n8n-deployment.yaml` manifest.

```yaml
…
volumes:
  - name: n8n-claim0
    persistentVolumeClaim:
      claimName: n8n-claim0
…
```

### Pod resources <a href="#pod-resources" id="pod-resources"></a>

[Kubernetes](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) lets you specify the minimum resources application containers need and the limits they can run to. The example YAML files cloned above contain the following in the `resources` section of the `n8n-deployment.yaml` file:

```yaml
…
resources:
  requests:
    memory: "250Mi"
  limits:
    memory: "500Mi"
…    
```

This defines a minimum of 250mb per container, a maximum of 500mb, and lets Kubernetes handle CPU. You can change these values to match your own needs. As a guide, here are the resources values for the n8n Cloud offerings:

| Tier                 | RAM    | CPU                    |
| -------------------- | ------ | ---------------------- |
| Starter              | 320mb  | 10 millicore burstable |
| Pro (10k executions) | 640mb  | 20 millicore burstable |
| Pro (50k executions) | 1280mb | 80 millicore burstable |

### Optional: Environment variables <a href="#optional-environment-variables" id="optional-environment-variables"></a>

You can configure n8n settings and behaviors using environment variables.

Create an `n8n-secret.yaml` file. Refer to [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables) for n8n environment variables details.

## Deployments <a href="#deployments" id="deployments"></a>

The two deployment manifests (`n8n-deployment.yaml` and `postgres-deployment.yaml`) define the n8n and Postgres applications to Kubernetes.

{% hint style="warning" %}
The manifests run PostgreSQL 18. Setting up for the first time needs nothing extra.

If you already have a database running an older PostgreSQL major version, don't apply this to it. PostgreSQL 18 can't open a data directory written by an older major version, and moving the folder doesn't help. The pod stays in `CrashLoopBackOff` with `database files are incompatible with server`. PostgreSQL leaves your data alone, and you can pin the image back to the version you were on.

To move an existing database across, follow the official [PostgreSQL upgrade guide](https://www.postgresql.org/docs/18/upgrading.html) first.
{% endhint %}

The manifests define the following:

* Send the environment variables defined to each application pod
* Define the container image to use
* Set resource consumption limits
* The `volumes` defined earlier and `volumeMounts` to define the path in the container to mount volumes.
* Scaling and restart policies. The example manifests define one instance of each pod. You should change this to meet your needs.

## Services <a href="#services" id="services"></a>

The two service manifests (`postgres-service.yaml` and `n8n-service.yaml`) expose the services to the outside world using the Kubernetes load balancer using ports 5432 and 5678 respectively by default.

## Send to Kubernetes cluster <a href="#send-to-kubernetes-cluster" id="send-to-kubernetes-cluster"></a>

Send all the manifests to the cluster by running the following command in the `n8n-kubernetes-hosting` directory:

```shell
kubectl apply -f .
```

{% hint style="info" %}
**Namespace error**

You may see an error message about not finding an "n8n" namespace as that resources isn't ready yet. You can run the same command again, or apply the namespace manifest first with the following command:

```shell
kubectl apply -f namespace.yaml
```

{% endhint %}

## Set up DNS <a href="#set-up-dns" id="set-up-dns"></a>

n8n typically operates on a subdomain. Create a DNS record with your provider for the subdomain and point it to a static address of the instance.

To find the address of the n8n service running on the instance:

1. Open the **Clusters** section of the **Amazon Elastic Kubernetes Service** page in the AWS console.
2. Select the name of the cluster to open its configuration page.
3. Select the **Resources** tab, then **Service and networking** > **Services**.
4. Select the **n8n** service and copy the **Load balancer URLs** value. Use this value suffixed with the n8n service port (5678) for DNS.

{% hint style="info" %}
**Use HTTP**

This guide uses HTTP connections for the services it defines, for example in `n8n-deployment.yaml`. However, if you click the **Load balancer URLs** value, EKS takes you to an "HTTPS" URL which results in an error. To solve this, when you open the n8n subdomain, make sure to use HTTP.
{% endhint %}

## Delete resources <a href="#delete-resources" id="delete-resources"></a>

If you need to delete the setup, you can remove the resources created by the manifests with the following command:

```shell
kubectl delete -f .
```

## Next steps <a href="#next-steps" id="next-steps"></a>

* Learn more about [configuring](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables) and [scaling](/deploy/host-n8n/configure-n8n/scaling) n8n.
* Or explore using n8n: try the [Quickstarts](/build-your-first-workflow).

## Related resources

* [Use a cloud provider](/deploy/host-n8n/install-options/use-a-cloud-provider)
* [Deploy to AWS with Terraform](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform)
* [DigitalOcean](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-digital-ocean)
* [Heroku](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-heroku)
* [Hetzner Cloud](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-hetzner)
* [Azure](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-azure)
* [Google Cloud Run](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-cloud-run)
* [Google Kubernetes Engine](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-kubernetes)
* [OpenShift Local (CRC)](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-openshift-local-crc)
* [Use Docker Compose](/deploy/host-n8n/install-options/use-a-cloud-provider/use-docker-compose)


# Deploy to AWS with Terraform

Deploy a production-grade, highly available n8n instance on AWS using the official Terraform module.

[terraform-aws-n8n](https://github.com/n8n-io/terraform-aws-n8n) is a Terraform module that deploys a production-grade, multi-main n8n instance to AWS. It provisions an Amazon EKS cluster running n8n's Helm chart, with managed PostgreSQL (RDS), Redis (ElastiCache), and S3 for shared file storage.

This differs from the manual [Kubernetes setup](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws) n8n documents elsewhere: that guide walks you through hand-written manifests for a single n8n instance. This module automates a highly available, auto-scaling deployment, and it's maintained independently by the n8n Solutions team.

{% hint style="warning" %}
**Pre-release module**

`terraform-aws-n8n` is in pre-release. Expect breaking changes before the module reaches its first stable (1.0) release.
{% endhint %}

{% hint style="info" %}
**Feature availability**

The default multi-main topology this module deploys is available on:

* **Self-hosted:** Enterprise

Setting `n8n_main_hpa_min_replicas = 1` runs a single main pod instead, which only requires a Business plan license. In that mode, the main pod's autoscaling maximum is forced to one, and upgrades use a `Recreate` strategy. Expect downtime for the editor, REST API, and scheduled triggers during upgrades and maintenance.
{% endhint %}

## Architecture

Users and inbound webhooks reach an Application Load Balancer that fronts the EKS cluster. Inside the cluster, the n8n Helm chart runs three separate deployments:

* **Main pods:** handle leader election, the editor UI, and the REST API.
* **Webhook processor pods:** handle inbound triggers.
* **Worker pods:** run workflow executions, and scale on Redis queue depth using [KEDA](https://keda.sh/).

State lives in managed services outside the cluster: RDS PostgreSQL for workflow data, ElastiCache Redis for leader election and the worker queue, and S3 for binary data. AWS Certificate Manager (ACM) issues the TLS certificate for the load balancer.

AWS grants pods permissions (for the Load Balancer Controller, Cluster Autoscaler, EBS CSI driver, and n8n's own S3 access) through EKS Pod Identity.

## Prerequisites

* An **n8n license key**: an Enterprise license for the default multi-main topology, or a Business license if you set `n8n_main_hpa_min_replicas = 1`.
* A **pre-existing VPC** with public and private subnets tagged for EKS and ALB use. The module doesn't create a VPC. See [Customize the AWS infrastructure](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/customize-the-infrastructure).
* **Terraform CLI 1.11 or later**, with the `aws`, `kubernetes`, and `helm` providers configured.
* A DNS option: either a Route 53 hosted zone (`route53_zone_id`), which lets the module issue the ACM certificate and manage the DNS record itself, or a pre-validated certificate from another provider (`certificate_arn`).

## Usage

For a step-by-step walkthrough that takes you from an empty folder to a running instance, see [Deploy your first n8n instance on AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/deploy-your-first-instance). The configuration below is the minimum set of inputs:

```hcl
module "n8n" {
  source  = "n8n-io/n8n/aws"
  version = "~> 0.5.0"

  aws_region      = "us-east-1"
  cluster_name    = "n8n-cluster"
  n8n_domain      = "n8n.example.com"
  n8n_license_key = var.n8n_license_key

  # Bring your own VPC.
  vpc_id          = module.vpc.vpc_id
  private_subnets = module.vpc.private_subnets
  public_subnets  = module.vpc.public_subnets
  vpc_cidr_block  = module.vpc.vpc_cidr_block

  # EKS node group autoscaling bounds. You pay for node_min nodes at all times.
  node_min = 3
  node_max = 6

  # Set exactly one of these for DNS and TLS.
  route53_zone_id = "Z0123456789ABCDEFGHIJ"
  # certificate_arn = aws_acm_certificate_validation.n8n.certificate_arn
}
```

Pass sensitive values such as `n8n_license_key` from a secrets manager, and store Terraform state in an encrypted, access-controlled backend because the module writes the key into the Helm release. Never hardcode the key in a `.tfvars` file you commit to version control.

## Choose a starting size

The module ships three sizing examples. Use one as your starting point, then tune node type, count, and database size from there.

|                                  | [small](https://github.com/n8n-io/terraform-aws-n8n/tree/main/examples/small) (default) | [medium](https://github.com/n8n-io/terraform-aws-n8n/tree/main/examples/medium) | [large](https://github.com/n8n-io/terraform-aws-n8n/tree/main/examples/large) |
| -------------------------------- | --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| Target scale                     | Development or small team                                                               | \~5-15M executions/day                                                          | \~50-60M+ executions/day                                                      |
| Node type                        | t3.xlarge                                                                               | m6i.2xlarge                                                                     | m7i.4xlarge                                                                   |
| Nodes (min/max)                  | 3/6                                                                                     | 5/15                                                                            | 10/50                                                                         |
| Database                         | RDS db.t3.small                                                                         | RDS db.m6g.2xlarge                                                              | Aurora PostgreSQL I/O-Optimized                                               |
| Redis                            | cache.t3.medium                                                                         | cache.r6g.large                                                                 | cache.r6g.large                                                               |
| Estimated cost/month (on-demand) | \~$440                                                                                  | \~$2,000                                                                        | \~$21,000+                                                                    |

Two topology variants are also available as examples: [split-ingress](https://github.com/n8n-io/terraform-aws-n8n/tree/main/examples/split-ingress) (see [Customize the AWS infrastructure](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/customize-the-infrastructure#customer-managed-ingress)) and [worker-pools](https://github.com/n8n-io/terraform-aws-n8n/tree/main/examples/worker-pools), an alpha n8n feature that runs separate labelled worker pools.

## Support

This module is open source, maintained by the n8n Solutions team independently of n8n's Enterprise support offering. Report bugs or request features on [GitHub issues](https://github.com/n8n-io/terraform-aws-n8n/issues); the maintainers triage on a best-effort basis, with no SLA. For general n8n questions unrelated to the module, use the [n8n community forum](https://community.n8n.io/).

## In this section

* [Deploy your first n8n instance on AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/deploy-your-first-instance): a step-by-step walkthrough, from an empty folder to a running instance.
* [Scale and run at high availability on AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/scale-and-run-at-high-availability): configure multi-main, worker autoscaling, and Redis high availability.
* [Configure Enterprise features on AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/use-enterprise-features-on-aws): wire up S3 execution data, Prometheus metrics, OpenTelemetry tracing, log streaming, and external secrets.
* [Customize the AWS infrastructure](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/customize-the-infrastructure): bring your own VPC, database, cache, or cluster, split ingress, or use a custom n8n image.
* [Maintain and tear down the AWS deployment](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/maintain-and-tear-down): manage encryption keys, verify database TLS, and configure deletion protection.

## Related resources

* [Use a cloud provider](/deploy/host-n8n/install-options/use-a-cloud-provider)
* [Deploy to AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws)
* [DigitalOcean](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-digital-ocean)
* [Heroku](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-heroku)
* [Hetzner Cloud](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-hetzner)
* [Azure](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-azure)
* [Google Cloud Run](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-cloud-run)
* [Google Kubernetes Engine](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-kubernetes)
* [OpenShift Local (CRC)](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-openshift-local-crc)
* [Use Docker Compose](/deploy/host-n8n/install-options/use-a-cloud-provider/use-docker-compose)
* [Enable queue mode](/deploy/host-n8n/configure-n8n/scaling/enable-queue-mode)


# Deploy your first n8n instance on AWS

A step-by-step walkthrough that deploys a working n8n instance on AWS with the terraform-aws-n8n module, from an empty folder to a running editor.

This walkthrough takes you from an empty folder to a running n8n instance on AWS in six steps, using the [terraform-aws-n8n](https://github.com/n8n-io/terraform-aws-n8n) module's `small` example. You write one file, `main.tf`, then run `terraform init`, `terraform plan`, and `terraform apply`.

You don't clone a repository. The example lives in the Terraform Registry as [`n8n-io/n8n/aws`](https://registry.terraform.io/modules/n8n-io/n8n/aws/0.5.0), and `terraform init` downloads it for you. The example bundles the VPC and the provider setup, so the configuration on this page is all the Terraform you write.

Expect about 30 minutes from `terraform apply` to a reachable editor.

{% hint style="info" %}
**Feature availability**

The default multi-main topology this module deploys is available on:

* **Self-hosted:** Enterprise

A Business license also works if you set `n8n_main_hpa_min_replicas = 1` to run a single main pod. See [Scale and run at high availability on AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/scale-and-run-at-high-availability) for what that mode changes.
{% endhint %}

## Prerequisites

Before you start, make sure you have:

* [Terraform CLI 1.11 or later](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli) installed.
* The [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) installed and configured with credentials that can create EKS, RDS, ElastiCache, IAM, VPC, KMS, S3, ACM, and Route 53 resources.
* A domain whose parent zone is hosted in AWS Route 53. You need the hosted zone ID. For example, to run n8n at `n8n.example.com`, you need the hosted zone for `example.com`.
* An n8n Enterprise license key, or a Business license key if you set `n8n_main_hpa_min_replicas = 1`.

## Step 1: Create a project folder

Terraform works from the folder you run it in, so start with an empty one:

```bash
mkdir n8n-aws
cd n8n-aws
```

## Step 2: Choose a deployment size

The terraform-aws-n8n module ships three sizing examples. This walkthrough deploys `small`, which suits a development or small-team instance:

|                                  | small (default)           | medium                 | large                    |
| -------------------------------- | ------------------------- | ---------------------- | ------------------------ |
| Target scale                     | Development or small team | \~5–15M executions/day | \~50–60M+ executions/day |
| Node type                        | t3.xlarge                 | m6i.2xlarge            | m7i.4xlarge              |
| Estimated cost/month (on-demand) | \~$440                    | \~$2,000               | \~$21,000+               |

For the full comparison, including pod counts, database sizing, and reserved-instance pricing, see the sizing table on [Deploy to AWS with Terraform](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform). If you're unsure, start with `small`: moving from `small` to `medium` is straightforward, while moving to `large` involves infrastructure changes.

To deploy a larger tier instead, point the module `source` in your `main.tf` at that example's subpath. [`examples/medium`](https://registry.terraform.io/modules/n8n-io/n8n/aws/0.5.0/examples/medium) takes the same inputs as `small`, and [`examples/large`](https://registry.terraform.io/modules/n8n-io/n8n/aws/0.5.0/examples/large) adds `certificate_arn` and `aurora_instance_class`.

## Step 3: Create `main.tf`

Create one file, `main.tf`, in your project folder. It references the registry's [small example](https://registry.terraform.io/modules/n8n-io/n8n/aws/0.5.0/examples/small) as a module, pinned to 0.5.0:

{% code title="main.tf" %}

```hcl
variable "n8n_license_key" {
  type      = string
  sensitive = true
}

module "n8n" {
  source  = "n8n-io/n8n/aws//examples/small"
  version = "0.5.0"

  n8n_domain      = "n8n.example.com"
  route53_zone_id = "<hosted-zone-id>"
  n8n_license_key = var.n8n_license_key

  # Applied to every resource, for cost tracking and ownership.
  tags = {
    Environment = "development"
    Owner       = "platform-team"
  }

  # aws_region   = "eu-west-1"   # optional, defaults to us-east-1
  # cluster_name = "n8n-cluster" # optional, 14 characters or fewer
}

output "n8n_url" {
  description = "The URL to open once the load balancer finishes provisioning."
  value       = module.n8n.n8n_url
}

output "n8n_encryption_key" {
  description = "Back this up in a password manager. n8n emits it once."
  value       = module.n8n.n8n_encryption_key
  sensitive   = true
}
```

{% endcode %}

`cluster_name` must be 14 characters or fewer. The module derives an ElastiCache cluster ID of `<cluster-name>-redis`, and AWS caps those at 20 characters.

## Step 4: Set your values

In `main.tf`, replace:

* `n8n_domain` with the domain you want to run n8n on.
* `route53_zone_id` with the hosted zone ID for that domain's parent zone.
* `tags` with whatever your organization uses for cost tracking and ownership.

Then provide your license key as an environment variable, so it stays out of the file:

```bash
export TF_VAR_n8n_license_key="<your-license-key>"
```

## Step 5: Initialize Terraform

```bash
terraform init
```

This downloads the n8n module, the VPC module, and the `aws`, `kubernetes`, and `helm` providers.

## Step 6: Plan and apply

Preview what Terraform creates:

```bash
terraform plan
```

Review the plan, then apply it:

```bash
terraform apply
```

Type `yes` when prompted, or add `-auto-approve` to skip the confirmation. Provisioning takes about 20 to 25 minutes, and the load balancer needs about five more minutes after that to become reachable.

When it finishes, open the URL from the `n8n_url` output:

```bash
terraform output -raw n8n_url
```

n8n shows the setup screen. Enter your email, first and last name, and a password to create the owner account. Complete or skip the questionnaire to reach your workspace.

{% hint style="danger" %}
**Save your encryption key now**

n8n generates the encryption key once. Without it, every stored credential becomes unreadable, and no one can recover it for you. Run `terraform output -raw n8n_encryption_key` and store the value in a password manager before you go any further.
{% endhint %}

## Protect your Terraform state file

Terraform writes a `terraform.tfstate` file in your project folder. It records your infrastructure, and it stores secrets in plain text: the n8n encryption key, the database password, and your license key. Marking an output `sensitive` only hides it from the terminal, not from the state file.

Follow two rules:

* Never commit `terraform.tfstate` to version control.
* For anything beyond a quick trial, store state remotely in HCP Terraform or an S3 bucket configured with encryption, versioning, state locking, and strict access controls.

## Clean up

To tear down everything this example created:

```bash
terraform destroy
```

Type `yes` when prompted, or add `-auto-approve`.

The `small` example ships teardown-friendly defaults so that `terraform destroy` runs cleanly: the RDS instance skips its final snapshot, and the S3 bucket force-destroys. Review these before you promote the setup to production. See [Maintain and tear down the AWS deployment](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/maintain-and-tear-down) for the production values, and note that the module schedules its KMS keys for deletion seven days after a destroy, which blocks recovery from any retained snapshot.

## Related resources

Your instance is running the module's defaults. From here:

* [Scale and run at high availability on AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/scale-and-run-at-high-availability): tune multi-main, worker autoscaling, and Redis high availability.
* [Configure Enterprise features on AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/use-enterprise-features-on-aws): wire up S3 execution data, Prometheus metrics, OpenTelemetry tracing, log streaming, and external secrets.
* [Customize the AWS infrastructure](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/customize-the-infrastructure): point the module at a VPC, database, cache, or cluster you already run, split ingress, or use a custom n8n image.


# Scale and run at high availability on AWS

Configure multi-main, worker autoscaling, and Redis high availability in the terraform-aws-n8n module.

The [terraform-aws-n8n](https://github.com/n8n-io/terraform-aws-n8n) module deploys n8n in [queue mode](/deploy/host-n8n/configure-n8n/scaling/enable-queue-mode) by default, with a [multi-main setup](/deploy/host-n8n/configure-n8n/scaling/enable-queue-mode#multi-main-setup) for high availability. This page covers the module-specific settings for that topology: multi-main licensing, worker autoscaling, and Redis high availability.

## Multi-main setup

By default, the module runs more than one main pod and requires an Enterprise license. Set `n8n_main_hpa_min_replicas = 1` to run a single main pod instead, which only requires a Business plan license, since n8n's multi-main leader-election feature is disabled in that mode.

{% hint style="warning" %}
**Single-main mode has upgrade downtime**

With `n8n_main_hpa_min_replicas = 1`, the main pod's autoscaling maximum is forced to one, upgrades use a `Recreate` strategy, and the pod disruption budget permits evicting the only main. Expect editor, REST API, and scheduled-trigger downtime during upgrades and maintenance. Plan a maintenance window.
{% endhint %}

Any load balancer or Ingress in front of the main pods needs session persistence (sticky sessions) enabled so a browser stays connected to one main pod. The module's own Ingress sets this by default. If you bring your own Ingress, see [Customize the AWS infrastructure](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/customize-the-infrastructure#customer-managed-ingress).

## Worker autoscaling

Worker pods scale on Redis queue depth using [KEDA](https://keda.sh/), which the module installs automatically. To check whether a worker's autoscaler can reach Redis:

```bash
kubectl -n n8n get scaledobject
```

A healthy scaler reports `READY=True`. If it reports `READY=False`, check the KEDA operator logs for the reason:

```bash
kubectl -n keda logs -l app=keda-operator | grep -i 'connection to redis'
```

{% hint style="info" %}
**The worker HPA's TARGETS column can be misleading**

`kubectl get hpa` often shows `<unknown>` in the TARGETS column for KEDA-backed worker HPAs, even while autoscaling works correctly. Use `kubectl get scaledobject` instead to check scaler health.
{% endhint %}

If you enable [Redis in-transit encryption](#redis-in-transit-encryption-and-auth), KEDA's queue-depth triggers automatically use the same encrypted, authenticated connection as the workers.

## Redis high availability

By default, the module provisions Redis as a single-node `aws_elasticache_cluster`, which is a single point of failure for both the worker queue and multi-main leader election. Set `redis_high_availability_enabled = true` to provision a replication group (one primary and one replica) with automatic failover across two Availability Zones instead:

```hcl
module "n8n" {
  # ...
  redis_high_availability_enabled = true
  redis_node_type                 = "cache.r6g.large"
}
```

Both nodes use `redis_node_type`, so enabling high availability roughly doubles the Redis cost.

{% hint style="warning" %}
**High availability doesn't prevent pod restarts**

A Redis failover promotes the replica in about twenty seconds, but Redis replication is asynchronous, so recent queue writes may be lost if the replica hasn't received them. However, every main, worker, and webhook pod still restarts: n8n's Redis client exits the process once Redis is unreachable for longer than `QUEUE_BULL_REDIS_TIMEOUT_THRESHOLD` (ten seconds by default). This is a fail-fast design, not a crash loop. Kubernetes brings each pod back immediately, and recovery typically completes within a minute if Redis is available.
{% endhint %}

### Avoid restarts during a failover

Set `n8n_redis_timeout_threshold` to raise how long n8n waits for Redis before exiting. The useful budget is coarser than the number you set, because each failed connection attempt takes about 11.1 seconds (a 1-second retry interval plus a 10-second connection timeout):

| You set           | Real budget  | Reconnect attempts before exit |
| ----------------- | ------------ | ------------------------------ |
| `10000` (default) | 11.1 seconds | 1                              |
| `30000`           | 33.2 seconds | 3                              |
| `60000`           | 66.4 seconds | 6                              |

A stale Redis endpoint after a failover can take longer to resolve than the failover itself, due to DNS caching. Setting the threshold to `60000` clears this in practice, with pods logging `Recovered Redis connection` instead of restarting:

```hcl
module "n8n" {
  # ...
  redis_high_availability_enabled = true
  n8n_redis_timeout_threshold     = 60000
}
```

This is a trade-off, not a free win: the same threshold also decides how long a pod waits before restarting against a genuinely dead Redis. For a worker, that's usually an acceptable trade, since restarting doesn't help when Redis is unreachable either way.

### Switching topologies

Switching `redis_high_availability_enabled` on a live deployment destroys the existing cache and creates a new one. Everything queued or in progress at that moment is lost. Treat this as a maintenance-window operation: stop new work from reaching n8n, let the workers drain, and verify that `bull:jobs:wait`, `bull:jobs:active`, and `bull:jobs:delayed` are all empty in Redis before applying.

## Redis eviction policy

The module sets Redis's `maxmemory-policy` to `noeviction` (`redis_maxmemory_policy`), rather than ElastiCache's `volatile-lru` default. Under memory pressure, a `noeviction` Redis rejects new writes with an out-of-memory error instead of silently evicting queue keys, such as job locks. This makes a full Redis visible as failed writes and job-lock-renewal failures, rather than as queue data disappearing without explanation. Plan Redis memory for the queue and n8n's cache together, since both share the same instance.

## Redis in-transit encryption and AUTH

By default, Redis sits in private subnets behind a security group that only admits VPC traffic, with no TLS and no password. Set `redis_transit_encryption_enabled = true` to add both: the module enables TLS, generates an AUTH token, and wires it onto every n8n container.

```bash
terraform output -raw redis_auth_token
```

## Related resources

* [Deploy to AWS with Terraform](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform)
* [Deploy your first n8n instance on AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/deploy-your-first-instance)
* [Configure Enterprise features on AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/use-enterprise-features-on-aws)
* [Customize the AWS infrastructure](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/customize-the-infrastructure)
* [Maintain and tear down the AWS deployment](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/maintain-and-tear-down)
* [Enable queue mode](/deploy/host-n8n/configure-n8n/scaling/enable-queue-mode)


# Configure Enterprise features on AWS

Configure execution data in S3, Prometheus metrics, OpenTelemetry tracing, log streaming, and external secrets in the terraform-aws-n8n module.

The [terraform-aws-n8n](https://github.com/n8n-io/terraform-aws-n8n) module provides Terraform inputs that wire up several of n8n's Enterprise features for the AWS deployment. This page covers each feature's module-specific setup. For what each feature does and how to use it, see the linked n8n feature pages.

## Execution data in S3

{% hint style="info" %}
**Feature availability**

Storing execution data in S3 requires n8n 2.27.0 or later, and an Enterprise license with the `feat:executionDataS3` entitlement.
{% endhint %}

The module always stores n8n's binary data in S3. From n8n 2.27.0, you can offload execution data to the same bucket instead of PostgreSQL, which relieves database write pressure at scale:

```hcl
module "n8n" {
  # ...other inputs...

  n8n_execution_data_storage_mode = "s3" # default: "database"
  n8n_image_tag                   = "2.27.4"
}
```

Only new executions move to S3: there's no backfill, and switching the mode back doesn't affect data already written under either mode. See [Use external storage](/deploy/host-n8n/configure-n8n/scaling/use-external-storage) for how n8n uses external storage.

{% hint style="warning" %}
**S3 execution data has no automatic backup**

Unlike PostgreSQL, the module doesn't version or back up the S3 bucket. If execution history matters to you, add S3 versioning or a replication rule to the bucket (the `s3_bucket_name` output) yourself.
{% endhint %}

If you add a lifecycle rule, scope it to binary data objects only. n8n prunes execution data in S3 itself using its execution-pruning settings; don't add a lifecycle rule for it, because that can delete data n8n still references.

## Prometheus metrics

Set `n8n_metrics_enabled = true` to expose n8n's built-in Prometheus endpoint at `/metrics` on port `5678`, the same port the chart already uses for the UI and API. See [Enable Prometheus metrics](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/enable-prometheus-metrics) for what n8n exposes. The module doesn't configure scraping: add scrape annotations to the `n8n-main` Service, or create a `ServiceMonitor` if you run the Prometheus Operator.

n8n's own `/metrics` endpoint doesn't report a usable Bull queue depth in a multi-main topology. Set `redis_exporter_enabled = true` to deploy a [redis\_exporter](https://github.com/oliver006/redis_exporter) alongside the release, which exposes queue depth as `redis_key_size{key="<prefix>:jobs:wait"}` and `redis_key_size{key="<prefix>:jobs:active"}` on port `9121`. This is the same queue depth KEDA scales workers on.

## OpenTelemetry tracing

{% hint style="info" %}
**Preview status**

OpenTelemetry tracing in n8n may change and isn't recommended for production use.
{% endhint %}

Set `n8n_otel_enabled = true` to turn on n8n's workflow and node tracing on every n8n container. Point `n8n_otel_exporter_otlp_endpoint` at your OpenTelemetry collector's base URL (n8n appends `/v1/traces` itself):

```hcl
module "n8n" {
  # ...other inputs...

  n8n_otel_enabled                = true
  n8n_otel_exporter_otlp_endpoint = "http://otel-collector.observability.svc.cluster.local:4318"
}
```

The module doesn't deploy a collector. Deploy one separately, for example with the upstream `open-telemetry/opentelemetry-collector` Helm chart. See [Trace executions with OpenTelemetry](/deploy/host-n8n/keep-n8n-running/trace-executions-with-opentelemetry) for the available tuning variables and what n8n traces.

## Log streaming

{% hint style="info" %}
**Feature availability**

Log streaming requires n8n 2.19.0 or later, and an Enterprise license.
{% endhint %}

Set `n8n_log_streaming_managed_by_env = true` to configure [log streaming](/administer/observe-and-log/stream-logs-to-external-systems) destinations from Terraform instead of the UI:

```hcl
module "n8n" {
  # ...other inputs...

  n8n_log_streaming_managed_by_env = true
  n8n_log_streaming_destinations = [
    {
      type             = "webhook"
      label            = "Audit events"
      enabled          = true
      subscribedEvents = ["n8n.audit", "n8n.workflow"]
      url              = "https://hooks.example.com/n8n"
      method           = "POST"
    },
  ]
}
```

n8n reapplies these destinations on every startup, and the Log Streaming settings in the UI become read-only. Setting `n8n_log_streaming_managed_by_env` back to `false` keeps the last applied destinations but restores UI access.

## External secrets

n8n's [External Secrets](/administer/manage-credentials/use-external-secret-stores) feature resolves workflow credential values from an external vault at runtime. It requires an Enterprise license with the `feat:externalSecrets` entitlement, and is on by default (`n8n_external_secrets_enabled = true`); set it to `false` to disable it even on a license that includes it.

Connecting a vault provider is a manual step in the n8n UI (**Settings** > **External Secrets**) in every case. Terraform can't create that connection. What the module can do is grant the n8n pod's Pod Identity role read access to specific AWS Secrets Manager secrets, so you can choose automatic credential detection in the UI instead of pasting static IAM user keys:

```hcl
module "n8n" {
  # ...other inputs...

  n8n_external_secrets_aws_enabled      = true
  n8n_external_secrets_aws_secret_names = ["prod/n8n/stripe", "prod/n8n/hubspot"]
}
```

`n8n_external_secrets_aws_secret_names` is required and doesn't accept a wildcard: list every secret name explicitly, since n8n's AWS Secrets Manager integration otherwise has no other way to restrict which secrets it can read.

## Credential overwrites

[Credential overwrites](/administer/manage-credentials/credential-overwrites) let you preconfigure shared credential fields and hide them from users. Supply the JSON payload through a Kubernetes Secret you manage yourself, and reference it with `n8n_credentials_overwrite_secret_ref`:

```hcl
module "n8n" {
  # ...other inputs...

  n8n_credentials_overwrite_secret_ref = {
    name = kubernetes_secret_v1.credentials_overwrite.metadata[0].name
  }
}
```

n8n reads this file once, at startup. After rotating the Secret's contents, restart the main, worker, and webhook processor deployments to pick up the change.

## Related resources

* [Deploy to AWS with Terraform](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform)
* [Deploy your first n8n instance on AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/deploy-your-first-instance)
* [Scale and run at high availability on AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/scale-and-run-at-high-availability)
* [Customize the AWS infrastructure](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/customize-the-infrastructure)
* [Maintain and tear down the AWS deployment](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/maintain-and-tear-down)
* [Use external storage](/deploy/host-n8n/configure-n8n/scaling/use-external-storage)


# Customize the AWS infrastructure

Bring your own VPC, database, cache, or cluster, split ingress, or use a custom n8n image with the terraform-aws-n8n module.

The [terraform-aws-n8n](https://github.com/n8n-io/terraform-aws-n8n) module can provision every layer of the deployment, or point at infrastructure you already run. This page covers the main customization points: pointing the module at existing infrastructure, splitting ingress traffic, and using a custom n8n image.

## Customer-managed infrastructure

Every layer the module can provision can instead point at infrastructure you already run. Each layer follows the same pattern: a `create_<x>` boolean (default `true`) that stops the module provisioning that layer, plus one or more reference inputs required only when it's `false`.

| Layer                                                                                    | Toggle                                                                                   | Reference inputs                                                                                                      |
| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| RDS PostgreSQL                                                                           | `create_database`                                                                        | `db_host`, `db_password` (or `db_password_secret_ref`)                                                                |
| EKS cluster and node group                                                               | `create_eks`                                                                             | `existing_eks_cluster_name`, `existing_eks_cluster_prerequisites_confirmed`                                           |
| ElastiCache Redis                                                                        | `create_elasticache`                                                                     | `redis_host`, `redis_port`, `redis_auth_token` (or `redis_auth_token_secret_ref`), `redis_transit_encryption_enabled` |
| S3 bucket                                                                                | `create_s3_bucket`                                                                       | `existing_s3_bucket_name`                                                                                             |
| RDS KMS key                                                                              | `create_db_kms_key`                                                                      | `db_kms_key_arn`                                                                                                      |
| S3 KMS key                                                                               | `create_s3_kms_key`                                                                      | `s3_kms_key_arn`                                                                                                      |
| Cluster controllers (load balancer controller, Cluster Autoscaler, metrics-server, KEDA) | `install_lbc` / `install_cluster_autoscaler` / `install_metrics_server` / `install_keda` | none; assumes equivalents already run on the existing cluster                                                         |

For example, to point the module at a Redis instance you already manage:

```hcl
module "n8n" {
  # ...
  create_elasticache = false
  redis_host         = aws_elasticache_replication_group.shared.primary_endpoint_address
  redis_port         = 6379
  redis_auth_token   = var.shared_redis_auth_token
}
```

{% hint style="warning" %}
**Keep the toggle and its reference inputs in sync**

Setting a reference input such as `redis_host` without also setting its `create_<x>` boolean to `false` doesn't fail: the module still provisions its own managed resource and points n8n at that instead, while the infrastructure you supplied sits unused. Always set both together.
{% endhint %}

If you're pointing two n8n deployments at the same Redis host, set a unique `redis_key_prefix` for each. Without it, both deployments share the same queue and leader-election channels, and activating a workflow on one instance can produce `webhook not registered` errors on the other.

Runnable reference configurations for each customer-managed layer are available in the module's [examples](https://github.com/n8n-io/terraform-aws-n8n/tree/main/examples) folder (`customer-managed-redis`, `customer-managed-s3`, `customer-managed-cluster`, and `customer-managed-everything`).

{% hint style="info" %}
**VPC creation is always out of scope**

The module always requires a pre-existing VPC (`vpc_id`, `private_subnets`, `public_subnets`). It never creates one.
{% endhint %}

## Customer-managed ingress

By default, the module creates a single internet-facing Application Load Balancer that routes `/webhook` to the webhook processors and `/` to the main pods. Set `create_ingress = false` to manage your own ingress instead, for example to split public webhook traffic from an internal-only editor and API.

Route traffic to the Services the module exposes as outputs:

| Output                      | Serves                                                   |
| --------------------------- | -------------------------------------------------------- |
| `n8n_service_name`          | Editor UI, REST API                                      |
| `n8n_webhook_service_name`  | Webhooks, forms, waiting resumptions, MCP                |
| `n8n_webhook_path_prefixes` | The path prefixes that must reach the webhook processors |
| `n8n_service_port`          | Both (`5678`)                                            |

Route every prefix in `n8n_webhook_path_prefixes` to the webhook processors, not just `/webhook`: the module disables production webhook handling on the main pods, so `/webhook-waiting` (wait-node resumption), `/form` and `/form-waiting` (Form Trigger nodes), and `/mcp` (MCP server triggers) all return 404 if they reach the main pods instead. Declare these prefixes before any catch-all `/` rule.

A caller-managed ingress also needs to:

* **Enable session stickiness** to `n8n_service_name`, so each browser stays on one main pod. Without it, editor requests and WebSocket connections from one browser spread across main pods and the editor loses its connection.
* **Set `n8n_proxy_hops`** to the number of proxies between the client and n8n that add an `X-Forwarded-For` header. The module sets this to `1` by default, which is correct if the module or your own load balancer is the only proxy. Add one for each additional HTTP proxy in the path, such as CloudFront.

A complete, runnable example of a split ingress, including the certificate and both DNS records, is in [`examples/split-ingress`](https://github.com/n8n-io/terraform-aws-n8n/tree/main/examples/split-ingress).

## Custom n8n images

Set `n8n_image_repository` to point the Helm release at an image you build instead of the default n8n image. Common reasons include an internal base image or community nodes baked into the image:

```hcl
module "n8n" {
  # ...other inputs...

  n8n_image_repository = "123456789012.dkr.ecr.eu-west-1.amazonaws.com/n8n"
  n8n_image_tag        = "2.27.4-mypackages"

  # Pin to the n8n version the custom image is built from.
  n8n_task_runner_image_tag = "2.27.4"

  # Not needed when packages are already in the image.
  n8n_reinstall_missing_packages = false
}
```

{% hint style="warning" %}
**Community packages installed through the UI don't load from a custom image**

n8n only loads community nodes from a directory set by `N8N_CUSTOM_EXTENSIONS`, not from a plain `npm install` into the image's `node_modules`. Set `n8n_custom_extensions_path` to the directory your image populates with the packages, and install the packages there in your Dockerfile. Nodes loaded this way are also renamed to a `CUSTOM.*` type, so existing workflows built on a UI-installed copy of the same package won't resolve without updating their node types.
{% endhint %}

If rebuilding an image for every package change isn't practical, `n8n_extra_volumes` and `n8n_extra_volume_mounts` mount the same directory from a ConfigMap, Secret, or persistent volume claim instead of baking it into the image.

## Pod DNS at scale

`n8n_dns_config` sets the DNS options on the n8n pods. At a large pod count, Kubernetes' default DNS search-path behavior (`ndots:5`) sends every in-cluster or AWS-service hostname lookup, such as to S3 or ElastiCache, through up to four unnecessary search-domain queries before trying the name as written. Set `n8n_dns_config` to `ndots:1` if your deployment addresses every dependency by fully qualified domain name, which it does by default in this module:

```hcl
n8n_dns_config = {
  options = [{ name = "ndots", value = "1" }]
}
```

This reduces DNS query volume substantially at scale and removes failed requests caused by CoreDNS saturation, without making individual requests faster.

## Related resources

* [Deploy to AWS with Terraform](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform)
* [Deploy your first n8n instance on AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/deploy-your-first-instance)
* [Scale and run at high availability on AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/scale-and-run-at-high-availability)
* [Configure Enterprise features on AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/use-enterprise-features-on-aws)
* [Maintain and tear down the AWS deployment](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/maintain-and-tear-down)


# Maintain and tear down the AWS deployment

Manage encryption keys, verify database TLS, and configure deletion protection in the terraform-aws-n8n module.

The [terraform-aws-n8n](https://github.com/n8n-io/terraform-aws-n8n) module manages encryption keys and database protection settings that matter most when you upgrade, recover from an incident, or decommission a deployment. This page covers those settings. For step-by-step upgrade and destroy troubleshooting, see the module's [upgrade guide](https://github.com/n8n-io/terraform-aws-n8n/blob/main/docs/upgrading-n8n.md) and [destroy checklist](https://github.com/n8n-io/terraform-aws-n8n/blob/main/docs/destroy-cleanup.md) on GitHub.

## Bring your own KMS key

By default, the module creates and manages its own KMS key to encrypt the RDS instance and the S3 bucket. To encrypt with a key you already own instead, for example one a central security team controls:

```hcl
create_db_kms_key = false
db_kms_key_arn    = "arn:aws:kms:eu-west-1:123456789012:key/1a2b3c4d-..."

create_s3_kms_key = false
s3_kms_key_arn    = "arn:aws:kms:eu-west-1:123456789012:key/1a2b3c4d-..."
```

Set both the boolean and the ARN together: the boolean alone stops the module creating its own key, and the ARN alone is ignored.

{% hint style="info" %}
**The CloudWatch Logs group needs its own key policy statement**

RDS can use your key through a grant, but CloudWatch Logs rejects a key that doesn't explicitly name the regional Logs service principal in its key policy. Without that statement, the module's `postgresql` log group falls back to CloudWatch's own managed key instead of yours. Add a statement granting `kms:Encrypt`, `kms:Decrypt`, `kms:ReEncrypt*`, `kms:GenerateDataKey*`, and `kms:DescribeKey` to the `logs.<region>.amazonaws.com` principal, then set `db_logs_kms_key_enabled = true` and `db_logs_kms_key_arn` to the same key.
{% endhint %}

## Verify the PostgreSQL TLS certificate

By default, the connection between n8n and the module's RDS instance is encrypted but unverified (`DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED=false`), because the RDS server certificate chains to Amazon's own certificate authority, which Node.js doesn't trust by default. To verify the server identity as well as encrypt the connection:

```hcl
db_postgresdb_ssl_reject_unauthorized = true
db_postgresdb_ssl_ca_pem              = file("${path.module}/global-bundle.pem")
```

Download the combined CA bundle from AWS's trust store at `https://truststore.pki.rds.amazonaws.com`. The module mounts it read-only on every n8n pod and points `DB_POSTGRESDB_SSL_CA_FILE` at it.

## KMS keys after terraform destroy

The module schedules its managed KMS keys for deletion seven days after a `terraform destroy`, rather than deleting them immediately. A key becomes unusable as soon as deletion is scheduled, even though permanent loss only occurs once the seven-day window completes. To reuse a key after a completed destroy, cancel its deletion, enable it, and import it back into Terraform state before re-applying:

```bash
aws kms cancel-key-deletion --key-id <key-id>
aws kms enable-key --key-id <key-id>
```

{% hint style="warning" %}
**A pending-deletion key blocks recovery, even with a retained snapshot or S3 objects**

RDS snapshots and S3 objects encrypted with the module's own KMS keys can't be decrypted once the key enters `PendingDeletion`. If you need encrypted backups to outlive a `terraform destroy`, manage a retained KMS key outside the module. For existing deployments, copy RDS snapshots with that key and re-encrypt or copy S3 objects before destroying; changing the configured key doesn't re-encrypt existing data.
{% endhint %}

## Deletion protection and teardown

The module defaults to teardown-friendly settings, so example deployments can be destroyed cleanly:

| Setting                       | Default | Production value                                  |
| ----------------------------- | ------- | ------------------------------------------------- |
| `db_deletion_protection`      | `false` | `true`                                            |
| `db_skip_final_snapshot`      | `true`  | `false` (also set `db_final_snapshot_identifier`) |
| `db_delete_automated_backups` | `true`  | `false`                                           |
| `s3_force_destroy`            | `true`  | `false`                                           |

All four are in-place changes on an existing deployment and don't force replacement. Apply these settings before running `terraform destroy`. Terraform uses the values in state, not un-applied configuration. Editing a `.tfvars` file and immediately running destroy therefore still uses the old values.

## Related resources

* [Deploy to AWS with Terraform](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform)
* [Deploy your first n8n instance on AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/deploy-your-first-instance)
* [Scale and run at high availability on AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/scale-and-run-at-high-availability)
* [Configure Enterprise features on AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/use-enterprise-features-on-aws)
* [Customize the AWS infrastructure](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/customize-the-infrastructure)


# Deploy to Azure

This hosting guide shows you how to self-host n8n on Azure. It uses n8n with Postgres as a database backend using Kubernetes to manage the necessary resources and reverse proxy.

## Prerequisites <a href="#prerequisites" id="prerequisites"></a>

You need [The Azure command line tool](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli)

{% hint style="info" %}
**Self-hosting knowledge prerequisites**

Self-hosting n8n requires technical knowledge, including:

* Setting up and configuring servers and containers
* Managing application resources and scaling
* Securing servers and applications
* Configuring n8n

n8n recommends self-hosting for expert users. Mistakes can lead to data loss, security issues, and downtime. If you aren't experienced at managing servers, n8n recommends [n8n Cloud](https://n8n.io/cloud/).
{% endhint %}

{% hint style="info" %}
**Stable and Beta versions**

n8n releases a new minor version most weeks. The `stable` version is for production use. `beta` is the most recent release. The `beta` version may be unstable. To report issues, use the [forum](https://community.n8n.io/c/questions/12).

Current `stable`: 2.47.7 Current `beta`: 2.48.4
{% endhint %}

## Hosting options <a href="#hosting-options" id="hosting-options"></a>

Azure offers several ways suitable for hosting n8n, including Azure Container Instances (optimized for running containers), Linux Virtual Machines, and Azure Kubernetes Service (containers running with Kubernetes).

This guide uses the Azure Kubernetes Service (AKS) as the hosting option. Using Kubernetes requires some additional complexity and configuration, but is the best method for scaling n8n as demand changes.

The steps in this guide use a mix of the Azure UI and command line tool, but you can use either to accomplish most tasks.

## Open the Azure Kubernetes Service <a href="#open-the-azure-kubernetes-service" id="open-the-azure-kubernetes-service"></a>

From [the Azure portal](https://portal.azure.com/) select **Kubernetes services**.

## Create a cluster <a href="#create-a-cluster" id="create-a-cluster"></a>

From the Kubernetes services page, select **Create** > **Create a Kubernetes cluster**.

You can select any of the configuration options that suit your needs, then select **Create** when done.

## Set Kubectl context <a href="#set-kubectl-context" id="set-kubectl-context"></a>

The remainder of the steps in this guide require you to set the Azure instance as the Kubectl context. You can find the connection details for a cluster instance by opening its details page and then the **Connect** button. The resulting code snippets shows the steps to paste and run into a terminal to change your local Kubernetes settings to use the new cluster.

## Clone configuration repository <a href="#clone-configuration-repository" id="clone-configuration-repository"></a>

Kubernetes and n8n require a series of configuration files. You can clone these from [this repository](https://github.com/n8n-io/n8n-hosting). The following steps tell you which file configures what and what you need to change.

Clone the repository with the following command:

```shell
git clone https://github.com/n8n-io/n8n-hosting.git
```

And change directory:

```shell
cd n8n-hosting/kubernetes
```

## Configure Postgres <a href="#configure-postgres" id="configure-postgres"></a>

For larger scale n8n deployments, Postgres provides a more robust database backend than SQLite.

### Configure volume for persistent storage <a href="#configure-volume-for-persistent-storage" id="configure-volume-for-persistent-storage"></a>

To maintain data between pod restarts, the Postgres deployment needs a persistent volume. The default storage class is suitable for this purpose and is defined in the `postgres-claim0-persistentvolumeclaim.yaml` manifest.

{% hint style="info" %}
**Specialized storage classes**

If you have specialised or higher requirements for storage classes, [read more on the options Azure offers in the documentation](https://learn.microsoft.com/en-us/azure/aks/concepts-storage#storage-classes).
{% endhint %}

### Postgres environment variables <a href="#postgres-environment-variables" id="postgres-environment-variables"></a>

Postgres needs some environment variables set to pass to the application running in the containers.

The example `postgres-secret.yaml` file contains placeholders you need to replace with your own values. Postgres will use these details when creating the database..

The `postgres-deployment.yaml` manifest then uses the values from this manifest file to send to the application pods.

## Configure n8n <a href="#configure-n8n" id="configure-n8n"></a>

### Create a volume for file storage <a href="#create-a-volume-for-file-storage" id="create-a-volume-for-file-storage"></a>

While not essential for running n8n, using persistent volumes is required for:

* Using nodes that interact with files, such as the binary data node.
* If you want to persist [manual n8n encryption keys](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/deployment) between restarts. This saves a file containing the key into file storage during startup.

The `n8n-claim0-persistentvolumeclaim.yaml` manifest creates this, and the n8n Deployment mounts that claim in the `volumes` section of the `n8n-deployment.yaml` manifest.

```yaml
…
volumes:
  - name: n8n-claim0
    persistentVolumeClaim:
      claimName: n8n-claim0
…
```

### Pod resources <a href="#pod-resources" id="pod-resources"></a>

[Kubernetes lets you](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) optionally specify the minimum resources application containers need and the limits they can run to. The example YAML files cloned above contain the following in the `resources` section of the `n8n-deployment.yaml` file:

```yaml
…
resources:
  requests:
    memory: "250Mi"
  limits:
    memory: "500Mi"
…    
```

This defines a minimum of 250mb per container, a maximum of 500mb, and lets Kubernetes handle CPU. You can change these values to match your own needs. As a guide, here are the resources values for the n8n cloud offerings:

| Tier                 | RAM    | CPU                    |
| -------------------- | ------ | ---------------------- |
| Starter              | 320mb  | 10 millicore burstable |
| Pro (10k executions) | 640mb  | 20 millicore burstable |
| Pro (50k executions) | 1280mb | 80 millicore burstable |

### Optional: Environment variables <a href="#optional-environment-variables" id="optional-environment-variables"></a>

You can configure n8n settings and behaviors using environment variables.

Create an `n8n-secret.yaml` file. Refer to [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables) for n8n environment variables details.

## Deployments <a href="#deployments" id="deployments"></a>

The two deployment manifests (`n8n-deployment.yaml` and `postgres-deployment.yaml`) define the n8n and Postgres applications to Kubernetes.

{% hint style="warning" %}
The manifests run PostgreSQL 18. Setting up for the first time needs nothing extra.

If you already have a database running an older PostgreSQL major version, don't apply this to it. PostgreSQL 18 can't open a data directory written by an older major version, and moving the folder doesn't help. The pod stays in `CrashLoopBackOff` with `database files are incompatible with server`. PostgreSQL leaves your data alone, and you can pin the image back to the version you were on.

To move an existing database across, follow the official [PostgreSQL upgrade guide](https://www.postgresql.org/docs/18/upgrading.html) first.
{% endhint %}

The manifests define the following:

* Send the environment variables defined to each application pod
* Define the container image to use
* Set resource consumption limits with the `resources` object
* The `volumes` defined earlier and `volumeMounts` to define the path in the container to mount volumes.
* Scaling and restart policies. The example manifests define one instance of each pod. You should change this to meet your needs.

## Services <a href="#services" id="services"></a>

The two service manifests (`postgres-service.yaml` and `n8n-service.yaml`) expose the services to the outside world using the Kubernetes load balancer using ports 5432 and 5678 respectively.

## Send to Kubernetes cluster <a href="#send-to-kubernetes-cluster" id="send-to-kubernetes-cluster"></a>

Send all the manifests to the cluster with the following command:

```shell
kubectl apply -f .
```

{% hint style="info" %}
**Namespace error**

You may see an error message about not finding an "n8n" namespace as that resources isn't ready yet. You can run the same command again, or apply the namespace manifest first with the following command:

```shell
kubectl apply -f namespace.yaml
```

{% endhint %}

## Set up DNS <a href="#set-up-dns" id="set-up-dns"></a>

n8n typically operates on a subdomain. Create a DNS record with your provider for the subdomain and point it to the IP address of the n8n service. Find the IP address of the n8n service from the **Services & ingresses** menu item of the cluster you want to use under the **External IP** column. You need to add the n8n port, "5678" to the URL.

{% hint style="info" %}
**Static IP addresses with AKS**

[Read this tutorial](https://learn.microsoft.com/en-us/azure/aks/static-ip) for more details on how to use a static IP address with AKS.
{% endhint %}

## Delete resources <a href="#delete-resources" id="delete-resources"></a>

Remove the resources created by the manifests with the following command:

```shell
kubectl delete -f .
```

## Next steps <a href="#next-steps" id="next-steps"></a>

* Learn more about [configuring](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables) and [scaling](/deploy/host-n8n/configure-n8n/scaling) n8n.
* Or explore using n8n: try the [Quickstarts](/build-your-first-workflow).

## Related resources

* [Use a cloud provider](/deploy/host-n8n/install-options/use-a-cloud-provider)
* [DigitalOcean](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-digital-ocean)
* [Heroku](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-heroku)
* [Hetzner Cloud](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-hetzner)
* [AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws)
* [Google Cloud Run](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-cloud-run)
* [Google Kubernetes Engine](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-kubernetes)
* [OpenShift Local (CRC)](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-openshift-local-crc)
* [Use Docker Compose](/deploy/host-n8n/install-options/use-a-cloud-provider/use-docker-compose)


# Deploy to Google Cloud Run

This hosting guide shows you how to self-host n8n on Google Cloud Run, a serverless container runtime. If you're just getting started with n8n and don't need a production-grade deployment, you can go with the "easy mode" option below for deployment. Otherwise, if you intend to use this n8n deployment at-scale, refer to the "durable mode" instructions further down.

You can also enable access via OAuth to Google Workspace, such as Gmail and Drive, to use these services as n8n workflow tools. Instructions for granting n8n access to these services are at the end of this documentation.

If you want to deploy to Google Kubernetes Engine (GKE) instead, you can refer to [these instructions](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-kubernetes).

{% hint style="info" %}
**Self-hosting knowledge prerequisites**

Self-hosting n8n requires technical knowledge, including:

* Setting up and configuring servers and containers
* Managing application resources and scaling
* Securing servers and applications
* Configuring n8n

n8n recommends self-hosting for expert users. Mistakes can lead to data loss, security issues, and downtime. If you aren't experienced at managing servers, n8n recommends [n8n Cloud](https://n8n.io/cloud/).
{% endhint %}

{% hint style="info" %}
**Stable and Beta versions**

n8n releases a new minor version most weeks. The `stable` version is for production use. `beta` is the most recent release. The `beta` version may be unstable. To report issues, use the [forum](https://community.n8n.io/c/questions/12).

Current `stable`: 2.47.7 Current `beta`: 2.48.4
{% endhint %}

## Before you begin: get a Google Cloud project <a href="#before-you-begin-get-a-google-cloud-project" id="before-you-begin-get-a-google-cloud-project"></a>

If you have not yet created a Google Cloud project, [do this first](https://developers.google.com/workspace/guides/create-project) (and ensure you have billing enabled on the project; even if your Cloud Run service runs for free you must have billing activated to deploy). Otherwise, navigate to the project where you want to deploy n8n.

## Easy mode <a href="#easy-mode" id="easy-mode"></a>

This is the fastest way to deploy n8n on Cloud Run. For this deployment, n8n's data is in-memory so this is only recommended for demo purposes. **Anytime this Cloud Run service scales to zero or is redeployed, the n8n data will be lost.** Refer to the durable mode instructions below if you need a production-grade deployment.

If you have not yet created a Google Cloud project, [do this first](https://developers.google.com/workspace/guides/create-project) (and ensure you have billing enabled on the project; even if your Cloud Run service will run for free you must have billing enabled to activated to deploy). Otherwise, navigate to the project where you want to deploy n8n.

Open the Cloud Shell Terminal (on the Google Cloud console, either type "G" then "S" or click on the terminal icon on the upper right).

Once your session is open, you may need to run this command first to login (and follow the steps it asks you to complete):

```sh
gcloud auth login
```

You can also explicitly enable the Cloud Run API (even if you don't do this, it will ask if you want this enabled when you deploy):

```sh
gcloud services enable run.googleapis.com
```

{% hint style="warning" %}
**Required: Custom health check endpoint**

Google Cloud Run reserves `/healthz` for its own health checks. Since n8n uses this path by default, it can conflict and cause connection issues in the workflow canvas. To fix this, set the `N8N_ENDPOINT_HEALTH` environment variable to a custom path (included in the deployment commands below).
{% endhint %}

To deploy n8n:

```sh
gcloud run deploy n8n \
    --image=n8nio/n8n \
    --region=us-west1 \
    --allow-unauthenticated \
    --port=5678 \
    --no-cpu-throttling \
    --memory=2Gi \
    --set-env-vars="N8N_ENDPOINT_HEALTH=health"
```

(you can specify whichever region you prefer, instead of "us-west1")

Once the deployment finishes, open another tab to navigate to the Service URL. n8n may still be loading and you will see a "n8n is starting up. Please wait" message, but shortly thereafter you should see the n8n login screen.

Optional: If you want to keep this n8n service running for as long as possible to avoid data loss, you can also set manual scale to 1 to prevent it from autoscaling to 0.

```sh
gcloud run deploy n8n \
    --image=n8nio/n8n \
    --region=us-west1 \
    --allow-unauthenticated \
    --port=5678 \
    --no-cpu-throttling \
    --memory=2Gi \
    --scaling=1 \
    --set-env-vars="N8N_ENDPOINT_HEALTH=health"
```

This does not prevent data loss completely, such as whenever the Cloud Run service is re-deployed/updated. If you want truly persistent data, you should refer to the instructions below for how to attach a database.

## Durable mode <a href="#durable-mode" id="durable-mode"></a>

The following instructions are intended for a more durable, production-grade deployment of n8n on Cloud Run. It includes resources such as a database for persistance and secret manager for sensitive data.

If you want to deploy the following setup via Terraform, refer to this [example](https://github.com/ryanpei/n8n-hosting/tree/main/google-cloud-run) which deploys the same setup as the following (without the OAuth setup for Google Workspace tools).

## Enable APIs and set env vars <a href="#enable-apis-and-set-env-vars" id="enable-apis-and-set-env-vars"></a>

Open the Cloud Shell Terminal (on the Google Cloud console, either type "G" then "S" or click on the terminal icon on the upper right) and run these commands in the terminal session:

```sh
## You may need to login first <a href="#you-may-need-to-login-first" id="you-may-need-to-login-first"></a>
gcloud auth login

gcloud services enable run.googleapis.com
gcloud services enable sqladmin.googleapis.com
gcloud services enable secretmanager.googleapis.com
```

You'll also want to set some environment variables for the remainder of these instructions:

```sh
export PROJECT_ID=your-project
export REGION=region-where-you-want-this-deployed
```

## Setup your Postgres database <a href="#setup-your-postgres-database" id="setup-your-postgres-database"></a>

Run this command to create the Postgres DB instance (it will take a few minutes to complete; also ensure you update the root-password field with your own desired password):

```sh
gcloud sql instances create n8n-db \
    --database-version=POSTGRES_17 \
    --tier=db-f1-micro \
    --region=$REGION \
    --root-password="change-this-password" \
    --storage-size=10GB \
    --availability-type=ZONAL \
    --no-backup \
    --storage-type=HDD
```

Once complete, you can add the database that n8n will use:

```sh
gcloud sql databases create n8n --instance=n8n-db
```

Create the DB user for n8n (change the password value, of course):

```sh
gcloud sql users create n8n-user \
    --instance=n8n-db \
    --password="change-this-password"
```

You can save the password you set for this n8n-user to a file for the next step of saving the password in Secret Manager. Be sure to delete this file later.

## Store sensitive data in Secret Manager <a href="#store-sensitive-data-in-secret-manager" id="store-sensitive-data-in-secret-manager"></a>

While not required, it's absolutely recommended to store your sensitive data in Secrets Manager.

Create a secret for the database password (replace "/your/password/file" with the file you created above for the n8n-user password):

```sh
gcloud secrets create n8n-db-password \
    --data-file=/your/password/file \
    --replication-policy="automatic"
```

Create an encryption key (you can use your own, this example generates a random one):

```sh
openssl rand -base64 -out my-encryption-key 42
```

Create a secret for this encryption key (replace "my-encryption-key" if you are supplying your own):

```sh
gcloud secrets create n8n-encryption-key \
    --data-file=my-encryption-key \
    --replication-policy="automatic"
```

Now you can delete my-encryption-key and the database password files you created. These values are now securely stored in Secret Manager.

## Create a service account for Cloud Run <a href="#create-a-service-account-for-cloud-run" id="create-a-service-account-for-cloud-run"></a>

You want this Cloud Run service to be restricted to access only the resources it needs. The following commands create the service account and adds the permissions necessary to access secrets and the database:

```sh
gcloud iam service-accounts create n8n-service-account \
    --display-name="n8n Service Account"

gcloud secrets add-iam-policy-binding n8n-db-password \
    --member="serviceAccount:n8n-service-account@$PROJECT_ID.iam.gserviceaccount.com" \
    --role="roles/secretmanager.secretAccessor"

gcloud secrets add-iam-policy-binding n8n-encryption-key \
    --member="serviceAccount:n8n-service-account@$PROJECT_ID.iam.gserviceaccount.com" \
    --role="roles/secretmanager.secretAccessor"

gcloud projects add-iam-policy-binding $PROJECT_ID \
    --member="serviceAccount:n8n-service-account@$PROJECT_ID.iam.gserviceaccount.com" \
    --role="roles/cloudsql.client"
```

## Deploy the Cloud Run service <a href="#deploy-the-cloud-run-service" id="deploy-the-cloud-run-service"></a>

Now you can deploy your n8n service:

```sh
gcloud run deploy n8n \
    --image=n8nio/n8n:latest \
    --command="/bin/sh" \
    --args="-c,sleep 5;n8n start" \
    --region=$REGION \
    --allow-unauthenticated \
    --port=5678 \
    --memory=2Gi \
    --no-cpu-throttling \
    --set-env-vars="N8N_PORT=5678,N8N_PROTOCOL=https,N8N_ENDPOINT_HEALTH=health,DB_TYPE=postgresdb,DB_POSTGRESDB_DATABASE=n8n,DB_POSTGRESDB_USER=n8n-user,DB_POSTGRESDB_HOST=/cloudsql/$PROJECT_ID:$REGION:n8n-db,DB_POSTGRESDB_PORT=5432,DB_POSTGRESDB_SCHEMA=public,GENERIC_TIMEZONE=UTC,QUEUE_HEALTH_CHECK_ACTIVE=true" \
    --set-secrets="DB_POSTGRESDB_PASSWORD=n8n-db-password:latest,N8N_ENCRYPTION_KEY=n8n-encryption-key:latest" \
    --add-cloudsql-instances=$PROJECT_ID:$REGION:n8n-db \
    --service-account=n8n-service-account@$PROJECT_ID.iam.gserviceaccount.com
```

Once the deployment finishes, open another tab to navigate to the Service URL. You should see the n8n login screen.

## Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

If you see a "Cannot GET /" screen this usually indicates that n8n is still starting up. You can refresh the page and it should eventually load.

## (Optional) Enabling Google Workspace services as n8n tools <a href="#optional-enabling-google-workspace-services-as-n8n-tools" id="optional-enabling-google-workspace-services-as-n8n-tools"></a>

If you want to use Google Workspace services (Gmail, Calendar, Drive, etc.) as tools in n8n, it's recommended to setup OAuth to access these services.

First ensure the respective APIs you want are enabled:

```sh
## Enable whichever APIs you need <a href="#enable-whichever-apis-you-need" id="enable-whichever-apis-you-need"></a>
## Note: If you want Sheets/Docs, it's not enough to just enable Drive; these services each have their own API <a href="#note-if-you-want-sheetsdocs-its-not-enough-to-just-enable-drive-these-services-each-have-their-own-api" id="note-if-you-want-sheetsdocs-its-not-enough-to-just-enable-drive-these-services-each-have-their-own-api"></a>
gcloud services enable gmail.googleapis.com
gcloud services enable drive.googleapis.com
gcloud services enable sheets.googleapis.com
gcloud services enable docs.googleapis.com
gcloud services enable calendar-json.googleapis.com
```

Re-deploy n8n on Cloud Run with the necessary OAuth callback URLs as environment variables:

```sh
export SERVICE_URL="your-n8n-service-URL"
## e.g. https://n8n-12345678.us-west1.run.app <a href="#eg-httpsn8n-12345678us-west1runapp" id="eg-httpsn8n-12345678us-west1runapp"></a>

gcloud run services update n8n \
    --region=$REGION \
    --update-env-vars="N8N_HOST=$(echo $SERVICE_URL | sed 's/https:\/\///'),N8N_WEBHOOK_URL=$SERVICE_URL,N8N_EDITOR_BASE_URL=$SERVICE_URL"
```

`N8N_WEBHOOK_URL` is available from n8n 2.30.0; on earlier versions, use `WEBHOOK_URL`.

Lastly, you must setup OAuth for these services. Visit `https://console.cloud.google.com/auth` and follow these steps:

1. Click "Get Started" if this button shows (when you have not yet setup OAuth in this Cloud project).
2. For "App Information", enter whichever "App Name" and "User Support Email" you prefer.
3. For "Audience", select "Internal" if you intend to only enable access to your user(s) within this same Google Workspace. Otherwise, you can select "External".
4. Enter "Contact Information".
5. If you selected "External", then click "Audience" and add any test users you need to grant access.
6. Click "Clients" > "Create client", select "Web application" for "Application type", enter your n8n service URL into "Authorized JavaScript origins", and "/rest/oauth2-credential/callback" into "Authorized redirect URIs" where your YOUR-N8N-URL is also the n8n service URL (e.g. `https://n8n-12345678.us-west1.run.app/rest/oauth2-credential/callback`). Make sure you download the created client's JSON file since it contains the client secret which you will not be able to see later in the Console.
7. Click "Data Access" and add the scopes you want n8n to have access for (e.g. to access Google Sheets, you need `https://googleapis.com/auth/drive.file` and `https://googleapis.com/auth/spreadsheets`)
8. Now you should be able to use these workspace services. You can test if it works by logging into n8n, add a Tool for the respective service and add its credentials using the information in the OAuth client JSON file from step 6.

## Related resources

* [Use a cloud provider](/deploy/host-n8n/install-options/use-a-cloud-provider)
* [DigitalOcean](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-digital-ocean)
* [Heroku](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-heroku)
* [Hetzner Cloud](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-hetzner)
* [AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws)
* [Azure](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-azure)
* [Google Kubernetes Engine](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-kubernetes)
* [OpenShift Local (CRC)](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-openshift-local-crc)
* [Use Docker Compose](/deploy/host-n8n/install-options/use-a-cloud-provider/use-docker-compose)


# Deploy to Google Kubernetes

Google Cloud offers several options suitable for hosting n8n, including Cloud Run (optimized for running containers), Compute Engine (VMs), and Kubernetes Engine (containers running with Kubernetes).

This guide uses the Google Kubernetes Engine (GKE) as the hosting option. If you want to use Cloud Run, refer to [these instructions](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-cloud-run).

Most of the steps in this guide use the Google Cloud UI, but you can also use the [gcloud command line tool](https://cloud.google.com/sdk/gcloud/) instead to undertake all the steps.

## Prerequisites <a href="#prerequisites" id="prerequisites"></a>

* The [gcloud command line tool](https://cloud.google.com/sdk/gcloud/)
* The [gke-gcloud-auth-plugin](https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke) (install the gcloud CLI first)

{% hint style="info" %}
**Self-hosting knowledge prerequisites**

Self-hosting n8n requires technical knowledge, including:

* Setting up and configuring servers and containers
* Managing application resources and scaling
* Securing servers and applications
* Configuring n8n

n8n recommends self-hosting for expert users. Mistakes can lead to data loss, security issues, and downtime. If you aren't experienced at managing servers, n8n recommends [n8n Cloud](https://n8n.io/cloud/).
{% endhint %}

{% hint style="info" %}
**Stable and Beta versions**

n8n releases a new minor version most weeks. The `stable` version is for production use. `beta` is the most recent release. The `beta` version may be unstable. To report issues, use the [forum](https://community.n8n.io/c/questions/12).

Current `stable`: 2.47.7 Current `beta`: 2.48.4
{% endhint %}

## Create project <a href="#create-project" id="create-project"></a>

GCP encourages you to create projects to logically organize resources and configuration. Create a new project for your n8n deployment from your Google Cloud Console: select the project dropdown menu and then the **NEW PROJECT** button. Then select the newly created project. As you follow the other steps in this guide, make sure you have the correct project selected.

## Enable the Kubernetes Engine API <a href="#enable-the-kubernetes-engine-api" id="enable-the-kubernetes-engine-api"></a>

GKE isn't enabled by default. Search for "Kubernetes" in the top search bar and select "Kubernetes Engine" from the results.

Select **ENABLE** to enable the Kubernetes Engine API for this project.

## Create a cluster <a href="#create-a-cluster" id="create-a-cluster"></a>

From the [GKE service page](https://console.cloud.google.com/kubernetes/list/overview), select **Clusters** > **CREATE**. Make sure you select the "Standard" cluster option, n8n doesn't work with an "Autopilot" cluster. You can leave the cluster configuration on defaults unless there's anything specifically you need to change, such as location.

## Set Kubectl context <a href="#set-kubectl-context" id="set-kubectl-context"></a>

The rest of the steps in this guide require you to set the GCP instance as the Kubectl context. You can find the connection details for a cluster instance by opening its details page and selecting **CONNECT**. The displayed code snippet shows a connection string for the gcloud CLI tool. Paste and run the code snippet in the gcloud CLI to change your local Kubernetes settings to use the new gcloud cluster.

## Clone configuration repository <a href="#clone-configuration-repository" id="clone-configuration-repository"></a>

Kubernetes and n8n require a series of configuration files. You can clone these from [this repository](https://github.com/n8n-io/n8n-hosting) locally. The following steps explain the file configuration and how to add your information.

Clone the repository with the following command:

```shell
git clone https://github.com/n8n-io/n8n-hosting.git
```

And change directory:

```shell
cd n8n-hosting/kubernetes
```

## Configure Postgres <a href="#configure-postgres" id="configure-postgres"></a>

For larger scale n8n deployments, Postgres provides a more robust database backend than SQLite.

### Create a volume for persistent storage <a href="#create-a-volume-for-persistent-storage" id="create-a-volume-for-persistent-storage"></a>

To maintain data between pod restarts, the Postgres deployment needs a persistent volume. Running Postgres on GCP requires a specific Kubernetes Storage Class. You can read [this guide](https://cloud.google.com/architecture/deploying-highly-available-postgresql-with-gke) for specifics, but the `storage.yaml` manifest creates it for you. You may want to change the regions to create the storage in under the `allowedTopologies` > `matchedLabelExpressions` > `values` key. By default, they're set to `us-central`.

```yaml
…
allowedTopologies:
  - matchLabelExpressions:
      - key: failure-domain.beta.kubernetes.io/zone
        values:
          - us-central1-b
          - us-central1-c
```

### Postgres environment variables <a href="#postgres-environment-variables" id="postgres-environment-variables"></a>

Postgres needs some environment variables set to pass to the application running in the containers.

The example `postgres-secret.yaml` file contains placeholders you need to replace with your own values. Postgres will use these details when creating the database..

The `postgres-deployment.yaml` manifest then uses the values from this manifest file to send to the application pods.

## Configure n8n <a href="#configure-n8n" id="configure-n8n"></a>

### Create a volume for file storage <a href="#create-a-volume-for-file-storage" id="create-a-volume-for-file-storage"></a>

While not essential for running n8n, using persistent volumes is required for:

* Using nodes that interact with files, such as the binary data node.
* If you want to persist [manual n8n encryption keys](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/deployment) between restarts. This saves a file containing the key into file storage during startup.

The `n8n-claim0-persistentvolumeclaim.yaml` manifest creates this, and the n8n Deployment mounts that claim in the `volumes` section of the `n8n-deployment.yaml` manifest.

```yaml
…
volumes:
  - name: n8n-claim0
    persistentVolumeClaim:
      claimName: n8n-claim0
…
```

### Pod resources <a href="#pod-resources" id="pod-resources"></a>

[Kubernetes lets you](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) optionally specify the minimum resources application containers need and the limits they can run to. The example YAML files cloned above contain the following in the `resources` section of the `n8n-deployment.yaml` and `postgres-deployment.yaml` files:

```yaml
…
resources:
  requests:
    memory: "250Mi"
  limits:
    memory: "500Mi"
…    
```

This defines a minimum of 250mb per container, a maximum of 500mb, and lets Kubernetes handle CPU. You can change these values to match your own needs. As a guide, here are the resources values for the n8n cloud offerings:

| Tier                 | RAM    | CPU                    |
| -------------------- | ------ | ---------------------- |
| Starter              | 320mb  | 10 millicore burstable |
| Pro (10k executions) | 640mb  | 20 millicore burstable |
| Pro (50k executions) | 1280mb | 80 millicore burstable |

### Optional: Environment variables <a href="#optional-environment-variables" id="optional-environment-variables"></a>

You can configure n8n settings and behaviors using environment variables.

Create an `n8n-secret.yaml` file. Refer to [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables) for n8n environment variables details.

## Deployments <a href="#deployments" id="deployments"></a>

The two deployment manifests (`n8n-deployment.yaml` and `postgres-deployment.yaml`) define the n8n and Postgres applications to Kubernetes.

{% hint style="warning" %}
The manifests run PostgreSQL 18. Setting up for the first time needs nothing extra.

If you already have a database running an older PostgreSQL major version, don't apply this to it. PostgreSQL 18 can't open a data directory written by an older major version, and moving the folder doesn't help. The pod stays in `CrashLoopBackOff` with `database files are incompatible with server`. PostgreSQL leaves your data alone, and you can pin the image back to the version you were on.

To move an existing database across, follow the official [PostgreSQL upgrade guide](https://www.postgresql.org/docs/18/upgrading.html) first.
{% endhint %}

The manifests define the following:

* Send the environment variables defined to each application pod
* Define the container image to use
* Set resource consumption limits with the `resources` object
* The `volumes` defined earlier and `volumeMounts` to define the path in the container to mount volumes.
* Scaling and restart policies. The example manifests define one instance of each pod. You should change this to meet your needs.

## Services <a href="#services" id="services"></a>

The two service manifests (`postgres-service.yaml` and `n8n-service.yaml`) expose the services to the outside world using the Kubernetes load balancer using ports 5432 and 5678 respectively.

## Send to Kubernetes cluster <a href="#send-to-kubernetes-cluster" id="send-to-kubernetes-cluster"></a>

Send all the manifests to the cluster with the following command:

```shell
kubectl apply -f .
```

{% hint style="info" %}
**Namespace error**

You may see an error message about not finding an "n8n" namespace as that resources isn't ready yet. You can run the same command again, or apply the namespace manifest first with the following command:

```shell
kubectl apply -f namespace.yaml
```

{% endhint %}

## Set up DNS <a href="#set-up-dns" id="set-up-dns"></a>

n8n typically operates on a subdomain. Create a DNS record with your provider for the subdomain and point it to the IP address of the n8n service. Find the IP address of the n8n service from the **Services & Ingress** menu item of the cluster you want to use under the **Endpoints** column.

{% hint style="info" %}
**GKE and IP addresses**

[Read this GKE tutorial](https://cloud.google.com/kubernetes-engine/docs/tutorials/configuring-domain-name-static-ip#configuring_your_domain_name_records) for more details on how reserved IP addresses work with GKE and Kubernetes resources.
{% endhint %}

## Delete resources <a href="#delete-resources" id="delete-resources"></a>

Remove the resources created by the manifests with the following command:

```shell
kubectl delete -f .
```

## Next steps <a href="#next-steps" id="next-steps"></a>

* Learn more about [configuring](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables) and [scaling](/deploy/host-n8n/configure-n8n/scaling) n8n.
* Or explore using n8n: try the [Quickstarts](/build-your-first-workflow).

## Related resources

* [Use a cloud provider](/deploy/host-n8n/install-options/use-a-cloud-provider)
* [DigitalOcean](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-digital-ocean)
* [Heroku](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-heroku)
* [Hetzner Cloud](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-hetzner)
* [AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws)
* [Azure](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-azure)
* [Google Cloud Run](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-cloud-run)
* [OpenShift Local (CRC)](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-openshift-local-crc)
* [Use Docker Compose](/deploy/host-n8n/install-options/use-a-cloud-provider/use-docker-compose)


# Deploy to OpenShift Local (CRC)

This guide walks you through deploying n8n on OpenShift Local (CRC), Red Hat's tool for running a local OpenShift cluster. It mirrors AWS/EKS deployment, but runs entirely on your local machine. It's designed for testing n8n in an OpenShift environment locally, without cloud costs.

You will need a machine with significant resources available, given how many resources OpenShift itself consumes.

## OpenShift concepts vs standard Kubernetes <a href="#openshift-concepts-vs-standard-kubernetes" id="openshift-concepts-vs-standard-kubernetes"></a>

OpenShift is built on Kubernetes but uses different terminology and has stricter security defaults. If you are familiar with standard Kubernetes, or with a guide that targets a managed Kubernetes service such as EKS, the table below maps the equivalent concepts so you know what to expect.

| Standard Kubernetes / EKS    | OpenShift Local (CRC)                                     |
| ---------------------------- | --------------------------------------------------------- |
| `kubectl`                    | `oc` (OpenShift CLI; also understands `kubectl` commands) |
| Namespace                    | Project (same concept, different command)                 |
| Ingress / LoadBalancer       | Route (built into OpenShift, no controller needed)        |
| EBS StorageClass (gp3)       | CRC built-in storage provisioner (no setup needed)        |
| RDS PostgreSQL               | In-cluster PostgreSQL via Helm (Bitnami)                  |
| ElastiCache Redis            | In-cluster Redis via Helm (Bitnami)                       |
| AWS S3                       | MinIO in-cluster (S3-compatible)                          |
| Pod Identity / IRSA          | Access keys via Kubernetes Secret                         |
| AWS Load Balancer Controller | Not needed (Routes are built-in)                          |
| OIDC / IAM                   | Not needed                                                |
| \~$135–400/month             | Free (runs on your machine)                               |

## Prerequisites <a href="#prerequisites" id="prerequisites"></a>

Before starting, confirm your machine has:

* **CPU**: 4 or more physical cores (not just threads) with virtualization support
* **RAM**: 32+ GB free minimum (CRC reserves 9 GB for its VM)
* **Disk**: 100 GB free
* **OS**: Ubuntu (22.04 LTS or newer)

## Prepare Ubuntu <a href="#prepare-ubuntu" id="prepare-ubuntu"></a>

### Open a terminal <a href="#open-a-terminal" id="open-a-terminal"></a>

Press `Ctrl+Alt+T` or search for **Terminal** in the Applications menu.

Every command in this guide is typed into the terminal and run by pressing **Enter**.

### Update your system <a href="#update-your-system" id="update-your-system"></a>

Start with a system update to avoid dependency issues:

```shell
sudo apt update && sudo apt upgrade -y
```

{% hint style="info" %}
**sudo**

`sudo` means “run as administrator”. You will be prompted for your password. Characters you type won't appear on screen, this is normal.
{% endhint %}

### Check CPU virtualization support <a href="#check-cpu-virtualization-support" id="check-cpu-virtualization-support"></a>

CRC runs a virtual machine. Your CPU must support hardware virtualization:

```shell
egrep -c '(vmx|svm)' /proc/cpuinfo
```

* **Output `0`**: Virtualization is disabled. Enter your BIOS/UEFI settings and enable VT-x (Intel) or AMD-V (AMD), then reboot and try again.
* **Output `1` or higher**: You are good to continue.

### Install KVM and libvirt <a href="#install-kvm-and-libvirt" id="install-kvm-and-libvirt"></a>

KVM is Linux’s built-in hypervisor. CRC uses it to run the OpenShift cluster VM:

```shell
sudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils
```

Install `virtiofsd`, which CRC requires to share the filesystem with the cluster VM:

```shell
sudo apt install -y virtiofsd
```

Start the libvirt service and configure it to start automatically on boot:

```shell
sudo systemctl start libvirtd
sudo systemctl enable libvirtd
```

Verify it's running:

```shell
sudo systemctl status libvirtd
```

Look for `Active: active (running)` in green. Press `q` to exit.

### Add user to required groups <a href="#add-user-to-required-groups" id="add-user-to-required-groups"></a>

This allows you to use KVM and libvirt without typing `sudo` for every command:

```shell
sudo usermod -aG libvirt $USER
sudo usermod -aG kvm $USER
```

{% hint style="info" %}
**Warning**

**You must log out and log back in (or reboot) for this to take effect.** If you skip this step, CRC will fail with a “permission denied” error.
{% endhint %}

Reboot now:

```shell
sudo reboot
```

After logging back in, open a terminal and verify group membership:

```shell
groups
```

You should see `libvirt` and `kvm` listed.

### Install NetworkManager <a href="#install-networkmanager" id="install-networkmanager"></a>

CRC requires NetworkManager to manage DNS entries for the cluster’s internal domains (`*.apps-crc.testing`, `api.crc.testing`):

```shell
sudo apt install -y network-manager
sudo systemctl start NetworkManager
sudo systemctl enable NetworkManager
```

Verify it's connected:

```shell
nmcli general status
```

The `STATE` column should show `connected`.

## Install tools <a href="#install-tools" id="install-tools"></a>

### Get a Red Hat account and pull secret <a href="#get-a-red-hat-account-and-pull-secret" id="get-a-red-hat-account-and-pull-secret"></a>

CRC requires a free Red Hat account to pull container images.

1. [Create a free Red Hat account](https://console.redhat.com/), if you don't already have one.
2. In [console.redhat.com/openshift/create/local](https://console.redhat.com/openshift/create/local), click **Download OpenShift Local**.
3. Select **Linux**, and download the `.tar.xz` file to `~/Downloads`.
4. On the same page of the Red Hat console, click **Copy pull secret**. Paste it into a text file and save it for later.

### Install CRC <a href="#install-crc" id="install-crc"></a>

Open a terminal in your Downloads folder.

```shell
cd ~/Downloads
```

Extract the archive.

```shell
tar xf crc-linux-amd64.tar.xz
```

Move the `crc` binary to a system-wide location, so it's available in any terminal:

```shell
sudo mv crc-*-linux-amd64/crc /usr/local/bin/
```

Verify the installation:

```shell
crc version
```

A version number should print to the terminal.

### Install Helm <a href="#install-helm" id="install-helm"></a>

Helm installs n8n and supporting services into the cluster:

```shell
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
```

Verify:

```shell
helm version
```

### Set environment variables <a href="#set-environment-variables" id="set-environment-variables"></a>

```shell
export NAMESPACE=n8n-$(date +%Y%m%d)
echo "Namespace:$NAMESPACE"
```

{% hint style="info" %}
**Variable persistence**

These variables only last for the current terminal session. Re-run this line whenever you open a new terminal before continuing.
{% endhint %}

## Start OpenShift Local <a href="#start-openshift-local" id="start-openshift-local"></a>

### Run CRC setup <a href="#run-crc-setup" id="run-crc-setup"></a>

You only need to run this once. It configures KVM networking, checks system requirements, and downloads the CRC bundle (\~2.5 GB):

```shell
crc setup
```

This takes several minutes. If it reports any missing packages, install them with `sudo apt install -y <package-name>` and re-run.

### Configure CRC memory and start the cluster <a href="#configure-crc-memory-and-start-the-cluster" id="configure-crc-memory-and-start-the-cluster"></a>

CRC defaults to 9 GB of RAM for its VM. n8n and its supporting services need more headroom. Set the memory to 14 GB before starting:

```shell
crc config set memory 14336
```

You only need to run this once. The setting persists across `crc stop` / `crc start` cycles.

**Recommended:** Save your pull secret to a file first so you don’t have to paste it every time:

```shell
# Open the file, paste your pull secret (from earlier), then Ctrl+O to save, Ctrl+X to exit <a href="#open-the-file-paste-your-pull-secret-from-earlier-then-ctrlo-to-save-ctrlx-to-exit" id="open-the-file-paste-your-pull-secret-from-earlier-then-ctrlo-to-save-ctrlx-to-exit"></a>
nano ~/pull-secret.txt

# Restrict permissions so only you can read it <a href="#restrict-permissions-so-only-you-can-read-it" id="restrict-permissions-so-only-you-can-read-it"></a>
chmod 600 ~/pull-secret.txt
```

Start CRC using the file:

```shell
crc start --pull-secret-file ~/pull-secret.txt
```

Alternatively, run `crc start` without the flag and paste the secret when prompted.

**This takes 10–15 minutes.** When complete you will see something like:

```
Started the OpenShift cluster.

The server is accessible via web console at:
  https://console-openshift-console.apps-crc.testing

Log in as administrator:
  Username: kubeadmin
  Password: <generated-password>

Log in as user:
  Username: developer
  Password: developer
```

**Save the `kubeadmin` password now.** You will need it in the next step. You can retrieve it later using `crc console --credentials`.

### Verify DNS resolution <a href="#verify-dns-resolution" id="verify-dns-resolution"></a>

On Ubuntu, CRC configures the system resolver automatically with NetworkManager and systemd-resolved. No manual `/etc/hosts` entries are needed.

Verify the API is reachable:

```shell
sudo ss -tlnp | grep 6443
```

You should see a process bound to `127.0.0.1:6443`. If nothing appears, re-run `crc start`. If DNS doesn't resolve `*.apps-crc.testing`, see the troubleshooting section.

### Configure your shell <a href="#configure-your-shell" id="configure-your-shell"></a>

CRC bundles the `oc` CLI inside the VM. This command makes it available in your terminal:

```shell
eval $(crc oc-env)
```

To make this permanent so you don't have to run it every time you open a terminal:

```shell
echo 'eval $(crc oc-env)' >> ~/.bashrc
source ~/.bashrc
```

Verify `oc` works:

```shell
oc version
```

### Log in to the cluster <a href="#log-in-to-the-cluster" id="log-in-to-the-cluster"></a>

```shell
oc login -u kubeadmin -p <your-kubeadmin-password> https://api.crc.testing:6443
```

Replace `<your-kubeadmin-password>` with the password printed when you [configured CRC memory and started the cluster](#configure-crc-memory-and-start-the-cluster).

Verify you are logged in:

```shell
oc whoami
```

`kubeadmin` should print to the screen.

## Standalone deployment <a href="#standalone-deployment" id="standalone-deployment"></a>

Standalone mode runs n8n as a single pod with SQLite. No external database or Redis is required. This is ideal for exploring n8n and testing workflows locally.

### Create the project <a href="#create-the-project" id="create-the-project"></a>

In OpenShift, a **project** is the same as a Kubernetes namespace: an isolated space for your resources:

```shell
oc new-project $NAMESPACE
```

### Grant the required security permission <a href="#grant-the-required-security-permission" id="grant-the-required-security-permission"></a>

OpenShift enforces strict security policies called **Security Context Constraints (SCCs)**. By default, pods can't run with a specific user ID. The n8n chart runs as user ID `1000`, so you must explicitly allow this.

Use the full explicit form. The shorthand `-z` flag can silently fail in some OpenShift versions:

```shell
oc adm policy add-scc-to-user anyuid \
  system:serviceaccount:$NAMESPACE:n8n
```

Verify the binding was created:

```shell
oc get rolebindings -n $NAMESPACE
```

You should see a binding referencing `system:openshift:scc:anyuid`.

### Create the required secret <a href="#create-the-required-secret" id="create-the-required-secret"></a>

```shell
oc create secret generic n8n-secrets \
  --namespace $NAMESPACE \
  --from-literal=N8N_ENCRYPTION_KEY="$(openssl rand -hex 32)" \
  --from-literal=N8N_HOST="localhost" \
  --from-literal=N8N_PORT="5678" \
  --from-literal=N8N_PROTOCOL="http"
```

**Back up the encryption key immediately:**

```shell
oc get secret n8n-secrets -n $NAMESPACE \
  -o jsonpath='{.data.N8N_ENCRYPTION_KEY}' | base64 --decode
```

Copy that output and store it somewhere safe. Losing it means all stored credentials in your workflows become permanently unreadable.

### Create your values file <a href="#create-your-values-file" id="create-your-values-file"></a>

Create a file called `n8n-standalone-values.yaml`. You can use `nano` (a simple text editor):

```shell
nano n8n-standalone-values.yaml
```

Paste the following, then press `Ctrl+O` to save and `Ctrl+X` to exit:

```yaml
# n8n-standalone-values.yaml <a href="#n8n-standalone-valuesyaml" id="n8n-standalone-valuesyaml"></a>
# Single pod, SQLite database, no external dependencies. <a href="#single-pod-sqlite-database-no-external-dependencies" id="single-pod-sqlite-database-no-external-dependencies"></a>

queueMode:
  enabled: false

database:
  type: sqlite
  useExternal: false

redis:
  enabled: false

# PVC stores the SQLite database file. <a href="#pvc-stores-the-sqlite-database-file" id="pvc-stores-the-sqlite-database-file"></a>
persistence:
  enabled: true
  size: 5Gi
  # No storageClassName needed — CRC provides a default storage provisioner.

secretRefs:
  existingSecret: "n8n-secrets"

service:
  type: ClusterIP
  port: 5678

# OpenShift: securityContext must be enabled so the pod runs as UID 1000 (node user) <a href="#openshift-securitycontext-must-be-enabled-so-the-pod-runs-as-uid-1000-node-user" id="openshift-securitycontext-must-be-enabled-so-the-pod-runs-as-uid-1000-node-user"></a>
# with fsGroup 1000 (so the PVC is writable). The anyuid SCC granted above <a href="#with-fsgroup-1000-so-the-pvc-is-writable-the-anyuid-scc-granted-above" id="with-fsgroup-1000-so-the-pvc-is-writable-the-anyuid-scc-granted-above"></a>
# allows this. The seccompProfile line is removed from the chart template in <a href="#allows-this-the-seccompprofile-line-is-removed-from-the-chart-template-in" id="allows-this-the-seccompprofile-line-is-removed-from-the-chart-template-in"></a>
# "Deploy n8n" because OpenShift 4.14+ rejects it even with anyuid. <a href="#deploy-n8n-because-openshift-414-rejects-it-even-with-anyuid" id="deploy-n8n-because-openshift-414-rejects-it-even-with-anyuid"></a>
securityContext:
  enabled: true

resources:
  main:
    requests:
      cpu: 100m
      memory: 256Mi
    limits:
      cpu: "1"
      memory: 1Gi

config:
  timezone: UTC
```

### Deploy n8n <a href="#deploy-n8n" id="deploy-n8n"></a>

The n8n Helm chart hard codes `seccompProfile: RuntimeDefault` in the pod spec. OpenShift 4.14+ converts this to a deprecated alpha annotation that's rejected at admission, even when `anyuid` SCC is granted. The fix is to pull the chart locally, remove those two lines, and install from the patched copy.

**Pull and patch the chart:**

```shell
helm pull oci://ghcr.io/n8n-io/n8n-helm-chart/n8n --version 1.0.3 --untar
sed -i '/seccompProfile:/d; /type: RuntimeDefault/d' ~/n8n/templates/deployment-main.yaml

# Confirm the lines are gone (should return no output) <a href="#confirm-the-lines-are-gone-should-return-no-output" id="confirm-the-lines-are-gone-should-return-no-output"></a>
grep -n "seccomp\|RuntimeDefault" ~/n8n/templates/deployment-main.yaml
```

**Install from the patched chart:**

```shell
helm install n8n ~/n8n/ \
  --namespace $NAMESPACE \
  --values n8n-standalone-values.yaml \
  --wait \
  --timeout 10m
```

### Access n8n using port forward <a href="#access-n8n-using-port-forward" id="access-n8n-using-port-forward"></a>

OpenShift Routes require a hostname, which adds complexity for standalone local access. Port-forward is simpler:

```shell
oc port-forward service/n8n-main --namespace $NAMESPACE 5678:5678
```

Leave this running, then open your browser to:

```
http://localhost:5678
```

n8n will prompt you to create an owner account.

{% hint style="info" %}
**Stop tunnel**

Press `Ctrl+C` to stop the tunnel. Re-run the `port-forward` command to access n8n again later.
{% endhint %}

### Check deployment status <a href="#check-deployment-status" id="check-deployment-status"></a>

```shell
oc get pods -n $NAMESPACE
```

Expected:

```
NAME                       READY   STATUS    RESTARTS   AGE
n8n-main-7d9f8b-xxxx       1/1     Running   0          3m
```

**Standalone deployment complete.**

## Multi-instance queue mode <a href="#multi-instance-queue-mode" id="multi-instance-queue-mode"></a>

Multi-instance queue mode runs multiple n8n pods with a shared database, message queue, and object storage. It requires an [n8n Enterprise license](https://n8n.io/pricing/).

Instead of AWS managed services, this guide uses in-cluster equivalents that mirror what you would find in an on-premises or customer OpenShift environment:

| AWS Service       | Local Equivalent                          |
| ----------------- | ----------------------------------------- |
| RDS PostgreSQL    | PostgreSQL (Bitnami Helm chart)           |
| ElastiCache Redis | Redis (Bitnami Helm chart)                |
| S3                | MinIO (S3-compatible, Bitnami Helm chart) |

### Install in-cluster services <a href="#install-in-cluster-services" id="install-in-cluster-services"></a>

#### Create the Project and add Bitnami Helm repo <a href="#create-the-project-and-add-bitnami-helm-repo" id="create-the-project-and-add-bitnami-helm-repo"></a>

```shell
oc new-project $NAMESPACE
```

Add the Bitnami chart repository (only needed once):

```shell
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
```

#### Install PostgreSQL <a href="#install-postgresql" id="install-postgresql"></a>

In the command below, replace `YourStrongPassword123` with a suitable complex password.

```shell
helm install postgresql bitnami/postgresql \
  --namespace $NAMESPACE \
  --set auth.username=n8n \
  --set auth.password='YourStrongPassword123' \
  --set auth.database=n8n_enterprise \
  --set global.compatibility.openshift.adaptSecurityContext=auto \
  --wait
```

{% hint style="info" %}
**Flag**

The `global.compatibility.openshift.adaptSecurityContext=auto` flag tells Bitnami to let OpenShift assign the correct user ID automatically (avoids SCC errors).
{% endhint %}

Save the endpoint, as it's fixed for in-cluster services:

```
postgresql.YOUR_NAMESPACE.svc.cluster.local
```

Replace `YOUR_NAMESPACE` with your actual `$NAMESPACE` value (e.g. `n8n-20260306`).

#### Install Redis <a href="#install-redis" id="install-redis"></a>

```shell
helm install redis bitnami/redis \
  --namespace $NAMESPACE \
  --set auth.enabled=false \
  --set architecture=standalone \
  --set global.compatibility.openshift.adaptSecurityContext=auto \
  --wait
```

Redis endpoint: `redis-master.$NAMESPACE.svc.cluster.local`

#### Install MinIO (S3-compatible storage) <a href="#install-minio-s3-compatible-storage" id="install-minio-s3-compatible-storage"></a>

In the command below, replace `MinioStrongPassword123` with a suitable complex password.

```shell
helm install minio bitnami/minio \
  --namespace $NAMESPACE \
  --set auth.rootUser=minioadmin \
  --set auth.rootPassword='MinioStrongPassword123' \
  --set global.compatibility.openshift.adaptSecurityContext=auto \
  --wait
```

MinIO endpoint: `http://minio:9000` (within the same namespace, just the service name works)

#### Create the n8n storage bucket in MinIO <a href="#create-the-n8n-storage-bucket-in-minio" id="create-the-n8n-storage-bucket-in-minio"></a>

MinIO needs a bucket created before n8n can use it. Use the MinIO web console:

**Open the MinIO console:**

```shell
oc port-forward svc/minio 9001:9001 -n $NAMESPACE
```

Leave this running, then open your browser to `http://localhost:9001`.

Log in with:

* **Username:** `minioadmin`
* **Password:** `MinioStrongPassword123`

In the console:

1. Click **Buckets** in the left sidebar → **Create Bucket**
2. **Bucket Name:** `n8n-data`
3. Click **Create Bucket**

Go back to the terminal and press `Ctrl+C` to stop the port-forward.

### Deploy n8n <a href="#deploy-n8n" id="deploy-n8n"></a>

#### Grant SCC for n8n <a href="#grant-scc-for-n8n" id="grant-scc-for-n8n"></a>

```shell
oc adm policy add-scc-to-user anyuid \
  system:serviceaccount:$NAMESPACE:n8n-enterprise
```

Verify that `oc get rolebindings -n $NAMESPACE` shows a binding for `system:openshift:scc:anyuid`.

#### Create required secrets <a href="#create-required-secrets" id="create-required-secrets"></a>

```shell
# Core n8n secrets <a href="#core-n8n-secrets" id="core-n8n-secrets"></a>
oc create secret generic n8n-enterprise-secrets \
  --namespace $NAMESPACE \
  --from-literal=N8N_ENCRYPTION_KEY="$(openssl rand -hex 32)" \
  --from-literal=N8N_HOST="localhost" \
  --from-literal=N8N_PORT="5678" \
  --from-literal=N8N_PROTOCOL="http"
```

**Back up the encryption key immediately:**

```shell
oc get secret n8n-enterprise-secrets -n $NAMESPACE \
  -o jsonpath='{.data.N8N_ENCRYPTION_KEY}' | base64 --decode
```

Store that value somewhere safe.

In the commands below, replace `YourStrongPassword123` and `MinioStrongPassword123` with the passwords from the earlier steps.

```shell
# Database password (must match what you set when installing PostgreSQL) <a href="#database-password-must-match-what-you-set-when-installing-postgresql" id="database-password-must-match-what-you-set-when-installing-postgresql"></a>
oc create secret generic n8n-enterprise-db-secret \
  --namespace $NAMESPACE \
  --from-literal=password='YourStrongPassword123'

# MinIO credentials <a href="#minio-credentials" id="minio-credentials"></a>
oc create secret generic n8n-minio-secret \
  --namespace $NAMESPACE \
  --from-literal=root-password='MinioStrongPassword123'
```

#### Create values file <a href="#create-values-file" id="create-values-file"></a>

Create `n8n-multimain-ocp-values.yaml`. Replace the **3 placeholder values** marked `# <-- REPLACE`:

```shell
nano n8n-multimain-ocp-values.yaml
```

```yaml
# n8n-multimain-ocp-values.yaml <a href="#n8n-multimain-ocp-valuesyaml" id="n8n-multimain-ocp-valuesyaml"></a>
# Multi-instance queue mode for OpenShift Local (CRC). <a href="#multi-instance-queue-mode-for-openshift-local-crc" id="multi-instance-queue-mode-for-openshift-local-crc"></a>
# Uses in-cluster PostgreSQL, Redis, and MinIO instead of AWS services. <a href="#uses-in-cluster-postgresql-redis-and-minio-instead-of-aws-services" id="uses-in-cluster-postgresql-redis-and-minio-instead-of-aws-services"></a>
# Requires Enterprise license. <a href="#requires-enterprise-license" id="requires-enterprise-license"></a>

# --- Enterprise license --- <a href="#enterprise-license" id="enterprise-license"></a>
license:
  enabled: true
  activationKey: "your-enterprise-license-key-here"  # <-- REPLACE

# --- Multi-main: 2 replicas (reduced for local resources) --- <a href="#multi-main-2-replicas-reduced-for-local-resources" id="multi-main-2-replicas-reduced-for-local-resources"></a>
multiMain:
  enabled: true
  replicas: 2

# --- Queue mode: 2 worker pods --- <a href="#queue-mode-2-worker-pods" id="queue-mode-2-worker-pods"></a>
queueMode:
  enabled: true
  workerReplicaCount: 2
  workerConcurrency: 5

# --- Webhook processors --- <a href="#webhook-processors" id="webhook-processors"></a>
webhookProcessor:
  enabled: true
  replicaCount: 1
  disableProductionWebhooksOnMainProcess: true

# --- PostgreSQL (in-cluster) --- <a href="#postgresql-in-cluster" id="postgresql-in-cluster"></a>
database:
  type: postgresdb
  useExternal: true
  host: "postgresql.YOUR_NAMESPACE.svc.cluster.local"   # <-- REPLACE YOUR_NAMESPACE
  port: 5432
  database: n8n_enterprise
  schema: "public"
  user: n8n
  passwordSecret:
    name: "n8n-enterprise-db-secret"
    key: "password"

# --- Redis (in-cluster, no TLS) --- <a href="#redis-in-cluster-no-tls" id="redis-in-cluster-no-tls"></a>
redis:
  enabled: true
  useExternal: true
  host: "redis-master.YOUR_NAMESPACE.svc.cluster.local"  # <-- REPLACE YOUR_NAMESPACE
  port: 6379
  tls: false

# --- MinIO (S3-compatible, in-cluster) --- <a href="#minio-s3-compatible-in-cluster" id="minio-s3-compatible-in-cluster"></a>
s3:
  enabled: true
  bucket:
    name: "n8n-data"
    region: "us-east-1"
  host: "http://minio:9000"
  auth:
    autoDetect: false
    accessKeyId: "minioadmin"
    secretAccessKeySecret:
      name: "n8n-minio-secret"
      key: "root-password"
  storage:
    mode: "s3"
    availableModes: "filesystem,s3"
  forcePathStyle: true

# --- Service account --- <a href="#service-account" id="service-account"></a>
serviceAccount:
  create: true
  name: n8n
```

Save and exit nano (`Ctrl+O`, `Ctrl+X`).

**Before deploying**, replace the two `YOUR_NAMESPACE` placeholders with your actual namespace value:

```shell
# Check your namespace value <a href="#check-your-namespace-value" id="check-your-namespace-value"></a>
echo $NAMESPACE

# Replace in the file (this edits it automatically) <a href="#replace-in-the-file-this-edits-it-automatically" id="replace-in-the-file-this-edits-it-automatically"></a>
sed -i "s/YOUR_NAMESPACE/$NAMESPACE/g" n8n-multimain-ocp-values.yaml
```

Verify the replacements:

```shell
grep "svc.cluster.local" n8n-multimain-ocp-values.yaml
```

Both lines should show your actual namespace name, not `YOUR_NAMESPACE`.

#### Deploy n8n <a href="#deploy-n8n" id="deploy-n8n"></a>

If you didn't patch the chart previously, pull and patch it now:

```shell
helm pull oci://ghcr.io/n8n-io/n8n-helm-chart/n8n --version 1.0.3 --untar
sed -i '/seccompProfile:/d; /type: RuntimeDefault/d' ~/n8n/templates/deployment-main.yaml
grep -n "seccomp\|RuntimeDefault" ~/n8n/templates/deployment-main.yaml  # should return nothing
```

Install from the patched chart:

```shell
helm install n8n ~/n8n/ \
  --namespace $NAMESPACE \
  --values n8n-multimain-ocp-values.yaml \
  --wait \
  --timeout 15m
```

#### Create a route for external access <a href="#create-a-route-for-external-access" id="create-a-route-for-external-access"></a>

In OpenShift, a **Route** exposes a service to the outside world. It's the equivalent of a Kubernetes Ingress or LoadBalancer, and requires no extra controller:

```shell
oc expose svc/n8n-main -n $NAMESPACE
```

Get the URL:

```shell
export ROUTE=$(oc get route n8n-main -n $NAMESPACE -o jsonpath='{.spec.host}')
echo "n8n URL: http://$ROUTE"
```

The URL will look like: `http://n8n-main-n8n-20260306.apps-crc.testing`

#### Update the host secret <a href="#update-the-host-secret" id="update-the-host-secret"></a>

n8n needs to know its public URL. Update the secret with the Route hostname, then restart the pods:

```shell
ENCRYPTION_KEY=$(oc get secret n8n-enterprise-secrets -n $NAMESPACE \
  -o jsonpath='{.data.N8N_ENCRYPTION_KEY}' | base64 --decode)

oc create secret generic n8n-enterprise-secrets \
  --namespace $NAMESPACE \
  --from-literal=N8N_ENCRYPTION_KEY="$ENCRYPTION_KEY" \
  --from-literal=N8N_HOST="$ROUTE" \
  --from-literal=N8N_PORT="5678" \
  --from-literal=N8N_PROTOCOL="http" \
  --dry-run=client -o yaml | oc apply -f -

oc rollout restart deployment -n $NAMESPACE
```

Wait for the rollout to complete:

```shell
oc rollout status deployment/n8n-main -n $NAMESPACE
```

#### Verify all pods are running <a href="#verify-all-pods-are-running" id="verify-all-pods-are-running"></a>

```shell
oc get pods -n $NAMESPACE
```

Expected (all `Running`):

```
NAME                                    READY   STATUS    RESTARTS   AGE
n8n-main-xxxx-aaaa                      1/1     Running   0          5m
n8n-main-xxxx-bbbb                      1/1     Running   0          5m
n8n-worker-xxxx-aaaa                    1/1     Running   0          5m
n8n-worker-xxxx-bbbb                    1/1     Running   0          5m
n8n-webhook-processor-xxxx-aaaa         1/1     Running   0          5m
postgresql-0                            1/1     Running   0          15m
redis-master-0                          1/1     Running   0          15m
minio-xxxx-xxxx                         1/1     Running   0          15m
```

Open your browser to the URL printed above.

**Multi-instance deployment complete.**

## Updating n8n <a href="#updating-n8n" id="updating-n8n"></a>

To change configuration or upgrade the chart version, pull and re-patch the new chart version, then upgrade:

```shell
# Remove the old local chart copy <a href="#remove-the-old-local-chart-copy" id="remove-the-old-local-chart-copy"></a>
rm -rf ~/n8n/

# Pull and patch the new version <a href="#pull-and-patch-the-new-version" id="pull-and-patch-the-new-version"></a>
helm pull oci://ghcr.io/n8n-io/n8n-helm-chart/n8n --version <new-version> --untar
sed -i '/seccompProfile:/d; /type: RuntimeDefault/d' ~/n8n/templates/deployment-main.yaml

# Standalone <a href="#standalone" id="standalone"></a>
helm upgrade n8n ~/n8n/ \
  --namespace $NAMESPACE \
  --values n8n-standalone-values.yaml

# Multi-instance <a href="#multi-instance" id="multi-instance"></a>
helm upgrade n8n ~/n8n/ \
  --namespace $NAMESPACE \
  --values n8n-multimain-ocp-values.yaml
```

## Stopping and resuming CRC <a href="#stopping-and-resuming-crc" id="stopping-and-resuming-crc"></a>

CRC doesn't need to be deleted between sessions. You can stop and restart it:

```shell
# Stop the cluster (saves state) <a href="#stop-the-cluster-saves-state" id="stop-the-cluster-saves-state"></a>
crc stop

# Start it again later <a href="#start-it-again-later" id="start-it-again-later"></a>
crc start
```

After restarting, re-run:

```shell
eval $(crc oc-env)
export NAMESPACE=n8n-YYYYMMDD   # use your original date
oc login -u kubeadmin -p <password> https://api.crc.testing:6443
```

## Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

### `crc setup` fails with “libvirt not found” <a href="#crc-setup-fails-with-libvirt-not-found" id="crc-setup-fails-with-libvirt-not-found"></a>

```shell
sudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients
sudo systemctl start libvirtd
```

Then re-run `crc setup`.

### `crc start` fails with “insufficient memory” <a href="#crc-start-fails-with-insufficient-memory" id="crc-start-fails-with-insufficient-memory"></a>

CRC requires at least 9 GB of free RAM. Close other applications and try again. If you [followed instructions for configuring CRC memory](#configure-crc-memory-and-start-the-cluster), CRC is configured to use 14 GB.

### n8n pod stuck in `Pending` or never created SCC error <a href="#n8n-pod-stuck-in-pending-or-never-created-scc-error" id="n8n-pod-stuck-in-pending-or-never-created-scc-error"></a>

Check events for the error:

```shell
oc get events -n $NAMESPACE --sort-by='.lastTimestamp' | tail -20
```

If you see `unable to validate against any security context constraint` or `seccomp may not be set`, the chart’s hard coded `seccompProfile: RuntimeDefault` is being rejected. OpenShift 4.14+ converts this to a deprecated alpha annotation that admission rejects even when `anyuid` SCC is granted.

**1. Grant anyuid using the explicit form** (the `-z` shorthand can silently fail):

```shell
# For standalone <a href="#for-standalone" id="for-standalone"></a>
oc adm policy add-scc-to-user anyuid \
  system:serviceaccount:$NAMESPACE:n8n

# For multi-instance <a href="#for-multi-instance" id="for-multi-instance"></a>
oc adm policy add-scc-to-user anyuid \
  system:serviceaccount:$NAMESPACE:n8n-enterprise
```

Verify: run `oc get rolebindings -n $NAMESPACE`. You should see a binding for `system:openshift:scc:anyuid`.

**2. Pull the chart locally and remove the `seccompProfile` lines:**

```shell
helm pull oci://ghcr.io/n8n-io/n8n-helm-chart/n8n --version 1.0.3 --untar
sed -i '/seccompProfile:/d; /type: RuntimeDefault/d' ~/n8n/templates/deployment-main.yaml

# Confirm they're gone (should return no output) <a href="#confirm-theyre-gone-should-return-no-output" id="confirm-theyre-gone-should-return-no-output"></a>
grep -n "seccomp\|RuntimeDefault" ~/n8n/templates/deployment-main.yaml
```

**3. Uninstall and reinstall from the patched chart:**

```shell
helm uninstall n8n -n $NAMESPACE
helm install n8n ~/n8n/ \
  --namespace $NAMESPACE \
  --values n8n-standalone-values.yaml \
  --wait \
  --timeout 10m
```

### Route URL returns “Application not available” <a href="#route-url-returns-application-not-available" id="route-url-returns-application-not-available"></a>

The pods may still be starting. Check:

```shell
oc get pods -n $NAMESPACE
oc rollout status deployment/n8n-main -n $NAMESPACE
```

Also confirm the Route exists:

```shell
oc get route -n $NAMESPACE
```

### n8n pod stuck in `Pending` with `Insufficient memory` <a href="#n8n-pod-stuck-in-pending-with-insufficient-memory" id="n8n-pod-stuck-in-pending-with-insufficient-memory"></a>

The CRC node doesn’t have enough free memory to schedule the pod.

**Fix:** Increase CRC’s VM memory and restart:

```shell
crc stop
crc config set memory 14336
crc start
```

After CRC restarts, the pod should schedule automatically. If the pod is still pending after a few minutes, delete it to force a reschedule:

```shell
oc delete pod -n $NAMESPACE -l app.kubernetes.io/component=main
```

If your machine can’t spare 14 GB, you can also lower the pod’s memory request in `n8n-standalone-values.yaml`:

```yaml
resources:
  main:
    requests:
      memory: 256Mi
```

Then upgrade: `helm upgrade n8n ~/n8n/ -n $NAMESPACE -f n8n-standalone-values.yaml`

### DNS not resolving `.apps-crc.testing` or `api.crc.testing` <a href="#dns-not-resolving-apps-crctesting-or-apicrctesting" id="dns-not-resolving-apps-crctesting-or-apicrctesting"></a>

On Ubuntu, CRC configures DNS automatically. If it fails, restart NetworkManager:

```shell
sudo systemctl restart NetworkManager
```

If still broken, add entries manually (CRC routes traffic through `127.0.0.1`):

```shell
sudo tee -a /etc/hosts <<EOF
127.0.0.1 api.crc.testing
127.0.0.1 console-openshift-console.apps-crc.testing
127.0.0.1 oauth-openshift.apps-crc.testing
127.0.0.1 default-route-openshift-image-registry.apps-crc.testing
EOF
```

{% hint style="info" %}
**Subdomains**

When you expose Routes in the multi-instance section, new `*.apps-crc.testing` subdomains are created. Add them to `/etc/hosts` pointing to `127.0.0.1` if your browser can’t reach them.
{% endhint %}

### n8n pod crashes with `EACCES: permission denied` writing to `/home/node/.n8n/` <a href="#n8n-pod-crashes-with-eacces-permission-denied-writing-to-homenoden8n" id="n8n-pod-crashes-with-eacces-permission-denied-writing-to-homenoden8n"></a>

This means the pod is running as a random OpenShift-assigned UID instead of UID 1000 (the `node` user the n8n image expects). It happens when `securityContext.enabled: false` is set in values without `runAsUser: 1000` and `fsGroup: 1000`, OpenShift assigns a random UID that can’t write to the PVC.

**Fix:** Ensure `securityContext.enabled: true` is set in your values file, and that the chart has been patched to remove `seccompProfile` (see the SCC error section above). Both are required together.

### View pod logs <a href="#view-pod-logs" id="view-pod-logs"></a>

```shell
# Main process <a href="#main-process" id="main-process"></a>
oc logs -n $NAMESPACE -l app.kubernetes.io/component=main --tail=50

# Workers <a href="#workers" id="workers"></a>
oc logs -n $NAMESPACE -l app.kubernetes.io/component=worker --tail=50

# Webhook processors <a href="#webhook-processors" id="webhook-processors"></a>
oc logs -n $NAMESPACE -l app.kubernetes.io/component=webhook-processor --tail=50
```

### All events in the namespace <a href="#all-events-in-the-namespace" id="all-events-in-the-namespace"></a>

```shell
oc get events -n $NAMESPACE --sort-by='.lastTimestamp'
```

## Quick Reference <a href="#quick-reference" id="quick-reference"></a>

### Re-export variables after reopening terminal <a href="#re-export-variables-after-reopening-terminal" id="re-export-variables-after-reopening-terminal"></a>

```shell
eval $(crc oc-env)
export NAMESPACE=n8n-YYYYMMDD   # use the date from your original deployment
oc login -u kubeadmin -p <password> https://api.crc.testing:6443
```

### Check cluster status <a href="#check-cluster-status" id="check-cluster-status"></a>

```shell
crc status
```

### Open the OpenShift web console <a href="#open-the-openshift-web-console" id="open-the-openshift-web-console"></a>

```shell
crc console
```

Log in with `kubeadmin` / your password to see a graphical view of everything running.

### Things to save <a href="#things-to-save" id="things-to-save"></a>

| Item                            | Why it matters                                |
| ------------------------------- | --------------------------------------------- |
| `kubeadmin` password            | Log in to the cluster                         |
| n8n encryption key              | Lose this = all stored credentials unreadable |
| `n8n-standalone-values.yaml`    | Required for `helm upgrade`                   |
| `n8n-multimain-ocp-values.yaml` | Required for `helm upgrade`                   |
| MinIO root password             | Access the MinIO console                      |
| PostgreSQL password             | Database access                               |

## Next steps <a href="#next-steps" id="next-steps"></a>

* Learn more about [configuring](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables) and [scaling](/deploy/host-n8n/configure-n8n/scaling) n8n.
* Or explore using n8n: try the [Quickstarts](/build-your-first-workflow).

## Related resources

* [Use a cloud provider](/deploy/host-n8n/install-options/use-a-cloud-provider)
* [DigitalOcean](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-digital-ocean)
* [Heroku](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-heroku)
* [Hetzner Cloud](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-hetzner)
* [AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws)
* [Azure](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-azure)
* [Google Cloud Run](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-cloud-run)
* [Google Kubernetes Engine](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-kubernetes)
* [Use Docker Compose](/deploy/host-n8n/install-options/use-a-cloud-provider/use-docker-compose)


# Use Docker Compose

Install and run n8n using Docker Compose

These instructions cover how to run n8n on a Linux server using Docker Compose.

If you have already installed Docker and Docker-Compose, then you can start with [step 3](#3-dns-setup).

You can find Docker Compose configurations for various architectures in the [n8n-hosting repository](https://github.com/n8n-io/n8n-hosting).

{% hint style="info" %}
**Self-hosting knowledge prerequisites**

Self-hosting n8n requires technical knowledge, including:

* Setting up and configuring servers and containers
* Managing application resources and scaling
* Securing servers and applications
* Configuring n8n

n8n recommends self-hosting for expert users. Mistakes can lead to data loss, security issues, and downtime. If you aren't experienced at managing servers, n8n recommends [n8n Cloud](https://n8n.io/cloud/).
{% endhint %}

{% hint style="info" %}
**Stable and Beta versions**

n8n releases a new minor version most weeks. The `stable` version is for production use. `beta` is the most recent release. The `beta` version may be unstable. To report issues, use the [forum](https://community.n8n.io/c/questions/12).

Current `stable`: 2.47.7 Current `beta`: 2.48.4
{% endhint %}

## 1. Install Docker and Docker Compose <a href="#id-1-install-docker-and-docker-compose" id="id-1-install-docker-and-docker-compose"></a>

The way that you install Docker and Docker Compose depends on your Linux distribution. You can find specific instructions for each component in the links below:

* [Docker Engine](https://docs.docker.com/engine/install/)
* [Docker Compose](https://docs.docker.com/compose/install/linux/)

After following the installation instructions, verify that Docker and Docker Compose are available by typing:

```shell
docker --version
docker compose version
```

## 2. Optional: Non-root user access <a href="#id-2-optional-non-root-user-access" id="id-2-optional-non-root-user-access"></a>

You can optionally grant access to run Docker without the `sudo` command.

To grant access to the user you're logged in as (assuming they have `sudo` access), run:

```shell
sudo usermod -aG docker ${USER}
# Register the `docker` group membership with current session without changing your primary group <a href="#register-the-docker-group-membership-with-current-session-without-changing-your-primary-group" id="register-the-docker-group-membership-with-current-session-without-changing-your-primary-group"></a>
exec sg docker newgrp
```

To grant access to a different user, type the following, substituting `<USER_TO_RUN_DOCKER>` with the appropriate username:

```shell
sudo usermod -aG docker <USER_TO_RUN_DOCKER>
```

You will need to run `exec sg docker newgrp` from any of that user's existing sessions for it to access the new group permissions.

You can verify that your current session recognizes the `docker` group by typing:

```shell
groups
```

## 3. DNS setup <a href="#id-3-dns-setup" id="id-3-dns-setup"></a>

To host n8n online or on a network, create a dedicated subdomain pointed at your server.

Add an A record to route the subdomain accordingly:

| Record type | Name                              | Destination                |
| ----------- | --------------------------------- | -------------------------- |
| A           | `n8n` (or your desired subdomain) | `<your_server_IP_address>` |

## 4. Create an `.env` file <a href="#id-4-create-an-env-file" id="id-4-create-an-env-file"></a>

Create a project directory to store your n8n environment configuration and Docker Compose files and navigate inside:

```shell
mkdir n8n-compose
cd n8n-compose
```

Inside the `n8n-compose` directory, create an `.env` file to customize your n8n instance's details. Change it to match your own information:

```shell
# DOMAIN_NAME and SUBDOMAIN together determine where n8n will be reachable from <a href="#domainname-and-subdomain-together-determine-where-n8n-will-be-reachable-from" id="domainname-and-subdomain-together-determine-where-n8n-will-be-reachable-from"></a>
# The top level domain to serve from <a href="#the-top-level-domain-to-serve-from" id="the-top-level-domain-to-serve-from"></a>
DOMAIN_NAME=example.com

# The subdomain to serve from <a href="#the-subdomain-to-serve-from" id="the-subdomain-to-serve-from"></a>
SUBDOMAIN=n8n

# The above example serve n8n at: https://n8n.example.com <a href="#the-above-example-serve-n8n-at-httpsn8nexamplecom" id="the-above-example-serve-n8n-at-httpsn8nexamplecom"></a>

# Optional timezone to set which gets used by Cron and other scheduling nodes <a href="#optional-timezone-to-set-which-gets-used-by-cron-and-other-scheduling-nodes" id="optional-timezone-to-set-which-gets-used-by-cron-and-other-scheduling-nodes"></a>
# New York is the default value if not set <a href="#new-york-is-the-default-value-if-not-set" id="new-york-is-the-default-value-if-not-set"></a>
GENERIC_TIMEZONE=Europe/Berlin

# The email address to use for the TLS/SSL certificate creation <a href="#the-email-address-to-use-for-the-tlsssl-certificate-creation" id="the-email-address-to-use-for-the-tlsssl-certificate-creation"></a>
SSL_EMAIL=user@example.com
```

## 5. Create local files directory <a href="#id-5-create-local-files-directory" id="id-5-create-local-files-directory"></a>

Inside your project directory, create a directory called `local-files` for sharing files between the n8n instance and the host system (for example, using the [Read/Write Files from Disk node](/integrations/builtin/core-nodes/n8n-nodes-base.readwritefile)):

```shell
mkdir local-files
```

The Docker Compose file below can automatically create this directory, but doing it manually ensures that it's created with the right ownership and permissions.

## 6. Create Docker Compose file <a href="#id-6-create-docker-compose-file" id="id-6-create-docker-compose-file"></a>

Create a `compose.yaml` file. Paste the following in the file:

```yaml
services:
  traefik:
    image: "traefik"
    restart: always
    command:
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
      - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.mytlschallenge.acme.tlschallenge=true"
      - "--certificatesresolvers.mytlschallenge.acme.email=${SSL_EMAIL}"
      - "--certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - traefik_data:/letsencrypt
      - /var/run/docker.sock:/var/run/docker.sock:ro

  n8n:
    image: n8nio/n8n
    restart: always
    ports:
      - "127.0.0.1:5678:5678"
    labels:
      - traefik.enable=true
      - traefik.http.routers.n8n.rule=Host(`${SUBDOMAIN}.${DOMAIN_NAME}`)
      - traefik.http.routers.n8n.tls=true
      - traefik.http.routers.n8n.entrypoints=web,websecure
      - traefik.http.routers.n8n.tls.certresolver=mytlschallenge
      - traefik.http.middlewares.n8n.headers.SSLRedirect=true
      - traefik.http.middlewares.n8n.headers.STSSeconds=315360000
      - traefik.http.middlewares.n8n.headers.browserXSSFilter=true
      - traefik.http.middlewares.n8n.headers.contentTypeNosniff=true
      - traefik.http.middlewares.n8n.headers.forceSTSHeader=true
      - traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME}
      - traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true
      - traefik.http.middlewares.n8n.headers.STSPreload=true
      - traefik.http.routers.n8n.middlewares=n8n@docker
    environment:
      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https  
      - NODE_ENV=production
      - N8N_WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
      - TZ=${GENERIC_TIMEZONE}
      - N8N_RESTRICT_FILE_ACCESS_TO=/files
    volumes:
      - n8n_data:/home/node/.n8n
      - ./local-files:/files

volumes:
  n8n_data:
  traefik_data:
```

`N8N_WEBHOOK_URL` is available from n8n 2.30.0; on earlier versions, use `WEBHOOK_URL`.

The Docker Compose file above configures two containers: one for n8n, and one to run [Traefik](https://github.com/traefik/traefik), an application proxy to manage TLS/SSL certificates and handle routing.

It also creates and mounts two [Docker volumes](https://docs.docker.com/engine/storage/volumes/) and mounts the `local-files` directory you created earlier:

| Name            | Type                                                        | Container mount   | Description                                                                                                                         |
| --------------- | ----------------------------------------------------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `n8n_data`      | [Volume](https://docs.docker.com/engine/storage/volumes/)   | `/home/node/.n8n` | Where n8n saves its SQLite database file and encryption key.                                                                        |
| `traefik_data`  | [Volume](https://docs.docker.com/engine/storage/volumes/)   | `/letsencrypt`    | Where Traefik saves TLS/SSL certificate data.                                                                                       |
| `./local-files` | [Bind](https://docs.docker.com/engine/storage/bind-mounts/) | `/files`          | A local directory shared between the n8n instance and host. In n8n, use the `/files` path to read from and write to this directory. |

## 7. Start Docker Compose <a href="#id-7-start-docker-compose" id="id-7-start-docker-compose"></a>

Start n8n by typing:

```shell
sudo docker compose up -d
```

To stop the containers, type:

```shell
sudo docker compose stop
```

## 8. Done <a href="#id-8-done" id="id-8-done"></a>

You can now reach n8n using the subdomain + domain combination you defined in your `.env` file configuration. The above example would result in `https://n8n.example.com`.

n8n is only accessible using secure HTTPS, not over plain HTTP.

If you have trouble reaching your instance, check your server's firewall settings and your DNS configuration.

## Next steps <a href="#next-steps" id="next-steps"></a>

* Learn more about [configuring](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables) and [scaling](/deploy/host-n8n/configure-n8n/scaling) n8n.
* Or explore using n8n: try the [Quickstarts](/build-your-first-workflow).

## Related resources

* [Use a cloud provider](/deploy/host-n8n/install-options/use-a-cloud-provider)
* [DigitalOcean](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-digital-ocean)
* [Heroku](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-heroku)
* [Hetzner Cloud](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-hetzner)
* [AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws)
* [Azure](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-azure)
* [Google Cloud Run](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-cloud-run)
* [Google Kubernetes Engine](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-google-kubernetes)
* [OpenShift Local (CRC)](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-openshift-local-crc)


# Production requirements

Check the database, operating system, runtime, storage, and software requirements for a production n8n deployment, and complete the pre-deployment checklist.

Before you run a production n8n deployment that you manage yourself, confirm that your database, operating system, runtime, storage, and deployment tooling meet n8n's requirements.

{% hint style="info" %}
**Looking for a quickstart?** You don't need this page. [One-line setup](/deploy/host-n8n/install-options/one-line-setup) only needs Docker and handles the database and storage for you. [Install using Docker Compose](/deploy/host-n8n/install-options/install-using-docker-compose) starts with the built-in SQLite database, with PostgreSQL as an optional step. Use this page when you move to production, run your own PostgreSQL, use queue mode, or deploy to Kubernetes or bare metal.
{% endhint %}

## Database

This section applies when you run n8n in production. [One-line setup](/deploy/host-n8n/install-options/one-line-setup) and the [Docker Compose](/deploy/host-n8n/install-options/install-using-docker-compose) guide start with n8n's built-in SQLite database, which suits testing and small setups.

n8n needs a database to store workflows, credentials, and execution history.

* **PostgreSQL:** n8n recommends PostgreSQL for production, on a [supported PostgreSQL version](/deploy/host-n8n/configure-n8n/choose-n8ns-database#supported-postgresql-versions).
* **SQLite:** n8n doesn't support SQLite in queue mode, and doesn't recommend it for multi-user production use.
* **Database user permissions:** the n8n database user must be able to connect to the database, use and create objects in the configured schema, and alter or drop n8n's tables during migrations. The simplest setup is to let the n8n user own the tables it creates. Refer to [Required permissions](/deploy/host-n8n/configure-n8n/choose-n8ns-database#required-permissions) for an example.

Refer to [Choose n8n's database](/deploy/host-n8n/configure-n8n/choose-n8ns-database) for the environment variables that configure PostgreSQL.

## Operating system and runtime

* **Operating system:** n8n recommends a 64-bit Linux host for production.
* **Node.js:** in n8n 2.x, you only need Node.js for [npm installations](/deploy/host-n8n/install-options/install-with-npm). Docker and Kubernetes installations include the correct version. Refer to [Install with npm](/deploy/host-n8n/install-options/install-with-npm) for the supported Node.js versions. From n8n 3.0, n8n no longer supports npm installations, so you need a Docker-based deployment. Refer to [v3.0 breaking changes](/changelog/v30-breaking-changes#docker-based-deployment-required-for-self-hosted-n8n).

## Storage

[One-line setup](/deploy/host-n8n/install-options/one-line-setup) and the [Docker Compose](/deploy/host-n8n/install-options/install-using-docker-compose) guide store n8n's data in a Docker volume, so you don't need to set up storage for them. If you adapt either setup, keep a volume for n8n's data. This section applies to production deployments and to deployments that [enable queue mode](/deploy/host-n8n/configure-n8n/scaling/enable-queue-mode), where you manage storage yourself.

For those deployments, plan for the following:

* **n8n data directory:** a persistent volume for the n8n data directory, which holds the encryption key and file logs, when enabled. It also holds local binary data in [filesystem mode](/deploy/host-n8n/configure-n8n/scaling/handle-binary-data#enable-filesystem-mode), the default in regular mode from n8n 2.0.
* **PostgreSQL data:** if you run PostgreSQL yourself, a persistent volume for PostgreSQL data.
* **Binary data in queue mode:** n8n stores binary data in the database by default unless you configure another storage mode. If your license includes the relevant [external storage](/deploy/host-n8n/configure-n8n/scaling/use-external-storage) option, you can use AWS S3 or Azure Blob Storage. If you use filesystem storage, all main instances, workers, and webhook processors that handle binary data must access the same shared volume at the same configured path. Database mode increases the size of your PostgreSQL database. If your license includes external storage, prefer it for queue mode. Refer to [Handle binary data](/deploy/host-n8n/configure-n8n/scaling/handle-binary-data) for details.

## Redis

This section applies only if you [enable queue mode](/deploy/host-n8n/configure-n8n/scaling/enable-queue-mode).

In queue mode, Redis holds the queue state for pending executions between the main n8n instance and its workers. PostgreSQL holds your workflows and execution data. If Redis loses queued jobs, n8n doesn't rebuild them from PostgreSQL. It marks the affected executions as crashed instead. Configure Redis persistence and availability to match how much lost work you can tolerate. Provision a Redis instance that the main instance and every worker can reach. Refer to [Start Redis](/deploy/host-n8n/configure-n8n/scaling/enable-queue-mode#start-redis) for the connection settings.

## Network

This section applies to production deployments that you expose to users or to external services.

### Ports

| Port | Component       | Purpose                                                                                                                                                                                                                                                                                                                      |
| ---- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 5678 | n8n             | HTTP API, editor UI, and webhooks. This is the default value of `N8N_PORT`.                                                                                                                                                                                                                                                  |
| 5432 | PostgreSQL      | Database connections. This is the PostgreSQL default.                                                                                                                                                                                                                                                                        |
| 6379 | Redis           | Queue communication in queue mode. This is the Redis default. Use the port and TLS settings of your Redis service, since managed services often use a different port for TLS.                                                                                                                                                |
| 5679 | n8n task broker | Connections from external task runners. This is the default value of `N8N_RUNNERS_BROKER_PORT`. The broker listens on `127.0.0.1` by default. If runners can’t connect through loopback, set `N8N_RUNNERS_BROKER_LISTEN_ADDRESS` to a bind address they can reach. Keep the port private and restrict access to the runners. |

### Firewall rules

At a minimum, configure your firewall so that:

* The main n8n instance and workers can reach PostgreSQL and, in queue mode, Redis.
* Your load balancer or reverse proxy can reach the main n8n instance on port 5678.
* n8n has outbound internet access to reach the external services your workflows use. This doesn't apply if you run n8n in an air-gapped environment where workflows only call internal services.
* Users can reach the editor UI through your load balancer or reverse proxy, from their networks.
* Services that call your webhooks can reach the webhook URLs, on the internet if those callers are external.
* If you run more than one main instance, your load balancer uses sticky sessions. Refer to [Enable queue mode](/deploy/host-n8n/configure-n8n/scaling/enable-queue-mode#multi-main-setup).

Don't expose the n8n process directly to the internet. Put a reverse proxy or load balancer in front of it.

### DNS

Create a DNS record that points a hostname, such as `n8n.example.com`, at your load balancer or reverse proxy. You use this hostname in the `N8N_HOST`, `N8N_EDITOR_BASE_URL`, and `N8N_WEBHOOK_URL` environment variables. `N8N_HOST` takes the hostname (`n8n.example.com`). `N8N_EDITOR_BASE_URL` and `N8N_WEBHOOK_URL` take full URLs (`https://n8n.example.com/`). `N8N_WEBHOOK_URL` is available from n8n 2.30.0; on earlier versions, use `WEBHOOK_URL`.

Behind a reverse proxy, also set `N8N_PROXY_HOPS`, which controls whether n8n trusts forwarded headers for the client IP and protocol. Refer to [Configure webhook URLs with reverse proxy](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/configure-webhook-urls-with-reverse-proxy) for how n8n builds webhook URLs behind a proxy and how to set `N8N_PROXY_HOPS`.

### TLS

Provision a TLS certificate for your hostname. n8n recommends terminating TLS at a reverse proxy or load balancer, which can also renew certificates if you configure it to. Refer to [Set up SSL](/deploy/host-n8n/configure-n8n/security/set-up-ssl) for how to set up SSL for n8n. On Kubernetes, [cert-manager](https://cert-manager.io/docs/) can issue and renew certificates.

## Software dependencies

Choose the subsection that matches how you deploy n8n.

### Docker

* A supported version of [Docker Engine](https://docs.docker.com/engine/install/) or [Docker Desktop](https://docs.docker.com/desktop/).
* The Docker Compose v2 plugin, for the Compose-based setups.

Refer to [Install using Docker Compose](/deploy/host-n8n/install-options/install-using-docker-compose) for installation steps.

### Kubernetes

* A Kubernetes version that the [official n8n Helm chart](https://github.com/n8n-io/n8n-hosting/tree/main/charts/n8n) supports. The chart declares its supported range in `Chart.yaml`.
* [`kubectl`](https://kubernetes.io/docs/tasks/tools/) configured with access to your cluster.
* [Helm](https://helm.sh/docs/intro/install/), for Helm-based deployments.
* A supported Ingress controller, such as the AWS Load Balancer Controller.

### Bare metal

{% hint style="info" %}
**Feature availability**

Bare metal installations with npm are available in n8n 2.x. From n8n 3.0, n8n no longer supports npm installations, so you need a Docker-based deployment. Refer to [v3.0 breaking changes](/changelog/v30-breaking-changes#docker-based-deployment-required-for-self-hosted-n8n).
{% endhint %}

* A supported Node.js version. Refer to [Install with npm](/deploy/host-n8n/install-options/install-with-npm).
* npm, which comes with Node.js.
* A process manager, such as PM2 or `systemd`.
* A reverse proxy, such as NGINX or Caddy, for SSL termination.

## Pre-deployment checklist

Use this checklist for production deployments. Skip items that don't apply to your setup, such as Redis if you don't use queue mode, or external storage if you don't use it.

* [ ] [License key](/deploy/host-n8n/configure-n8n/manage-your-license) obtained and ready to activate, if you use Business or Enterprise features.
* [ ] [PostgreSQL](#database) provisioned and accessible, on a supported version.
* [ ] [Redis](#redis) provisioned and accessible (queue mode only).
* [ ] [External storage](#storage) bucket or container created, if you use external storage.
* [ ] [DNS record](#dns) pointing to your load balancer.
* [ ] [TLS certificate](#tls) provisioned, or cert-manager configured.
* [ ] [Firewall rules](#firewall-rules) configured.
* [ ] [Persistent volumes](#storage) available.
* [ ] [Encryption key](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/set-a-custom-encryption-key) generated, stored securely, and set to the same value on every n8n instance. Run `openssl rand -hex 32` to generate one.
* [ ] [Backup strategy](/deploy/host-n8n/keep-n8n-running/backup-and-restore) decided.

## Related resources

* [Install options](/deploy/host-n8n/install-options)
* [One-line setup](/deploy/host-n8n/install-options/one-line-setup)
* [Install using Docker Compose](/deploy/host-n8n/install-options/install-using-docker-compose)
* [Install with npm](/deploy/host-n8n/install-options/install-with-npm)
* [Use a cloud provider](/deploy/host-n8n/install-options/use-a-cloud-provider)
* [Choose n8n's database](/deploy/host-n8n/configure-n8n/choose-n8ns-database)
* [Enable queue mode](/deploy/host-n8n/configure-n8n/scaling/enable-queue-mode)


# Configure n8n

Configure a self-hosted n8n instance, including database, security, scaling, and license settings.

Configure a self-hosted n8n instance, including database, security, scaling, and license settings.

## In this section

* [Basic configuration](/deploy/host-n8n/configure-n8n/basic-configuration): set environment variables, and browse configuration examples.
* [Choose n8n's database](/deploy/host-n8n/configure-n8n/choose-n8ns-database): SQLite and PostgreSQL configuration.
* [External hooks](/deploy/host-n8n/configure-n8n/external-hooks): run your own code at specific points in n8n's lifecycle.
* [Use the command line](/deploy/host-n8n/configure-n8n/use-the-command-line): the n8n CLI reference.
* [User management](/deploy/host-n8n/configure-n8n/user-management): manage users on a self-hosted instance.
* [Change instance owner email](/deploy/host-n8n/configure-n8n/change-instance-owner-email): update the email address of the instance owner.
* [Manage settings using environment variables](/deploy/host-n8n/configure-n8n/manage-settings-using-environment-variables): configure instance settings without the UI.
* [Set up task runners](/deploy/host-n8n/configure-n8n/set-up-task-runners): run Code node executions in external processes.
* [Durable scheduler](/deploy/host-n8n/configure-n8n/durable-scheduler): make scheduled triggers resilient to restarts.
* [System tasks](/deploy/host-n8n/configure-n8n/system-tasks): the Prometheus metrics n8n's system tasks expose.
* [Set up n8n Assistant](/deploy/host-n8n/configure-n8n/set-up-n8n-assistant): configure AI-assisted building for self-hosted n8n.
* [Deploy n8n in canvas-only mode](/deploy/host-n8n/configure-n8n/deploy-n8n-in-canvas-only-mode): restrict an instance to the workflow canvas.
* [Manage your license](/deploy/host-n8n/configure-n8n/manage-your-license): activate, renew, and manage your n8n license.
* [Security](/deploy/host-n8n/configure-n8n/security): audit, harden, and restrict a self-hosted instance.
* [Scaling](/deploy/host-n8n/configure-n8n/scaling): configure n8n for a large number of users, workflows, or executions.

## Related resources

* [Host n8n](/deploy/host-n8n)
* [Install options](/deploy/host-n8n/install-options)
* [Keep n8n running](/deploy/host-n8n/keep-n8n-running)
* [Understand the architecture](/deploy/host-n8n/understand-the-architecture)
* [Deploy as an OEM integration](/deploy/host-n8n/deploy-as-an-oem-integration)
* [Deploy with the AI starter kit](/deploy/host-n8n/deploy-with-the-ai-starter-kit)
* [Compare editions](/deploy/host-n8n/community-edition-features)


# Basic configuration

How to set environment variables for n8n.

You can change n8n's settings using environment variables. For a full list of available configurations see [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables).

## Set environment variables by command line <a href="#set-environment-variables-by-command-line" id="set-environment-variables-by-command-line"></a>

### npm <a href="#npm" id="npm"></a>

For npm, set your desired environment variables in terminal. The command depends on your command line.

Bash CLIs:

```bash
export <variable>=<value>
```

In cmd.exe:

```bash
set <variable>=<value>
```

In PowerShell:

```powershell
$env:<variable>=<value>
```

### Docker <a href="#docker" id="docker"></a>

In Docker you can use the `-e` flag from the command line:

```bash
docker run -it --rm \
 --name n8n \
 -p 5678:5678 \
 -e N8N_TEMPLATES_ENABLED="false" \
 n8nio/n8n
```

## Docker Compose file <a href="#docker-compose-file" id="docker-compose-file"></a>

In Docker, you can set your environment variables in the `n8n: environment:` element of your `docker-compose.yaml` file.

For example:

```yaml
n8n:
    environment:
      - N8N_TEMPLATES_ENABLED=false
```

## Keeping sensitive data in separate files <a href="#keeping-sensitive-data-in-separate-files" id="keeping-sensitive-data-in-separate-files"></a>

You can append `_FILE` to individual environment variables to provide their configuration in a separate file, enabling you to avoid passing sensitive details using environment variables. n8n loads the data from the file with the given name, making it possible to load data from [Docker secrets](https://docs.docker.com/engine/swarm/secrets/) and [Kubernetes secrets](https://kubernetes.io/docs/concepts/configuration/secret/).

Refer to [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables) for details on each variable.

While most environment variables can use the `_FILE` suffix, it's more beneficial for sensitive data such as credentials[^1] and database configuration. Here are some examples:

```yaml
CREDENTIALS_OVERWRITE_DATA_FILE=/path/to/credentials_data
DB_TYPE_FILE=/path/to/db_type
DB_POSTGRESDB_DATABASE_FILE=/path/to/database_name
DB_POSTGRESDB_HOST_FILE=/path/to/database_host
DB_POSTGRESDB_PORT_FILE=/path/to/database_port
DB_POSTGRESDB_USER_FILE=/path/to/database_user
DB_POSTGRESDB_PASSWORD_FILE=/path/to/database_password
DB_POSTGRESDB_SCHEMA_FILE=/path/to/database_schema
DB_POSTGRESDB_SSL_CA_FILE=/path/to/ssl_ca
DB_POSTGRESDB_SSL_CERT_FILE=/path/to/ssl_cert
DB_POSTGRESDB_SSL_KEY_FILE=/path/to/ssl_key
DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED_FILE=/path/to/ssl_reject_unauth
```

## In this section

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables): reference for every environment variable n8n supports.
* [Configuration examples](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples): examples for how to configure n8n to solve particular use cases.

## Related resources

* [Configure n8n](/deploy/host-n8n/configure-n8n)

[^1]: In n8n, credentials store authentication information to connect with specific apps and services. After creating credentials with your authentication information (username and password, API key, OAuth secrets, etc.), you can use the associated app node to interact with the service.


# Use environment variables

An overview of configuration environment variables for self-hosted n8n.

This section lists the environment variables that you can use to change n8n's configuration settings when self-hosting n8n.

{% hint style="info" %}
**File-based configuration**

You can provide a [configuration file](/deploy/host-n8n/configure-n8n/basic-configuration) for n8n. You can also append `_FILE` to certain variables to provide their configuration in a separate file.
{% endhint %}

## In this section

* [Ask n8n AI](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/ai-assistant): variables for n8n's built-in AI help assistant.
* [Binary data](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/binary-data): variables for storing and handling binary data.
* [Credentials](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/credentials): variables for credential overwrites and encryption.
* [Database](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/database): variables for database connection and configuration.
* [Deployment](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/deployment): variables for instance identity, encryption, and the public API.
* [Endpoints](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/endpoints): variables for customizing n8n's REST and webhook endpoint paths.
* [Executions](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/executions): variables for execution timeouts, data pruning, and process modes.
* [Expression engine](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/expression-engine): variables for controlling expression evaluation.
* [External data storage](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/external-data-storage): variables for storing data outside the n8n database.
* [External hooks](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/external-hooks): variables for the external hooks file location.
* [External secrets](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/external-secrets): variables for external secrets vaults.
* [Insights](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/insights): variables for the Insights usage tracking feature.
* [Logs](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/logs): variables for logging level, format, and destinations.
* [License](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/license): variables for activating and managing your n8n license.
* [Nodes](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/nodes): variables for excluding or including specific nodes.
* [OpenTelemetry](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/opentelemetry): variables for exporting execution traces.
* [Queue mode](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/queue-mode): variables for running n8n across multiple worker processes.
* [Scheduler](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/scheduler): variables for the durable scheduler.
* [Security](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/security): variables for hardening a self-hosted instance.
* [Source control](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/source-control): variables for Git-based source control.
* [SSO](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/sso): variables for single sign-on.
* [SSRF protection](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/ssrf-protection): variables for restricting outbound requests from workflow nodes.
* [Task runners](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/task-runners): variables for configuring external Code node execution.
* [Timezone and localization](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/timezone-and-localization): variables for setting your instance's timezone and locale.
* [User management and 2FA](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/user-management-and-2fa): variables for user management and two-factor authentication.
* [Workflows](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/workflows): variables for workflow defaults and templates.
* [Workflow history](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/workflow-history): variables for workflow version history.

## Related resources

* [Basic configuration](/deploy/host-n8n/configure-n8n/basic-configuration)
* [Configuration examples](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples)


# Ask n8n AI

Environment variables to configure Ask n8n AI.

| Variable                    | Type   | Default | Description                                                                                                                                     |
| --------------------------- | ------ | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_AI_ASSISTANT_BASE_URL` | String | (empty) | Base URL of the AI assistant service, specified as `https://ai-assistant.n8n.io` . Required if you self-host n8n and want to enable Ask n8n AI. |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Binary data

Customize binary data storage modes and paths with environment variables for your self-hosted n8n instance.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

By default, n8n uses memory to store binary data. On self-hosted Business and Enterprise plans, you can choose to use an external service instead. Refer to [External storage](/deploy/host-n8n/configure-n8n/scaling/use-external-storage) for more information on using external storage for binary data.

| Variable                                 | Type   | Default                      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ---------------------------------------- | ------ | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `N8N_AVAILABLE_BINARY_DATA_MODES`        | String | `filesystem`                 | A comma separated list of available binary data modes.                                                                                                                                                                                                                                                                                                                                                                                           |
| `N8N_BINARY_DATA_DATABASE_MAX_FILE_SIZE` | Number | `512`                        | Maximum size (in MiB) of a single file n8n stores when `N8N_DEFAULT_BINARY_DATA_MODE` is `database`. Can't exceed `1024`, the limit of a database column. Storing a larger file fails.                                                                                                                                                                                                                                                           |
| `N8N_BINARY_DATA_STORAGE_PATH`           | String | `N8N_USER_FOLDER/binaryData` | The path where n8n stores binary data.                                                                                                                                                                                                                                                                                                                                                                                                           |
| `N8N_DEFAULT_BINARY_DATA_MODE`           | String | `default`                    | The default binary data mode. `default` keeps binary data in memory. Set to `filesystem` to use the filesystem, `s3` to use AWS S3, `azure` to use Azure Blob Storage, or `database` to use the DB. Note that binary data pruning operates on the active binary data mode. For example, if your instance stored data in S3, and you later switched to filesystem mode, n8n only prunes binary data in the filesystem. This may change in future. |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Credentials

Manage default credentials and override them through environment variables your self-hosted n8n instance.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

Enable credential overwrites using the following environment variables. Refer to [Credential overwrites](/administer/manage-credentials/credential-overwrites) for details.

| Variable                                                                 | Type    | Default          | Description                                                                                                                                                               |
| ------------------------------------------------------------------------ | ------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>CREDENTIALS\_OVERWRITE\_DATA</code><br>/<code>\_FILE</code></p> | \*      | -                | Overwrites for credentials.                                                                                                                                               |
| `CREDENTIALS_OVERWRITE_ENDPOINT`                                         | String  | -                | The API endpoint to fetch credentials.                                                                                                                                    |
| `CREDENTIALS_OVERWRITE_PERSISTENCE`                                      | Boolean | `false`          | Enable database persistence for credential overwrites. Required for multi-instance or queue mode to propagate overwrites to workers through a publish/subscribe approach. |
| `N8N_MANAGED_OAUTH_SHOW_SCOPES`                                          | String  | -                | Comma-separated list of managed OAuth credential types for which users can configure scope fields.                                                                        |
| `CREDENTIALS_DEFAULT_NAME`                                               | String  | `My credentials` | The default name for credentials.                                                                                                                                         |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Database

Set up and configure databases with environment variables for your self-hosted n8n instance.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

By default, n8n uses SQLite. n8n also supports PostgreSQL. n8n [deprecated support for MySQL and MariaDB](/changelog/v10-migration-guide#mysql-and-mariadb) from n8n 1.0.

This page outlines environment variables to configure your chosen database for your self-hosted n8n instance.

| Variable                                             | Type                                                                | Default  | Description                                                                                                                                                                        |
| ---------------------------------------------------- | ------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>DB\_TYPE</code><br>/<code>\_FILE</code></p> | <p>Enum string:<br><code>sqlite</code>, <code>postgresdb</code></p> | `sqlite` | The database to use.                                                                                                                                                               |
| `DB_TABLE_PREFIX`                                    | \*                                                                  | -        | Prefix to use for table names.                                                                                                                                                     |
| `DB_PING_INTERVAL_SECONDS`                           | Number                                                              | `2`      | How often, in seconds, n8n pings the database to check that the connection is still alive.                                                                                         |
| `DB_PING_TIMEOUT_MS`                                 | Number                                                              | `5000`   | How long, in milliseconds, n8n waits for a single ping to respond before counting it as a failure. Falls back to `N8N_DB_PING_TIMEOUT`, deprecated from n8n 2.35.0, if that's set. |
| `DB_PING_MAX_FAILURES_BEFORE_RECOVERY`               | Number                                                              | `3`      | How many pings in a row must fail before n8n treats the connection as lost and starts recovery.                                                                                    |
| `DB_RECOVERY_BACKOFF_MIN_MS`                         | Number                                                              | `1000`   | How long, in milliseconds, n8n waits before its first recovery attempt. Each retry waits longer (exponential backoff).                                                             |
| `DB_RECOVERY_BACKOFF_MAX_MS`                         | Number                                                              | `30000`  | The longest, in milliseconds, n8n waits between recovery attempts. This caps the backoff. Must be greater than or equal to `DB_RECOVERY_BACKOFF_MIN_MS`.                           |
| `DB_CONNECTION_ACQUISITION_TIMEOUT_MS`               | Number                                                              | `30000`  | How long, in milliseconds, a query waits while recovery is in progress before failing fast with an error. Set to `0` to wait indefinitely. Applies to PostgreSQL only.             |

## PostgreSQL <a href="#postgresql" id="postgresql"></a>

| Variable                                                                                    | Type    | Default     | Description                                                                                                                                                                                                                                                |
| ------------------------------------------------------------------------------------------- | ------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>DB\_POSTGRESDB\_DATABASE</code><br>/<code>\_FILE</code></p>                        | String  | `n8n`       | The name of the PostgreSQL database.                                                                                                                                                                                                                       |
| <p><code>DB\_POSTGRESDB\_HOST</code><br>/<code>\_FILE</code></p>                            | String  | `localhost` | The PostgreSQL host.                                                                                                                                                                                                                                       |
| <p><code>DB\_POSTGRESDB\_PORT</code><br>/<code>\_FILE</code></p>                            | Number  | `5432`      | The PostgreSQL port.                                                                                                                                                                                                                                       |
| <p><code>DB\_POSTGRESDB\_USER</code><br>/<code>\_FILE</code></p>                            | String  | `postgres`  | The PostgreSQL user.                                                                                                                                                                                                                                       |
| <p><code>DB\_POSTGRESDB\_PASSWORD</code><br>/<code>\_FILE</code></p>                        | String  | -           | The PostgreSQL password.                                                                                                                                                                                                                                   |
| <p><code>DB\_POSTGRESDB\_POOL\_SIZE</code><br>/<code>\_FILE</code></p>                      | Number  | `2`         | Control how many parallel open Postgres connections n8n should have. Increasing it may help with resource utilization, but too many connections may degrade performance.                                                                                   |
| <p><code>DB\_POSTGRESDB\_CONNECTION\_TIMEOUT</code><br>/<code>\_FILE</code></p>             | Number  | `20000`     | Postgres connection timeout (ms).                                                                                                                                                                                                                          |
| <p><code>DB\_POSTGRESDB\_IDLE\_CONNECTION\_TIMEOUT</code><br>/<code>\_FILE</code></p>       | Number  | `30000`     | Amount of time before an idle connection is eligible for eviction for being idle.                                                                                                                                                                          |
| <p><code>DB\_POSTGRESDB\_MAX\_CONNECTION\_LIFETIME\_MS</code><br>/<code>\_FILE</code></p>   | Number  | `3600000`   | How long, in milliseconds, n8n keeps a pooled connection before recycling it. Recycling old connections helps avoid stale connections that the database or network dropped without n8n noticing. The default is one hour. Set to `0` to disable recycling. |
| <p><code>DB\_POSTGRESDB\_KEEP\_ALIVE</code><br>/<code>\_FILE</code></p>                     | Boolean | `true`      | Whether to enable TCP keep-alive on connections. Keep-alive lets n8n notice a dead connection without having to run a query first.                                                                                                                         |
| <p><code>DB\_POSTGRESDB\_KEEP\_ALIVE\_INITIAL\_DELAY\_MS</code><br>/<code>\_FILE</code></p> | Number  | `10000`     | How long, in milliseconds, n8n waits before sending the first TCP keep-alive probe on a connection.                                                                                                                                                        |
| <p><code>DB\_POSTGRESDB\_SCHEMA</code><br>/<code>\_FILE</code></p>                          | String  | `public`    | The PostgreSQL schema.                                                                                                                                                                                                                                     |
| <p><code>DB\_POSTGRESDB\_SSL\_ENABLED</code><br>/<code>\_FILE</code></p>                    | Boolean | `false`     | Whether to enable SSL. Automatically enabled if `DB_POSTGRESDB_SSL_CA`, `DB_POSTGRESDB_SSL_CERT` or `DB_POSTGRESDB_SSL_KEY` is set to a non-empty value, or if `DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED` is set to `false`.                                  |
| <p><code>DB\_POSTGRESDB\_SSL\_CA</code><br>/<code>\_FILE</code></p>                         | String  | -           | The PostgreSQL SSL certificate authority.                                                                                                                                                                                                                  |
| <p><code>DB\_POSTGRESDB\_SSL\_CERT</code><br>/<code>\_FILE</code></p>                       | String  | -           | The PostgreSQL SSL certificate.                                                                                                                                                                                                                            |
| <p><code>DB\_POSTGRESDB\_SSL\_KEY</code><br>/<code>\_FILE</code></p>                        | String  | -           | The PostgreSQL SSL key.                                                                                                                                                                                                                                    |
| <p><code>DB\_POSTGRESDB\_SSL\_REJECT\_UNAUTHORIZED</code><br>/<code>\_FILE</code></p>       | Boolean | `true`      | If n8n should reject unauthorized SSL connections (true) or not (false).                                                                                                                                                                                   |

## SQLite <a href="#sqlite" id="sqlite"></a>

| Variable                      | Type    | Default | Description                                                                                                                                                                                                                                |
| ----------------------------- | ------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `DB_SQLITE_POOL_SIZE`         | Number  | `3`     | The number of parallel SQL read connections in the SQLite connection pool. Must be at least `1`. Setting it to `0` logs a warning and falls back to the default. n8n opens the SQLite file in [WAL mode](https://www.sqlite.org/wal.html). |
| `DB_SQLITE_VACUUM_ON_STARTUP` | Boolean | `false` | Runs [VACUUM](https://www.sqlite.org/lang_vacuum.html) operation on startup to rebuild the database. Reduces file size and optimizes indexes. This is a long running blocking operation and increases start-up time.                       |

## How database connection recovery works <a href="#how-database-connection-recovery-works" id="how-database-connection-recovery-works"></a>

n8n keeps checking that it can still reach your database. If the connection drops, for example after a database restart or a network blip, n8n can repair it on its own instead of staying broken until you restart n8n.

Here's the cycle the variables on this page control:

1. Every `DB_PING_INTERVAL_SECONDS`, n8n sends a ping. Each ping has `DB_PING_TIMEOUT_MS` to respond.
2. Once `DB_PING_MAX_FAILURES_BEFORE_RECOVERY` pings fail in a row, n8n treats the connection as lost.
3. n8n then rebuilds the connection, retrying with a growing wait between attempts that starts at `DB_RECOVERY_BACKOFF_MIN_MS` and never exceeds `DB_RECOVERY_BACKOFF_MAX_MS`.
4. On PostgreSQL, while recovery is in progress, any new query waits up to `DB_CONNECTION_ACQUISITION_TIMEOUT_MS` for the connection to come back, then fails with an error rather than hanging.

{% hint style="info" %}
**Applies to all databases**

The health checks and the recovery cycle (the `DB_PING_*` and `DB_RECOVERY_BACKOFF_*` variables) apply to every database type. The remaining settings (`DB_CONNECTION_ACQUISITION_TIMEOUT_MS`, `DB_POSTGRESDB_MAX_CONNECTION_LIFETIME_MS`, `DB_POSTGRESDB_KEEP_ALIVE`, and `DB_POSTGRESDB_KEEP_ALIVE_INITIAL_DELAY_MS`) apply to PostgreSQL only. The default values suit most deployments, so you can leave them unchanged unless you run into connection problems.
{% endhint %}

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Deployment

Configure deployment options and application accessibility with environment variables for your self-hosted n8n instance.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

This page lists the deployment configuration options for your self-hosted n8n instance, including setting up access URLs, enabling templates, customizing encryption, and configuring server details.

{% hint style="info" %}
**Proxy variable priorities**

The [`proxy-from-env`](https://www.npmjs.com/package/proxy-from-env) package that n8n uses to handle proxy environment variables (those ending with `_PROXY`) imposes a certain variable precedence. Notably, for proxy variables, lowercase versions (like `http_proxy`) have precedence over uppercase variants (for example `HTTP_PROXY`) when both are present.

To learn more about proxy environment variables, check the [environment variables section of the package details](https://www.npmjs.com/package/proxy-from-env#environment-variables).
{% endhint %}

| Variable                                                  | Type                         | Default                                                          | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| --------------------------------------------------------- | ---------------------------- | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `HTTP_PROXY`                                              | String                       | -                                                                | A URL to proxy unencrypted HTTP requests through. When set, n8n proxies all unencrypted HTTP traffic from nodes through the proxy URL.                                                                                                                                                                                                                                                                                                                                                          |
| `HTTPS_PROXY`                                             | String                       | -                                                                | A URL to proxy TLS/SSL encrypted HTTP requests through. When set, n8n proxies all TLS/SSL encrypted HTTP traffic from nodes through the proxy URL.                                                                                                                                                                                                                                                                                                                                              |
| `ALL_PROXY`                                               | String                       | -                                                                | A URL to proxy both unencrypted and encrypted HTTP requests through. When set, n8n uses this value when more specific variables (`HTTP_PROXY` or `HTTPS_PROXY`) aren't present.                                                                                                                                                                                                                                                                                                                 |
| `NO_PROXY`                                                | String                       | -                                                                | A comma-separated list of hostnames or URLs that should bypass the proxy. When using `HTTP_PROXY`, `HTTPS_PROXY`, or `ALL_PROXY`, n8n will connect directly to the URLs or hostnames defined here instead of using the proxy.                                                                                                                                                                                                                                                                   |
| `N8N_ENFORCE_GLOBAL_USER_AGENT`                           | Boolean                      | `false`                                                          | When set to `true`, n8n replaces the default bare `n8n` User-Agent string with an RFC-compliant value (`Mozilla/5.0 (compatible; n8n/<version>; +https://n8n.io/)`) on all outbound HTTP requests. Enable this to prevent web application firewalls from blocking n8n requests.                                                                                                                                                                                                                 |
| `N8N_GLOBAL_USER_AGENT_VALUE`                             | String                       | -                                                                | A custom User-Agent string to use for all outbound HTTP requests. Overrides the RFC-compliant default set by `N8N_ENFORCE_GLOBAL_USER_AGENT`. Useful when you don't want to disclose the n8n version to upstream servers.                                                                                                                                                                                                                                                                       |
| `N8N_EDITOR_BASE_URL`                                     | String                       | -                                                                | Public URL where users can access the editor. Also used for emails sent from n8n and the redirect URL for SAML based authentication.                                                                                                                                                                                                                                                                                                                                                            |
| `N8N_DISABLE_UI`                                          | Boolean                      | `false`                                                          | Set to `true` to disable the UI.                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `N8N_PREVIEW_MODE`                                        | Boolean                      | `false`                                                          | Set to `true` to run in preview mode.                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `N8N_CANVAS_ONLY`                                         | Boolean                      | `false`                                                          | Set to `true` to run n8n in [canvas-only mode](/deploy/host-n8n/configure-n8n/deploy-n8n-in-canvas-only-mode), hiding the header, sidebar, and overlay elements when viewing an individual workflow. Available from n8n 2.15.0.                                                                                                                                                                                                                                                                 |
| `N8N_TEMPLATES_ENABLED`                                   | Boolean                      | `true`                                                           | Enables [workflow templates](#user-content-fn-1)[^1] (true) or disable (false).                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `N8N_TEMPLATES_HOST`                                      | String                       | `https://api.n8n.io`                                             | Change this if creating your own workflow template library. Note that to use your own workflow templates library, your API must provide the same endpoints and response structure as n8n's. Refer to [Workflow templates](/build/ways-of-building-workflows/use-templates) for more information.                                                                                                                                                                                                |
| `N8N_ENCRYPTION_KEY`                                      | String                       | Random key generated by n8n                                      | Provide a custom key used to encrypt credentials in the n8n database. By default n8n generates a random key on first launch.                                                                                                                                                                                                                                                                                                                                                                    |
| `N8N_ENV_FEAT_ENCRYPTION_KEY_ROTATION`                    | Boolean                      | `false`                                                          | Set to `true` on all instances (main and workers) to enable [encryption key rotation](/deploy/host-n8n/configure-n8n/security/rotate-encryption-keys). One-way change: take a full database backup first.                                                                                                                                                                                                                                                                                       |
| `N8N_ENV_FEAT_OAUTH2_JWE`                                 | Boolean                      | `false`                                                          | Set to `true` on all instances (main and workers) to enable [JWE token decryption for OAuth 2.0 credentials](/deploy/host-n8n/configure-n8n/security/decrypt-oauth-20-tokens-with-jwe). Preview feature.                                                                                                                                                                                                                                                                                        |
| `N8N_ENV_FEAT_TOKEN_EXCHANGE`                             | Boolean                      | `false`                                                          | Set to `true` to enable [token exchange for embedding partners](/deploy/host-n8n/deploy-as-an-oem-integration/set-up-token-exchange). Preview feature.                                                                                                                                                                                                                                                                                                                                          |
| `N8N_OAUTH_JWE_JWKS_PER_MINUTE`                           | Number                       | `60`                                                             | Per-IP rate limit on the public JWKS endpoint (`/rest/.well-known/jwks.json`) used by [JWE token decryption for OAuth 2.0 credentials](/deploy/host-n8n/configure-n8n/security/decrypt-oauth-20-tokens-with-jwe).                                                                                                                                                                                                                                                                               |
| `N8N_MCP_BASE_URL`                                        | String                       | -                                                                | Public base URL where MCP clients reach the instance-level MCP server, when it differs from the instance base URL. Useful for deployments that serve the MCP server on a dedicated hostname (for example, `https://n8n-mcp.example.com` in front of the same instance). When set, n8n advertises the MCP server at this URL and accepts it during OAuth authentication, alongside the URL derived from the instance base URL. Doesn't affect editor or webhook URLs. Available from n8n 2.31.0. |
| `N8N_MCP_SERVER_RATE_LIMIT`                               | Number                       | `100`                                                            | Maximum number of requests per IP, per 5 minutes, to the MCP server endpoint (`/mcp-server/http`).                                                                                                                                                                                                                                                                                                                                                                                              |
| `N8N_OAUTH_SERVER_REGISTER_RATE_LIMIT`                    | Number                       | `10`                                                             | Maximum number of requests per IP, per 5 minutes, to the OAuth server client registration endpoint (`/oauth/register` and `/mcp-oauth/register`).                                                                                                                                                                                                                                                                                                                                               |
| `N8N_OAUTH_SERVER_AUTHORIZE_RATE_LIMIT`                   | Number                       | `50`                                                             | Maximum number of requests per IP, per 5 minutes, to the OAuth server authorization endpoint (`/oauth/authorize` and `/mcp-oauth/authorize`).                                                                                                                                                                                                                                                                                                                                                   |
| `N8N_OAUTH_SERVER_TOKEN_RATE_LIMIT`                       | Number                       | `20`                                                             | Maximum number of requests per IP, per 5 minutes, to the OAuth server token endpoint (`/oauth/token` and `/mcp-oauth/token`).                                                                                                                                                                                                                                                                                                                                                                   |
| `N8N_OAUTH_SERVER_REVOKE_RATE_LIMIT`                      | Number                       | `30`                                                             | Maximum number of requests per IP, per 5 minutes, to the OAuth server token revocation endpoint (`/oauth/revoke` and `/mcp-oauth/revoke`).                                                                                                                                                                                                                                                                                                                                                      |
| `N8N_USER_FOLDER`                                         | String                       | `user-folder`                                                    | Provide the path where n8n will create the `.n8n` folder. This directory stores user-specific data, such as database file and encryption key.                                                                                                                                                                                                                                                                                                                                                   |
| `N8N_PATH`                                                | String                       | `/`                                                              | The path n8n deploys to. Combining `N8N_PATH` with reverse proxies can cause folder navigation issues. Use a subdomain (for example, `n8n.example.com`) or use `N8N_PATH` without reverse proxy.                                                                                                                                                                                                                                                                                                |
| `N8N_HOST`                                                | String                       | `localhost`                                                      | Host name n8n runs on.                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `N8N_PORT`                                                | Number                       | `5678`                                                           | The HTTP port n8n runs on.                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `N8N_LISTEN_ADDRESS`                                      | String                       | `::`                                                             | The IP address n8n should listen on.                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `N8N_PROTOCOL`                                            | Enum string: `http`, `https` | `http`                                                           | The protocol used to reach n8n.                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `N8N_SSL_KEY`                                             | String                       | -                                                                | The SSL key for HTTPS protocol.                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `N8N_SSL_CERT`                                            | String                       | -                                                                | The SSL certificate for HTTPS protocol.                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `N8N_PERSONALIZATION_ENABLED`                             | Boolean                      | `true`                                                           | Whether to ask users personalisation questions and then customise n8n accordingly.                                                                                                                                                                                                                                                                                                                                                                                                              |
| `N8N_VERSION_NOTIFICATIONS_ENABLED`                       | Boolean                      | `true`                                                           | When enabled, n8n sends notifications of new versions and security updates.                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `N8N_VERSION_NOTIFICATIONS_ENDPOINT`                      | String                       | `https://api.n8n.io/versions/`                                   | The endpoint to retrieve where version information.                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `N8N_VERSION_NOTIFICATIONS_INFO_URL`                      | String                       | `https://docs.n8n.io/getting-started/installation/updating.html` | The URL displayed in the New Versions panel for more information.                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `N8N_DIAGNOSTICS_ENABLED`                                 | Boolean                      | `true`                                                           | Whether to share selected, anonymous [telemetry](https://docs.n8n.io/privacy-and-security/) with n8n. Note that if you set this to `false`, you can't enable Ask AI in the Code node.                                                                                                                                                                                                                                                                                                           |
| `N8N_DIAGNOSTICS_CONFIG_FRONTEND`                         | String                       | `1zPn9bgWPzlQc0p8Gj1uiK6DOTn;https://telemetry.n8n.io`           | Telemetry configuration for the frontend.                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `N8N_DIAGNOSTICS_CONFIG_BACKEND`                          | String                       | `1zPn7YoGC3ZXE9zLeTKLuQCB4F6;https://telemetry.n8n.io/v1/batch`  | Telemetry configuration for the backend.                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `N8N_PUSH_BACKEND`                                        | String                       | `websocket`                                                      | Choose whether the n8n backend uses server-sent events (`sse`) or WebSockets (`websocket`) to send changes to the UI.                                                                                                                                                                                                                                                                                                                                                                           |
| `VUE_APP_URL_BASE_API`                                    | String                       | `http://localhost:5678/`                                         | Used when building the `n8n-editor-ui` package manually to set how the frontend can reach the backend API. Refer to [Configure the Base URL](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/configure-the-base-url).                                                                                                                                                                                                                                                 |
| `N8N_HIRING_BANNER_ENABLED`                               | Boolean                      | `true`                                                           | Whether to show the n8n hiring banner in the console (true) or not (false).                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `N8N_PUBLIC_API_SWAGGERUI_DISABLED`                       | Boolean                      | `false`                                                          | Whether the Swagger UI (API playground) is disabled (true) or not (false).                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `N8N_PUBLIC_API_DISABLED`                                 | Boolean                      | `false`                                                          | Whether to disable the public API (true) or not (false).                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `N8N_PUBLIC_API_ENDPOINT`                                 | String                       | `api`                                                            | Path for the public API endpoints.                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `N8N_PUBLIC_API_RATE_LIMIT_ENABLED`                       | Boolean                      | `false`                                                          | Whether n8n limits how many public API requests each API key can make. A request over a limit gets a `429` response. n8n counts only requests that use an API key. Each `N8N_PUBLIC_API_RATE_LIMIT_*` variable you set overrides its own field in **Settings** > **Policies**, and you can't change that field there. Refer to [API rate limits](https://app.gitbook.com/s/r7wKI4I1BgdBCuq5Cvcx/n8n-api/rate-limits).                                                                           |
| `N8N_PUBLIC_API_RATE_LIMIT_GLOBAL_READ_LIMIT`             | Number                       | `1200`                                                           | Maximum number of read requests (`GET`) that one API key can make to all public API endpoints together in each window. Set to `0` for no limit.                                                                                                                                                                                                                                                                                                                                                 |
| `N8N_PUBLIC_API_RATE_LIMIT_GLOBAL_READ_WINDOW_SECONDS`    | Number                       | `60`                                                             | Length of the window for `N8N_PUBLIC_API_RATE_LIMIT_GLOBAL_READ_LIMIT`, in seconds. The count starts again when the window ends.                                                                                                                                                                                                                                                                                                                                                                |
| `N8N_PUBLIC_API_RATE_LIMIT_GLOBAL_WRITE_LIMIT`            | Number                       | `600`                                                            | Maximum number of write requests (`POST`, `PUT`, `PATCH`, and `DELETE`) that one API key can make to all public API endpoints together in each window. Set to `0` for no limit.                                                                                                                                                                                                                                                                                                                 |
| `N8N_PUBLIC_API_RATE_LIMIT_GLOBAL_WRITE_WINDOW_SECONDS`   | Number                       | `60`                                                             | Length of the window for `N8N_PUBLIC_API_RATE_LIMIT_GLOBAL_WRITE_LIMIT`, in seconds. The count starts again when the window ends.                                                                                                                                                                                                                                                                                                                                                               |
| `N8N_PUBLIC_API_RATE_LIMIT_ENDPOINT_READ_LIMIT`           | Number                       | `1000`                                                           | Maximum number of read requests (`GET`) that one API key can make to each public API endpoint in each window. An endpoint is a method and a path, so `GET /workflows/{id}` is one endpoint for every workflow ID. Set to `0` for no limit.                                                                                                                                                                                                                                                      |
| `N8N_PUBLIC_API_RATE_LIMIT_ENDPOINT_READ_WINDOW_SECONDS`  | Number                       | `60`                                                             | Length of the window for `N8N_PUBLIC_API_RATE_LIMIT_ENDPOINT_READ_LIMIT`, in seconds. The count starts again when the window ends.                                                                                                                                                                                                                                                                                                                                                              |
| `N8N_PUBLIC_API_RATE_LIMIT_ENDPOINT_WRITE_LIMIT`          | Number                       | `500`                                                            | Maximum number of write requests (`POST`, `PUT`, `PATCH`, and `DELETE`) that one API key can make to each public API endpoint in each window. An endpoint is a method and a path, so `DELETE /workflows/{id}` is one endpoint for every workflow ID. Set to `0` for no limit.                                                                                                                                                                                                                   |
| `N8N_PUBLIC_API_RATE_LIMIT_ENDPOINT_WRITE_WINDOW_SECONDS` | Number                       | `60`                                                             | Length of the window for `N8N_PUBLIC_API_RATE_LIMIT_ENDPOINT_WRITE_LIMIT`, in seconds. The count starts again when the window ends.                                                                                                                                                                                                                                                                                                                                                             |
| `N8N_GRACEFUL_SHUTDOWN_TIMEOUT`                           | Number                       | `30`                                                             | How long should the n8n process wait (in seconds) for components to shut down before exiting the process.                                                                                                                                                                                                                                                                                                                                                                                       |
| `N8N_DEV_RELOAD`                                          | Boolean                      | `false`                                                          | When working on the n8n source code, set this to `true` to automatically reload or restart the application when changes occur in the source code files.                                                                                                                                                                                                                                                                                                                                         |
| `N8N_REINSTALL_MISSING_PACKAGES`                          | Boolean                      | `false`                                                          | If set to `true`, n8n will automatically attempt to reinstall any missing packages.                                                                                                                                                                                                                                                                                                                                                                                                             |
| `N8N_TUNNEL_SUBDOMAIN`                                    | String                       | -                                                                | Specifies the subdomain for the n8n tunnel. If not set, n8n generates a random subdomain.                                                                                                                                                                                                                                                                                                                                                                                                       |
| `N8N_PROXY_HOPS`                                          | Number                       | 0                                                                | Number of reverse-proxies n8n is running behind.                                                                                                                                                                                                                                                                                                                                                                                                                                                |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)

[^1]: n8n templates are pre-built workflows designed by n8n and community members that you can import into your n8n instance. When using templates, you may need to fill in credentials and adjust the configuration to suit your needs.


# Endpoints

Customize the application's API and webhook endpoints with environment variables for your self-hosted n8n instance.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

This page lists environment variables for customizing endpoints in n8n.

| Variable                                        | Type    | Default           | Description                                                                                                                                                                                                                                                                                                                                                                     |
| ----------------------------------------------- | ------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_PAYLOAD_SIZE_MAX`                          | Number  | `16`              | The maximum payload size in MiB. The default is 16 MiB, but this can be increased by adjusting the variable to a higher value. The n8n instance needs to be restarted to apply the new setting. Note: Increasing the payload size requires more memory and CPU resources and may impact performance. Ensure your infrastructure can handle larger payloads.                     |
| `N8N_FORMDATA_FILE_SIZE_MAX`                    | Number  | `200`             | Max payload size for files in form-data webhook payloads in MiB.                                                                                                                                                                                                                                                                                                                |
| `N8N_METRICS`                                   | Boolean | `false`           | Whether to enable the `/metrics` endpoint.                                                                                                                                                                                                                                                                                                                                      |
| `N8N_METRICS_PREFIX`                            | String  | `n8n_`            | Optional prefix for n8n specific metrics names.                                                                                                                                                                                                                                                                                                                                 |
| `N8N_METRICS_INCLUDE_DEFAULT_METRICS`           | Boolean | `true`            | Whether to expose default system and node.js metrics.                                                                                                                                                                                                                                                                                                                           |
| `N8N_METRICS_INCLUDE_CACHE_METRICS`             | Boolean | false             | Whether to include metrics (true) for cache hits and misses, or not include them (false).                                                                                                                                                                                                                                                                                       |
| `N8N_METRICS_INCLUDE_MESSAGE_EVENT_BUS_METRICS` | Boolean | `false`           | Whether to include metrics (true) for events, or not include them (false).                                                                                                                                                                                                                                                                                                      |
| `N8N_METRICS_INCLUDE_WORKFLOW_ID_LABEL`         | Boolean | `false`           | Whether to include a label for the workflow ID on workflow metrics.                                                                                                                                                                                                                                                                                                             |
| `N8N_METRICS_INCLUDE_NODE_TYPE_LABEL`           | Boolean | `false`           | Whether to include a label for the node type on node metrics.                                                                                                                                                                                                                                                                                                                   |
| `N8N_METRICS_INCLUDE_CREDENTIAL_TYPE_LABEL`     | Boolean | `false`           | Whether to include a label for the credential type on credential metrics.                                                                                                                                                                                                                                                                                                       |
| `N8N_METRICS_INCLUDE_API_ENDPOINTS`             | Boolean | `false`           | Whether to expose metrics for API endpoints.                                                                                                                                                                                                                                                                                                                                    |
| `N8N_METRICS_INCLUDE_API_PATH_LABEL`            | Boolean | `false`           | Whether to include a label for the path of API invocations.                                                                                                                                                                                                                                                                                                                     |
| `N8N_METRICS_INCLUDE_API_METHOD_LABEL`          | Boolean | `false`           | Whether to include a label for the HTTP method (GET, POST, ...) of API invocations.                                                                                                                                                                                                                                                                                             |
| `N8N_METRICS_INCLUDE_API_STATUS_CODE_LABEL`     | Boolean | `false`           | Whether to include a label for the HTTP status code (200, 404, ...) of API invocations.                                                                                                                                                                                                                                                                                         |
| `N8N_METRICS_INCLUDE_QUEUE_METRICS`             | Boolean | `false`           | Whether to include metrics for jobs in scaling mode.                                                                                                                                                                                                                                                                                                                            |
| `N8N_METRICS_QUEUE_METRICS_INTERVAL`            | Integer | `20`              | How often (in seconds) to update queue metrics.                                                                                                                                                                                                                                                                                                                                 |
| `N8N_METRICS_INCLUDE_SCHEDULER_METRICS`         | Boolean | `false`           | Whether to include metrics for the durable scheduler, such as queue depth, scheduling lag, dispatch throughput, retries, and dead-letters. Main instances only. For what each metric means, see [Durable scheduler observability](/deploy/host-n8n/configure-n8n/durable-scheduler#observability).                                                                              |
| `N8N_METRICS_SCHEDULER_INTERVAL`                | Integer | `20`              | How often (in seconds) to refresh the queue-health gauges for the durable scheduler. See [Durable scheduler observability](/deploy/host-n8n/configure-n8n/durable-scheduler#observability).                                                                                                                                                                                     |
| `N8N_METRICS_INCLUDE_POLL_TRIGGER_METRICS`      | Boolean | `false`           | Whether to include metrics for trigger nodes that poll, such as poll duration, poll errors, overlapping polls, and cursor commits. Main instances only. For what each metric means, see [Poll trigger metrics](/deploy/host-n8n/configure-n8n/durable-scheduler#poll-trigger-metrics).                                                                                          |
| `N8N_METRICS_INCLUDE_SYSTEM_TASK_METRICS`       | Boolean | `false`           | Whether to include metrics for n8n's internal maintenance tasks, such as run duration, last success, skipped occurrences, and timer lag. Main instances only. For what each metric means, see [System task observability](/deploy/host-n8n/configure-n8n/system-tasks#observability).                                                                                           |
| `N8N_METRICS_INCLUDE_SSRF_METRICS`              | Boolean | `false`           | Whether to include metrics for SSRF protection checks.                                                                                                                                                                                                                                                                                                                          |
| `N8N_METRICS_INCLUDE_DNS_CACHE_METRICS`         | Boolean | `false`           | Whether to include metrics for the DNS cache (currently only used by SSRF protection).                                                                                                                                                                                                                                                                                          |
| `N8N_ENDPOINT_REST`                             | String  | `rest`            | The path used for REST endpoint.                                                                                                                                                                                                                                                                                                                                                |
| `N8N_ENDPOINT_WEBHOOK`                          | String  | `webhook`         | The path used for webhook endpoint.                                                                                                                                                                                                                                                                                                                                             |
| `N8N_ENDPOINT_WEBHOOK_TEST`                     | String  | `webhook-test`    | The path used for test-webhook endpoint.                                                                                                                                                                                                                                                                                                                                        |
| `N8N_ENDPOINT_WEBHOOK_WAIT`                     | String  | `webhook-waiting` | The path used for waiting-webhook endpoint.                                                                                                                                                                                                                                                                                                                                     |
| `N8N_ENDPOINT_FORM`                             | String  | `form`            | The path used for the form endpoint.                                                                                                                                                                                                                                                                                                                                            |
| `N8N_ENDPOINT_FORM_TEST`                        | String  | `form-test`       | The path used for the test-form endpoint.                                                                                                                                                                                                                                                                                                                                       |
| `N8N_ENDPOINT_FORM_WAIT`                        | String  | `form-waiting`    | The path used for the waiting-form endpoint.                                                                                                                                                                                                                                                                                                                                    |
| `N8N_ENDPOINT_HEALTH`                           | String  | `healthz`         | The path used for health check endpoint.                                                                                                                                                                                                                                                                                                                                        |
| `N8N_WEBHOOK_URL`                               | String  | -                 | Sets the base URL for both test and production webhooks when running n8n behind a reverse proxy. Use this instead of the `N8N_ENDPOINT_*` variables above, which set only the endpoint *path*, not a URL. See [Configure webhook URLs with reverse proxy](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/configure-webhook-urls-with-reverse-proxy). |
| `WEBHOOK_URL`                                   | String  | -                 | Deprecated from n8n 2.35.0; alias of `N8N_WEBHOOK_URL`. Still works, but n8n logs a deprecation warning on startup.                                                                                                                                                                                                                                                             |
| `N8N_DISABLE_PRODUCTION_MAIN_PROCESS`           | Boolean | `false`           | Disable production webhooks from main process. This helps ensure no HTTP traffic load to main process when using webhook-specific processes.                                                                                                                                                                                                                                    |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Executions

Environment variables to configure settings related to workflow executions.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

This page lists environment variables to configure workflow execution settings.

| Variable                                            | Type                                                 | Default                   | Description                                                                                                                                                                                                                                                                                                                                                                                                   |
| --------------------------------------------------- | ---------------------------------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `EXECUTIONS_MODE`                                   | Enum string: `regular`, `queue`                      | `regular`                 | <p>Whether executions should run directly or using queue.<br><br>Refer to <a href="/deploy/host-n8n/configure-n8n/scaling/enable-queue-mode">Queue mode</a> for more details.</p>                                                                                                                                                                                                                             |
| `EXECUTIONS_TIMEOUT`                                | Number                                               | `-1`                      | Sets a default timeout (in seconds) to all workflows after which n8n stops their execution. Users can override this for individual workflows up to the duration set in `EXECUTIONS_TIMEOUT_MAX`. Set `EXECUTIONS_TIMEOUT` to `-1` to disable.                                                                                                                                                                 |
| `EXECUTIONS_TIMEOUT_MAX`                            | Number                                               | `3600`                    | The maximum execution time (in seconds) that users can set for an individual workflow.                                                                                                                                                                                                                                                                                                                        |
| `N8N_AI_TIMEOUT_MAX`                                | Number                                               | `3600000`                 | Sets the HTTP request timeout in milliseconds for AI and LLM nodes (such as OpenAI, Anthropic, Mistral, and Ollama). This controls how long n8n waits for responses from AI services before timing out. Useful for slower local AI services or complex prompts that require longer processing time.                                                                                                           |
| `EXECUTIONS_DATA_SAVE_ON_ERROR`                     | Enum string: `all`, `none`                           | `all`                     | Whether n8n saves execution data on error.                                                                                                                                                                                                                                                                                                                                                                    |
| `EXECUTIONS_DATA_SAVE_ON_SUCCESS`                   | Enum string: `all`, `none`                           | `all`                     | Whether n8n saves execution data on success.                                                                                                                                                                                                                                                                                                                                                                  |
| `EXECUTIONS_DATA_SAVE_ON_PROGRESS`                  | Boolean                                              | `false`                   | Whether to save progress for each node executed (true) or not (false).                                                                                                                                                                                                                                                                                                                                        |
| `EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS`            | Boolean                                              | `true`                    | Whether to save data of executions when started manually.                                                                                                                                                                                                                                                                                                                                                     |
| `N8N_EXECUTION_DATA_STORAGE_MODE`                   | Enum string: `database`, `filesystem`, `s3`, `azure` | `database`                | Where n8n stores execution data. The `s3` and `azure` modes require a self-hosted Business or Enterprise plan. Refer to [External data storage](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/external-data-storage) for the related storage variables.                                                                                                                        |
| `N8N_STORAGE_PATH`                                  | String                                               | `N8N_USER_FOLDER/storage` | Base path for filesystem storage. When `N8N_EXECUTION_DATA_STORAGE_MODE` is `filesystem`, n8n stores execution data here. n8n also uses this path for filesystem binary data.                                                                                                                                                                                                                                 |
| `EXECUTIONS_DATA_PRUNE`                             | Boolean                                              | `true`                    | Whether to delete data of past executions on a rolling basis.                                                                                                                                                                                                                                                                                                                                                 |
| `EXECUTIONS_DATA_MAX_AGE`                           | Number                                               | `336`                     | The execution age (in hours) before it's deleted.                                                                                                                                                                                                                                                                                                                                                             |
| `EXECUTIONS_DATA_PRUNE_MAX_COUNT`                   | Number                                               | `10000`                   | Maximum number of executions to keep in the database. 0 = no limit                                                                                                                                                                                                                                                                                                                                            |
| `EXECUTIONS_DATA_HARD_DELETE_BUFFER`                | Number                                               | `1`                       | How old (hours) the finished execution data has to be to get hard-deleted. By default, this buffer excludes recent executions as the user may need them while building a workflow.                                                                                                                                                                                                                            |
| `EXECUTIONS_DATA_PRUNE_HARD_DELETE_INTERVAL`        | Number                                               | `15`                      | How often (minutes) execution data should be hard-deleted.                                                                                                                                                                                                                                                                                                                                                    |
| `EXECUTIONS_DATA_PRUNE_SOFT_DELETE_INTERVAL`        | Number                                               | `60`                      | How often (minutes) execution data should be soft-deleted.                                                                                                                                                                                                                                                                                                                                                    |
| `EXECUTIONS_DATA_MAX_DISPLAY_SIZE`                  | Number                                               | `104857600`               | Maximum size (in bytes) of execution data that n8n loads when displaying an execution (editor, execution detail, and public API). For larger executions, n8n omits the data (shown as "too large to display") to avoid running low-resource instances out of memory. Doesn't affect retrying or resuming executions, which always load the full data. Set to `0` to disable the limit.                        |
| `N8N_CONCURRENCY_PRODUCTION_LIMIT`                  | Number                                               | `-1`                      | Max production executions allowed to run concurrently, in both regular and scaling modes. `-1` to disable in regular mode.                                                                                                                                                                                                                                                                                    |
| `N8N_CONCURRENCY_EVALUATION_LIMIT`                  | Number                                               | License-tier default      | Max test cases that can run in parallel within a single [evaluation](/build/integrate-ai/test-and-improve-ai-workflows/use-metrics-to-measure-quality#run-test-cases-in-parallel) test run. When unset, the limit follows the license tier: self-hosted Community: 1, n8n Cloud Pro: 1, self-hosted Business: 3, n8n Cloud Enterprise and self-hosted Enterprise: 5. Setting this overrides the tier default. |
| `N8N_WORKFLOW_AUTODEACTIVATION_ENABLED`             | Boolean                                              | `false`                   | Whether workflows are automatically unpublished after repeated crashed executions.                                                                                                                                                                                                                                                                                                                            |
| `N8N_WORKFLOW_AUTODEACTIVATION_MAX_LAST_EXECUTIONS` | Number                                               | `3`                       | Number of crashed executions before unpublishing a workflow.                                                                                                                                                                                                                                                                                                                                                  |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Expression engine

Choose the expression engines for the n8n backend and editor, and configure the sandbox pool for your self-hosted n8n instance.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

[Expressions](/build/work-with-data/expressions-versus-data-nodes) are the JavaScript snippets n8n evaluates at runtime to set node parameters dynamically. The expression engine is the component that runs that evaluation. This page lists environment variables for configuring it.

{% hint style="warning" %}
**Avoid the `legacy` expression engine**

The `legacy` engine runs expressions without isolation, so it gives less protection against malicious expressions than the sandboxed engines. n8n plans to deprecate `legacy` in a future release. For the strongest security posture:

* Keep `N8N_EXPRESSION_ENGINE` set to `vm`, the backend default.
* Set `N8N_EXPRESSION_ENGINE_FRONTEND` to `quickjs`. The editor still uses `legacy` by default.
  {% endhint %}

## Choose the expression engine

n8n evaluates expressions in two places, and each has its own engine setting:

* **Backend:** the n8n server evaluates expressions when a workflow runs. `N8N_EXPRESSION_ENGINE` selects this engine.
* **Editor:** your browser evaluates expressions while you build a workflow, for example to preview an expression's result. `N8N_EXPRESSION_ENGINE_FRONTEND` selects this engine.

The two settings are independent.

| Variable                         | Type                                   | Default  | Description                                                                                                                                                                                                                                                                                                      |
| -------------------------------- | -------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_EXPRESSION_ENGINE`          | Enum string: `vm`, `quickjs`, `legacy` | `vm`     | Which expression engine the backend uses. `vm` runs expressions in a sandboxed V8 isolate. `quickjs` runs them in a QuickJS sandbox compiled to WebAssembly. `legacy` runs them without isolation, and n8n plans to deprecate it. `vm` is the default from n8n 2.35.0. Earlier n8n versions default to `legacy`. |
| `N8N_EXPRESSION_ENGINE_FRONTEND` | Enum string: `legacy`, `quickjs`       | `legacy` | Which expression engine the editor uses in the browser. `quickjs` runs expressions in a QuickJS sandbox compiled to WebAssembly, isolated from the rest of the page. `legacy` runs them without isolation. n8n strongly recommends `quickjs`. Available from n8n 2.41.0.                                         |

## Configure the sandboxed backend engines

These variables configure the backend `vm` and `quickjs` engines. They have no effect when `N8N_EXPRESSION_ENGINE` is `legacy`, and they don't affect the editor's engine.

| Variable                                    | Type   | Default | Description                                                                              |
| ------------------------------------------- | ------ | ------- | ---------------------------------------------------------------------------------------- |
| `N8N_EXPRESSION_ENGINE_POOL_SIZE`           | Number | `1`     | Number of sandboxes kept warm in the pool.                                               |
| `N8N_EXPRESSION_ENGINE_MAX_CODE_CACHE_SIZE` | Number | `1024`  | Maximum number of compiled expressions to cache.                                         |
| `N8N_EXPRESSION_ENGINE_TIMEOUT`             | Number | `5000`  | Execution timeout in milliseconds for each expression evaluation.                        |
| `N8N_EXPRESSION_ENGINE_MEMORY_LIMIT`        | Number | `128`   | Memory limit in MiB for each sandbox.                                                    |
| `N8N_EXPRESSION_ENGINE_IDLE_TIMEOUT`        | Number | -       | If set, scales the pool to zero warm sandboxes after this many seconds with no activity. |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# External data storage

Environment variables to configure external data storage for your self-hosted n8n instance.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

Refer to [External storage](/deploy/host-n8n/configure-n8n/scaling/use-external-storage) for more information on using external storage for binary data and execution data.

| Variable                                   | Type    | Default | Description                                                                                                                                                                                                                                                                                     |
| ------------------------------------------ | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_EXTERNAL_STORAGE_S3_HOST`             | String  | -       | Host of the n8n bucket in S3-compatible external storage. For example, `s3.us-east-1.amazonaws.com`                                                                                                                                                                                             |
| `N8N_EXTERNAL_STORAGE_S3_BUCKET_NAME`      | String  | -       | Name of the n8n bucket in S3-compatible external storage.                                                                                                                                                                                                                                       |
| `N8N_EXTERNAL_STORAGE_S3_BUCKET_REGION`    | String  | -       | Region of the n8n bucket in S3-compatible external storage. For example, `us-east-1`                                                                                                                                                                                                            |
| `N8N_EXTERNAL_STORAGE_S3_ACCESS_KEY`       | String  | -       | Access key in S3-compatible external storage                                                                                                                                                                                                                                                    |
| `N8N_EXTERNAL_STORAGE_S3_ACCESS_SECRET`    | String  | -       | Access secret in S3-compatible external storage.                                                                                                                                                                                                                                                |
| `N8N_EXTERNAL_STORAGE_S3_AUTH_AUTO_DETECT` | Boolean | -       | Use automatic credential detection to authenticate S3 calls for external storage. This will ignore the access key and access secret and use the default [credential provider chain](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html#credchain). |

## Azure Blob Storage <a href="#azure-blob-storage" id="azure-blob-storage"></a>

{% hint style="info" %}
**Feature availability**

Storing execution data or binary data in Azure Blob Storage is available on:

* **Self-hosted:** Business, Enterprise

It isn't available on n8n Cloud. Add your [license key](/deploy/host-n8n/configure-n8n/manage-your-license) to unlock this feature.
{% endhint %}

To store execution data in Azure Blob Storage, set `N8N_EXECUTION_DATA_STORAGE_MODE` to `azure`. To store binary data in Azure Blob Storage, set `N8N_DEFAULT_BINARY_DATA_MODE` to `azure` (refer to [External storage](/deploy/host-n8n/configure-n8n/scaling/use-external-storage#storing-n8ns-binary-data-in-azure-blob-storage)). A single container can hold both. Configure the variables below; `N8N_EXTERNAL_STORAGE_AZURE_CONTAINER_NAME` is always required.

For authentication, choose one of these three options. n8n checks them in this order:

1. **Connection string**: set `N8N_EXTERNAL_STORAGE_AZURE_CONNECTION_STRING`. This takes precedence over the other options, so n8n ignores the account name, key, and auto-detect when you set it. It's the simplest option and works well for local testing with Azurite.
2. **Auto-detect**: set `N8N_EXTERNAL_STORAGE_AZURE_ACCOUNT_NAME` and set `N8N_EXTERNAL_STORAGE_AZURE_AUTH_AUTO_DETECT` to `true`. n8n authenticates through Azure's `DefaultAzureCredential` chain (managed identity, environment, or Azure CLI), so no key lives in your n8n configuration. Best for production on Azure.
3. **Account name and key**: set `N8N_EXTERNAL_STORAGE_AZURE_ACCOUNT_NAME` and `N8N_EXTERNAL_STORAGE_AZURE_ACCOUNT_KEY`.

Set `N8N_EXTERNAL_STORAGE_AZURE_ENDPOINT` only if you use a custom endpoint, such as Azurite or a sovereign cloud.

| Variable                                       | Type    | Default | Description                                                                                                                                              |
| ---------------------------------------------- | ------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_EXTERNAL_STORAGE_AZURE_CONNECTION_STRING` | String  | -       | Connection string for Azure Blob Storage. Takes precedence over the account name and key when set.                                                       |
| `N8N_EXTERNAL_STORAGE_AZURE_ACCOUNT_NAME`      | String  | -       | Storage account name. Use with an account key or managed identity.                                                                                       |
| `N8N_EXTERNAL_STORAGE_AZURE_ACCOUNT_KEY`       | String  | -       | Storage account key. Use with the account name.                                                                                                          |
| `N8N_EXTERNAL_STORAGE_AZURE_CONTAINER_NAME`    | String  | -       | Name of the blob container to store execution data and/or binary data in. Required for Azure Blob Storage.                                               |
| `N8N_EXTERNAL_STORAGE_AZURE_ENDPOINT`          | String  | -       | Custom blob endpoint, for example for Azurite or sovereign clouds.                                                                                       |
| `N8N_EXTERNAL_STORAGE_AZURE_AUTH_AUTO_DETECT`  | Boolean | `false` | Authenticate via `DefaultAzureCredential` (managed identity, environment, or Azure CLI) instead of an account key. Ignores the account key when enabled. |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# External hooks

Environment variables to integrate external hooks into your self-hosted n8n instance.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

You can define external hooks that n8n executes whenever a specific operation runs. Refer to [External hooks](/deploy/host-n8n/configure-n8n/external-hooks) for the full reference, including available hooks and file formatting.

| Variable                        | Type   | Default | Description                                                                                                                            |
| ------------------------------- | ------ | ------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `EXTERNAL_HOOK_FILES`           | String | -       | Files containing backend external hooks. Provide multiple files separated by the character defined in `EXTERNAL_HOOK_FILES_SEPARATOR`. |
| `EXTERNAL_HOOK_FILES_SEPARATOR` | String | `:`     | Separator character for `EXTERNAL_HOOK_FILES`. Use `;` on Windows to avoid conflicts with drive-letter paths like `C:\`.               |
| `EXTERNAL_FRONTEND_HOOKS_URLS`  | String | -       | URLs to files containing frontend external hooks. Provide multiple URLs as a colon-separated list ("`:`").                             |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# External secrets

Configure the update interval and the connect and refresh timeouts for external secrets in a self-hosted n8n instance.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

You can use an external secrets store to manage credentials for n8n. Refer to [External secrets](/administer/manage-credentials/use-external-secret-stores) for details.

| Variable                               | Type   | Default           | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| -------------------------------------- | ------ | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_EXTERNAL_SECRETS_UPDATE_INTERVAL` | Number | `300` (5 minutes) | How often (in seconds) to check for secret updates.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `N8N_EXTERNAL_SECRETS_CONNECT_TIMEOUT` | Number | `20`              | Maximum time (in seconds) n8n waits for a secrets vault to connect. If the vault doesn't answer in time, n8n marks it as errored, retries the connection in the background with increasing delays, and startup continues without its secrets. Available from n8n 2.41.0.                                                                                                                                                                                                                                                                                                                                                                       |
| `N8N_EXTERNAL_SECRETS_REFRESH_TIMEOUT` | Number | `20`              | Maximum time (in seconds) n8n waits for a secrets vault to deliver its secrets, at startup and on each update interval. If the fetch takes longer, n8n stops waiting and the fetch keeps running in the background. When it completes successfully, n8n stores the secrets. At startup, workflows that use secrets from that vault fail until the first fetch completes. On an update interval, the previously fetched secrets stay available. Increase this value for vaults with many secrets. For HashiCorp Vault and Infisical, n8n also cancels each single HTTP request after the larger of the two timeouts. Available from n8n 2.41.0. |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Insights

Configure insights metrics collection with environment variables for your self-hosted n8n instance.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

Insights gives instance owners and admins visibility into how workflows perform over time. Refer to [Insights](/administer/observe-and-log/track-usage-with-insights) for details.

{% hint style="warning" %}
**Storage and compaction thresholds**

`N8N_INSIGHTS_COMPACTION_HOURLY_TO_DAILY_THRESHOLD_DAYS` and `N8N_INSIGHTS_COMPACTION_DAILY_TO_WEEKLY_THRESHOLD_DAYS` set how many days n8n keeps high-resolution insights (metrics stored in one-hour buckets) before each compaction step (from the hour bucket to the day bucket, then from the day bucket to the week bucket). You configure those day counts on your instance.

Raising the values delays compaction. That adds more rows to `insights_by_period` and increases database usage. For how this relates to retention, see [Insights](/administer/observe-and-log/track-usage-with-insights#disable-or-configure-insights-metrics-collection).
{% endhint %}

If you encounter database load issues during compaction, tune how often compaction runs and how much work n8n does in each run:

* Decrease `N8N_INSIGHTS_COMPACTION_INTERVAL_MINUTES` to run compaction more often. This can reduce the amount of data that builds up between runs.
* Increase `N8N_INSIGHTS_COMPACTION_BATCH_DELAY_MILLISECONDS` to wait longer between batches.
* Decrease `N8N_INSIGHTS_COMPACTION_MAX_BATCHES_PER_RUN` to process fewer batches in each run.
* Decrease `N8N_INSIGHTS_COMPACTION_MAX_RUNTIME_SECONDS` to stop each run sooner.

These settings only control compaction workload and scheduling. They don't change retention or the age thresholds for each compaction step.

| Variable                                                 | Type   | Default | Description                                                                                                                                       |
| -------------------------------------------------------- | ------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_DISABLED_MODULES`                                   | String | -       | Set to `insights` to disable the feature and metrics collection for an instance.                                                                  |
| `N8N_INSIGHTS_COMPACTION_BATCH_SIZE`                     | Number | 500     | The number of raw insights data to compact in a single batch.                                                                                     |
| `N8N_INSIGHTS_COMPACTION_BATCH_DELAY_MILLISECONDS`       | Number | 100     | Delay in milliseconds between full compaction batches. Increase this to wait longer between batches. Set to `0` to skip the delay.                |
| `N8N_INSIGHTS_COMPACTION_DAILY_TO_WEEKLY_THRESHOLD_DAYS` | Number | 180     | Age in days after which n8n compacts daily insights rows to weekly.                                                                               |
| `N8N_INSIGHTS_COMPACTION_HOURLY_TO_DAILY_THRESHOLD_DAYS` | Number | 90      | Age in days after which n8n compacts hourly insights rows to daily.                                                                               |
| `N8N_INSIGHTS_COMPACTION_INTERVAL_MINUTES`               | Number | 60      | Interval (in minutes) at which compaction should run. Decrease this to run compaction more often and reduce how much data builds up between runs. |
| `N8N_INSIGHTS_COMPACTION_MAX_BATCHES_PER_RUN`            | Number | 1000    | Maximum number of compaction batches to process in one run. Decrease this to process fewer batches per run. Set to `0` to disable this limit.     |
| `N8N_INSIGHTS_COMPACTION_MAX_RUNTIME_SECONDS`            | Number | 300     | Maximum runtime in seconds for one compaction run. Decrease this to stop each run sooner. Set to `0` to disable this limit.                       |
| `N8N_INSIGHTS_FLUSH_BATCH_SIZE`                          | Number | 1000    | The maximum number of insights data to keep in the buffer before flushing.                                                                        |
| `N8N_INSIGHTS_FLUSH_INTERVAL_SECONDS`                    | Number | 30      | The interval (in seconds) at which n8n flushes insights data to the database.                                                                     |
| `N8N_INSIGHTS_MAX_AGE_DAYS`                              | Number | 365     | Number of days n8n keeps compacted insights data before pruning. The maximum value is 730 (two years).                                            |
| `N8N_INSIGHTS_PRUNE_CHECK_INTERVAL_HOURS`                | Number | 24      | How often (in hours) the instance checks for insights data older than the effective max age and deletes it.                                       |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Logs

Environment variables to configure logging and diagnostic data.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

This page lists environment variables to set up logging for debugging. Refer to [Logging in n8n](/deploy/host-n8n/keep-n8n-running/set-up-logging) for details.

## n8n logs <a href="#n8n-logs" id="n8n-logs"></a>

| Variable                        | Type                                                           | Default                             | Description                                                                                                                                                                                                                     |
| ------------------------------- | -------------------------------------------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_LOG_LEVEL`                 | Enum string: `info`, `warn`, `error`, `debug`                  | `info`                              | Log output level. Refer to [Log levels](/deploy/host-n8n/keep-n8n-running/set-up-logging#log-levels) for details.                                                                                                               |
| `N8N_LOG_OUTPUT`                | Enum string: `console`, `file`                                 | `console`                           | Where to output logs. Provide multiple values as a comma-separated list.                                                                                                                                                        |
| `N8N_LOG_FORMAT`                | Enum string: `text`, `json`                                    | `text`                              | The log format to use. `text` prints human readable messages. `json` prints one JSON object per line containing the message, level, timestamp, and all metadata. This is useful for production monitoring as well as debugging. |
| `N8N_LOG_CRON_ACTIVE_INTERVAL`  | Number                                                         | `0`                                 | Interval in minutes to log currently active cron jobs. Set to `0` to disable.                                                                                                                                                   |
| `N8N_LOG_FILE_COUNT_MAX`        | Number                                                         | `100`                               | Max number of log files to keep.                                                                                                                                                                                                |
| `N8N_LOG_FILE_SIZE_MAX`         | Number                                                         | `16`                                | Max size of each log file in MB.                                                                                                                                                                                                |
| `N8N_LOG_FILE_LOCATION`         | String                                                         | `<n8n-directory-path>/logs/n8n.log` | Log file location. Requires N8N\_LOG\_OUTPUT set to `file`.                                                                                                                                                                     |
| `DB_LOGGING_ENABLED`            | Boolean                                                        | `false`                             | Whether to enable database-specific logging.                                                                                                                                                                                    |
| `DB_LOGGING_OPTIONS`            | Enum string: `query`, `error`, `schema`, `warn`, `info`, `log` | `error`                             | Database log output level. To enable all logging, specify `all`. Refer to [TypeORM logging options](https://orkhan.gitbook.io/typeorm/docs/docs/advanced-topics/5-logging#logging-options)                                      |
| `DB_LOGGING_MAX_EXECUTION_TIME` | Number                                                         | `1000`                              | Maximum execution time (in milliseconds) before n8n logs a warning. Set to `0` to disable long running query warning.                                                                                                           |
| `CODE_ENABLE_STDOUT`            | Boolean                                                        | `false`                             | Set to `true` to send Code node logs from `console.log` or `print` to the process's stdout, only for production executions.                                                                                                     |
| `NO_COLOR`                      | any                                                            | `undefined`                         | Set to any value to output logs without ANSI colors. For more information, see the [no-color.org website](https://no-color.org/).                                                                                               |

## Log streaming <a href="#log-streaming" id="log-streaming"></a>

Refer to [Log streaming](/administer/observe-and-log/stream-logs-to-external-systems) for more information on this feature.

| Variable                                         | Type    | Default       | Description                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ------------------------------------------------ | ------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `N8N_EVENTBUS_CHECKUNSENTINTERVAL`               | Number  | `0`           | How often (in milliseconds) to check for unsent event messages. Can in rare cases send message twice. Set to `0` to disable it.                                                                                                                                                                                                                                                                                                                  |
| `N8N_EVENTBUS_LOGWRITER_SYNCFILEACCESS`          | Boolean | `false`       | Whether all file access happens synchronously within the thread (true) or not (false).                                                                                                                                                                                                                                                                                                                                                           |
| `N8N_EVENTBUS_LOGWRITER_KEEPLOGCOUNT`            | Number  | `3`           | Number of event log files to keep.                                                                                                                                                                                                                                                                                                                                                                                                               |
| `N8N_EVENTBUS_LOGWRITER_MAXFILESIZEINKB`         | Number  | `10240`       | Maximum size (in kilo-bytes) of an event log file before a new one starts.                                                                                                                                                                                                                                                                                                                                                                       |
| `N8N_EVENTBUS_LOGWRITER_LOGBASENAME`             | String  | `n8nEventLog` | Basename of the event log file. Ignored when `N8N_EVENTBUS_LOGWRITER_LOGFULLPATH` is set.                                                                                                                                                                                                                                                                                                                                                        |
| `N8N_EVENTBUS_LOGWRITER_LOGFULLPATH`             | String  | `''`          | Absolute path to the event log file. Must end in `.log`. When set, this path is used verbatim and overrides `N8N_EVENTBUS_LOGWRITER_LOGBASENAME` and the default per-process suffix. Use this to give each n8n process a unique event log path when multiple processes share a writable filesystem. Refer to [Per-process event log files](/administer/observe-and-log/stream-logs-to-external-systems#per-process-event-log-files) for details. |
| `N8N_EVENTBUS_LOGWRITER_MAXTOTALMESSAGESPERFILE` | Number  | `500000`      | Maximum number of lines parsed from a single event log file during recovery. Bounds memory use when an event log file contains many invalid lines.                                                                                                                                                                                                                                                                                               |

### Manage log streaming destinations from environment variables <a href="#manage-log-streaming-destinations-from-environment-variables" id="manage-log-streaming-destinations-from-environment-variables"></a>

Set `N8N_LOG_STREAMING_MANAGED_BY_ENV` to `true` to manage log streaming destinations from environment variables. See [Manage instance settings using environment variables](/deploy/host-n8n/configure-n8n/manage-settings-using-environment-variables) for how the activation pattern works, and [Configure log streaming destinations using environment variables](/administer/observe-and-log/stream-logs-to-external-systems#configure-using-environment-variables) for the per-destination JSON shape.

| Variable                           | Type        | Default | Description                                                                                                                                                                 |
| ---------------------------------- | ----------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_LOG_STREAMING_MANAGED_BY_ENV` | Boolean     | `false` | Set to `true` to manage log streaming from environment variables. When `true`, n8n applies the log streaming variables on every startup and locks the matching UI controls. |
| `N8N_LOG_STREAMING_DESTINATIONS`   | JSON string | -       | JSON array of log streaming destinations. Each destination is an object with a `type` of `webhook`, `syslog`, or `sentry`, plus the configuration for that type.            |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# License

Environment variables to configure license settings in n8n, including options to hide the usage page, manage license activation and auto-renewal settings, and specify the server URL for license retrie

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

To enable certain licensed features, you must first activate your license. You can do this either through the UI or by setting environment variables. For more information, see [license key](/deploy/host-n8n/configure-n8n/manage-your-license).

| Variable                                  | Type    | Default                        | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ----------------------------------------- | ------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_HIDE_USAGE_PAGE`                     | boolean | `false`                        | Hide the **Plan & usage** page in the app.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `N8N_LICENSE_ACTIVATION_KEY`              | String  | `''`                           | Activation key to initialize license. Not applicable if the n8n instance was already activated.                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `N8N_LICENSE_AUTO_RENEW_ENABLED`          | Boolean | `true`                         | <p>Enables (true) or disables (false) autorenewal for licenses.<br>If disabled, you need to manually renew the license every 10 days by navigating to <strong>Settings</strong> > <strong>Plan & usage</strong>, and pressing <code>F5</code>. Failure to renew the license will disable all licensed features.</p>                                                                                                                                                                                                           |
| `N8N_LICENSE_CERT`                        | String  | `''`                           | Base64-encoded license certificate provided by n8n. Used instead of `N8N_LICENSE_ACTIVATION_KEY` for special use cases, e.g. air-gapped environments.                                                                                                                                                                                                                                                                                                                                                                         |
| `N8N_LICENSE_DETACH_FLOATING_ON_SHUTDOWN` | Boolean | `true`                         | <p>Controls whether the instance releases <a href="/key-concept-glossary#entitlement-n8n">floating entitlements</a> back to the pool upon shutdown. Set to <code>true</code> to allow other instances to reuse the entitlements, or <code>false</code> to retain them.<br>For production instances that must always keep their licensed features, set this to <code>false</code>.<br>Ignored when multi-main mode is enabled: all main instances share one seat, and a main instance that shuts down does not release it.</p> |
| `N8N_LICENSE_SERVER_URL`                  | String  | `https://license.n8n.io/v1`    | Server URL to retrieve license.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `N8N_LICENSE_TENANT_ID`                   | Number  | `1`                            | Tenant ID associated with the license. Only set this variable if explicitly instructed by n8n.                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `https_proxy_license_server`              | String  | `https://user:pass@proxy:port` | Proxy server URL for HTTPS requests to retrieve license. This variable name needs to be lowercase.                                                                                                                                                                                                                                                                                                                                                                                                                            |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Nodes

Environment variables to configure nodes management and node-specific limits in self-hosted n8n.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

This page lists the environment variables configuration options for managing nodes[^1] in n8n, including specifying which nodes to load or exclude, importing built-in or external modules in the Code node, enabling community nodes, and configuring node-specific limits.

## Nodes and community node settings <a href="#nodes-and-community-node-settings" id="nodes-and-community-node-settings"></a>

| Variable                                  | Type             | Default                                                                    | Description                                                                                                                                                                                                                                                                    |
| ----------------------------------------- | ---------------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `N8N_COMMUNITY_PACKAGES_AUTH_TOKEN`       | String           | -                                                                          | Authentication token for a private npm registry. Use with `N8N_COMMUNITY_PACKAGES_REGISTRY` to authenticate requests when installing community nodes from a private registry.                                                                                                  |
| `N8N_COMMUNITY_PACKAGES_ENABLED`          | Boolean          | `true`                                                                     | Enables (true) or disables (false) the functionality to install and load community nodes. If set to false, neither verified nor unverified community packages will be available, regardless of their individual settings.                                                      |
| `N8N_COMMUNITY_PACKAGES_PREVENT_LOADING`  | Boolean          | `false`                                                                    | Prevents (true) or allows (false) loading installed community nodes on instance startup. Use this if a faulty node prevents the instance from starting.                                                                                                                        |
| `N8N_COMMUNITY_PACKAGES_REGISTRY`         | String           | `https://registry.npmjs.org`                                               | NPM registry URL to pull community packages from (license required).                                                                                                                                                                                                           |
| `N8N_CUSTOM_EXTENSIONS`                   | String           | -                                                                          | Specify the path to directories containing your custom nodes.                                                                                                                                                                                                                  |
| `N8N_PYTHON_ENABLED`                      | Boolean          | `true`                                                                     | Whether to enable Python execution on the Code node.                                                                                                                                                                                                                           |
| `N8N_UNVERIFIED_PACKAGES_ENABLED`         | Boolean          | `true`                                                                     | When `N8N_COMMUNITY_PACKAGES_ENABLED` is true, this variable controls whether to enable the installation and use of unverified community nodes from an NPM registry (true) or not (false).                                                                                     |
| `N8N_VERIFIED_PACKAGES_ENABLED`           | Boolean          | `true`                                                                     | When `N8N_COMMUNITY_PACKAGES_ENABLED` is true, this variable controls whether to show verified community nodes in the nodes panel for installation and use (true) or to hide them (false).                                                                                     |
| `NODE_FUNCTION_ALLOW_BUILTIN`             | String           | -                                                                          | Permit users to import specific built-in modules in the Code node. Use \* to allow all. n8n disables importing modules by default.                                                                                                                                             |
| `NODE_FUNCTION_ALLOW_EXTERNAL`            | String           | -                                                                          | Permit users to import specific external modules (from `n8n/node_modules`) in the Code node. n8n disables importing modules by default.                                                                                                                                        |
| `NODES_ERROR_TRIGGER_TYPE`                | String           | `n8n-nodes-base.errorTrigger`                                              | Specify which node type to use as Error Trigger.                                                                                                                                                                                                                               |
| `NODES_EXCLUDE`                           | Array of strings | `[\"n8n-nodes-base.executeCommand\", \"n8n-nodes-base.localFileTrigger\"]` | Specify which nodes not to load. For example, to block nodes that can be a security risk if users aren't trustworthy: `NODES_EXCLUDE: "[\"n8n-nodes-base.executeCommand\", \"@n8n/n8n-nodes-langchain.lmChatDeepSeek\"]"`. To enable all nodes, specify `NODES_EXCLUDE: "[]"`. |
| `NODES_INCLUDE`                           | Array of strings | -                                                                          | Specify which nodes to load.                                                                                                                                                                                                                                                   |
| `NODES_MERGE_SQL_SANDBOX_MEMORY_LIMIT_MB` | Number           | `64`                                                                       | Memory limit in MB for the Merge node's SQL sandbox. Increase this if Combine by SQL fails with large datasets and your instance has enough memory available.                                                                                                                  |

## Compression node settings <a href="#compression-node-settings" id="compression-node-settings"></a>

| Variable                                           | Type   | Default     | Description                                                          |
| -------------------------------------------------- | ------ | ----------- | -------------------------------------------------------------------- |
| `N8N_COMPRESSION_NODE_MAX_DECOMPRESSED_SIZE_BYTES` | Number | `268435456` | Maximum total decompressed output size in bytes. Default is 256 MiB. |
| `N8N_COMPRESSION_NODE_MAX_ZIP_ENTRIES`             | Number | `1000`      | Maximum number of entries allowed in a ZIP archive.                  |

## Manage installed community packages <a href="#manage-installed-community-packages" id="manage-installed-community-packages"></a>

{% hint style="info" %}
**Feature availability**

Managing installed community packages from environment variables is available from n8n 2.21.0.
{% endhint %}

Pre-provision installed [community packages](/integrations/community-nodes/installation-and-management) from environment variables. See [Manage instance settings using environment variables](/deploy/host-n8n/configure-n8n/manage-settings-using-environment-variables) for the `*_MANAGED_BY_ENV` pattern.

| Variable                                | Type        | Default | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| --------------------------------------- | ----------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_COMMUNITY_PACKAGES_MANAGED_BY_ENV` | Boolean     | `false` | Set to `true` to manage installed community packages from environment variables. When `true`, n8n reconciles the installed packages against `N8N_COMMUNITY_PACKAGES` on every startup, installing missing packages, correcting versions, and **uninstalling any currently-installed packages that aren't in the list**. The **Community nodes** settings page becomes read-only: you can't install, update, or uninstall packages from the UI while this is enabled. |
| `N8N_COMMUNITY_PACKAGES`                | JSON string | -       | JSON array of community packages to install. Each entry is an object with a `name` (required) and optional `version` and `checksum` fields. You can also embed the version in the name as `<package-name>@<version>`. See [environment variable installation](/integrations/community-nodes/installation-and-management/environment-variable-installation) for the full per-field reference.                                                                         |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)

[^1]: In n8n, nodes are individual components that you compose to create workflows. Nodes define when the workflow should run, allow you to fetch, send, and process data, can define flow control logic, and connect with external services.


# OpenTelemetry

Configure OpenTelemetry tracing with environment variables for your self-hosted n8n instance.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

n8n can export workflow and node execution traces over OTLP to an OpenTelemetry collector. Refer to [OpenTelemetry tracing](/deploy/host-n8n/keep-n8n-running/trace-executions-with-opentelemetry) for details.

| Variable                                    | Type    | Default                 | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | Available from |
| ------------------------------------------- | ------- | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- |
| `N8N_OTEL_ENABLED`                          | Boolean | `false`                 | Whether to enable OpenTelemetry tracing. When set to `false`, n8n doesn't load the OpenTelemetry SDK.                                                                                                                                                                                                                                                                                                                                                                                     | 2.19.0         |
| `N8N_OTEL_EXPORTER_OTLP_ENDPOINT`           | String  | `http://localhost:4318` | Base URL of the OTLP endpoint to export traces to. The value must be an `http://` or `https://` URL. If it isn't, n8n logs a warning and uses the default. For `http/protobuf`, n8n appends the value of `N8N_OTEL_EXPORTER_OTLP_TRACING_PATH` to this URL.                                                                                                                                                                                                                               | 2.19.0         |
| `N8N_OTEL_EXPORTER_OTLP_PROTOCOL`           | String  | `http/protobuf`         | OTLP transport for exporting traces. Valid values: `http/protobuf` and `grpc`. The name and values match the upstream [`OTEL_EXPORTER_OTLP_PROTOCOL`](https://opentelemetry.io/docs/specs/otel/protocol/exporter/) specification. Refer to [Choose the OTLP protocol](/deploy/host-n8n/keep-n8n-running/trace-executions-with-opentelemetry#choose-the-otlp-protocol) for guidance.                                                                                                       | 2.39.0         |
| `N8N_OTEL_EXPORTER_OTLP_TRACING_PATH`       | String  | `/v1/traces`            | Path appended to `N8N_OTEL_EXPORTER_OTLP_ENDPOINT` for exporting traces. n8n ignores this variable when `N8N_OTEL_EXPORTER_OTLP_PROTOCOL` is `grpc`, because gRPC endpoints take no URL path.                                                                                                                                                                                                                                                                                             | 2.19.0         |
| `N8N_OTEL_EXPORTER_OTLP_HEADERS`            | String  | -                       | Comma-separated list of `key=value` pairs to send as HTTP headers with each OTLP request. Use this for authentication tokens or tenant headers. For example: `authorization=Bearer <token>,x-tenant=acme`. With the `grpc` protocol, n8n sends these as gRPC metadata and converts the keys to lowercase.                                                                                                                                                                                 | 2.19.0         |
| `N8N_OTEL_EXPORTER_SERVICE_NAME`            | String  | `n8n`                   | Value of the `service.name` resource attribute on exported spans.                                                                                                                                                                                                                                                                                                                                                                                                                         | 2.19.0         |
| `N8N_OTEL_TRACES_SAMPLE_RATE`               | Number  | `1.0`                   | Fraction of traces to export, between `0` and `1`. n8n uses a trace ID ratio sampler, so all spans in a trace are either sampled or dropped together.                                                                                                                                                                                                                                                                                                                                     | 2.19.0         |
| `N8N_OTEL_TRACES_INCLUDE_NODE_SPANS`        | Boolean | `true`                  | Whether to emit a `node.execute` span for each node execution. Set to `false` to export workflow-level spans only.                                                                                                                                                                                                                                                                                                                                                                        | 2.19.0         |
| `N8N_OTEL_TRACES_CUSTOM_ATTRIBUTE_PREFIXES` | String  | -                       | JSON object that changes or removes the prefix on custom span attribute keys, for example `{"project":"","node":""}`. Refer to [Change the attribute prefixes](/deploy/host-n8n/keep-n8n-running/trace-executions-with-opentelemetry#change-the-attribute-prefixes).                                                                                                                                                                                                                      | 2.46.0         |
| `N8N_OTEL_TRACES_EMIT_WORKFLOW_START_SPAN`  | Boolean | `false`                 | Whether to send a 0 ms `workflow.execute.started` span when a workflow execution starts. Refer to [Start spans](/deploy/host-n8n/keep-n8n-running/trace-executions-with-opentelemetry#start-spans).                                                                                                                                                                                                                                                                                       | 2.44.0         |
| `N8N_OTEL_TRACES_EMIT_NODE_START_SPAN`      | Boolean | `false`                 | Whether to send a 0 ms `node.execute.started` span when a node execution starts. Needs `N8N_OTEL_TRACES_INCLUDE_NODE_SPANS` set to `true`. Refer to [Start spans](/deploy/host-n8n/keep-n8n-running/trace-executions-with-opentelemetry#start-spans).                                                                                                                                                                                                                                     | 2.44.0         |
| `N8N_OTEL_TRACES_PRODUCTION_ONLY`           | Boolean | `true`                  | Whether to export traces for [production executions](/build/understand-workflows/understand-executions/types-of-executions) only. Set to `false` to export traces for all workflow executions.                                                                                                                                                                                                                                                                                            | 2.25.2         |
| `N8N_OTEL_TRACES_INJECT_OUTBOUND`           | Boolean | `true`                  | Whether n8n adds tracing headers to outbound HTTP requests made by nodes that use n8n's HTTP helpers. When `true`, n8n sends `traceparent`, `tracestate`, and `baggage` (from n8n 2.47.0). Use `OTEL_PROPAGATORS` to narrow the set. Refer to [Outbound trace headers](/deploy/host-n8n/keep-n8n-running/trace-executions-with-opentelemetry#outbound-trace-headers).                                                                                                                     | 2.19.0         |
| `OTEL_PROPAGATORS`                          | String  | `tracecontext,baggage`  | Comma-separated list naming which headers n8n writes while `N8N_OTEL_TRACES_INJECT_OUTBOUND` is `true`. Valid names: `tracecontext` (sends `traceparent` and `tracestate`), `baggage`, and `none`. Set it to `tracecontext` to stop n8n forwarding the caller's `baggage` entries downstream. n8n reads it once at startup, so a change needs a restart. Refer to [Outbound trace headers](/deploy/host-n8n/keep-n8n-running/trace-executions-with-opentelemetry#outbound-trace-headers). | 2.47.0         |
| `N8N_OTEL_STARTUP_CONNECTIVITY_TIMEOUT_MS`  | Number  | `2000`                  | Timeout (in milliseconds) for the startup connectivity check against the OTLP endpoint. n8n logs an error if the endpoint isn't reachable within this period.                                                                                                                                                                                                                                                                                                                             | 2.19.0         |
| `N8N_AGENTS_TRACING_ENABLED`                | Boolean | `true`                  | Whether agent runs emit OpenTelemetry spans. Inherits the endpoint, headers, sampling, and transport settings from `N8N_OTEL_*`. Spans have nowhere to go until you configure an OTel provider, so set this to `false` to run workflow tracing without agent spans.                                                                                                                                                                                                                       | 2.33.0         |
| `N8N_AGENTS_TRACING_RECORD_INPUTS`          | Boolean | `true`                  | Whether agent tracing records inputs, such as prompts and tool arguments. Set to `false` to exclude sensitive input data from traces.                                                                                                                                                                                                                                                                                                                                                     | 2.33.0         |
| `N8N_AGENTS_TRACING_RECORD_OUTPUTS`         | Boolean | `true`                  | Whether agent tracing records outputs, such as responses and tool results. Set to `false` to exclude sensitive output data from traces.                                                                                                                                                                                                                                                                                                                                                   | 2.33.0         |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Queue mode

Environment variables to configure queue mode on your self-hosted n8n instance.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

You can run n8n in different modes depending on your needs. Queue mode provides the best scalability. Refer to [Queue mode](/deploy/host-n8n/configure-n8n/scaling/enable-queue-mode) for more information.

| Variable                                          | Type    | Default     | Description                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ------------------------------------------------- | ------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `OFFLOAD_MANUAL_EXECUTIONS_TO_WORKERS`            | Boolean | `false`     | Set to `true` if you want manual executions to run on the worker rather than on main.                                                                                                                                                                                                                                                                                                                                                    |
| `QUEUE_BULL_PREFIX`                               | String  | -           | Prefix to use for all queue keys.                                                                                                                                                                                                                                                                                                                                                                                                        |
| `N8N_REDIS_KEY_PREFIX`                            | String  | `n8n`       | Prefix for Redis keys and pub/sub channels outside the job queue, such as the multi-main leader key, messages between main and worker instances, the cache, and locks. If two or more n8n deployments share one Redis, give each deployment a different value. Use the same value on every main and worker of a deployment. Before n8n 2.3.0, the prefix doesn't apply to pub/sub channels, so use a separate Redis for each deployment. |
| `N8N_CACHE_REDIS_KEY_PREFIX`                      | String  | `cache`     | Prefix for cache keys in Redis. n8n adds it after `N8N_REDIS_KEY_PREFIX`, for example `n8n:cache`.                                                                                                                                                                                                                                                                                                                                       |
| `QUEUE_BULL_REDIS_DB`                             | Number  | `0`         | The Redis database used.                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `QUEUE_BULL_REDIS_HOST`                           | String  | `localhost` | The Redis host.                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `QUEUE_BULL_REDIS_PORT`                           | Number  | `6379`      | The Redis port used.                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `QUEUE_BULL_REDIS_USERNAME`                       | String  | -           | The Redis username (needs Redis version 6 or above). Don't define it for Redis < 6 compatibility                                                                                                                                                                                                                                                                                                                                         |
| `QUEUE_BULL_REDIS_PASSWORD`                       | String  | -           | The Redis password.                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `QUEUE_BULL_REDIS_TIMEOUT_THRESHOLD`              | Number  | `10000`     | The Redis timeout threshold (in ms).                                                                                                                                                                                                                                                                                                                                                                                                     |
| `QUEUE_BULL_REDIS_CLUSTER_NODES`                  | String  | -           | Expects a comma-separated list of Redis Cluster nodes in the format `host:port`, for the Redis client to initially connect to. If running in queue mode (`EXECUTIONS_MODE = queue`), setting this variable will create a Redis Cluster client instead of a Redis client, and n8n will ignore `QUEUE_BULL_REDIS_HOST` and `QUEUE_BULL_REDIS_PORT`.                                                                                        |
| `QUEUE_BULL_REDIS_TLS`                            | Boolean | `false`     | Enable TLS on Redis connections.                                                                                                                                                                                                                                                                                                                                                                                                         |
| `QUEUE_BULL_REDIS_DUALSTACK`                      | Boolean | `false`     | Enable dual-stack support (IPv4 and IPv6) on Redis connections.                                                                                                                                                                                                                                                                                                                                                                          |
| `QUEUE_WORKER_TIMEOUT` (**deprecated**)           | Number  | `30`        | Deprecated from n8n 1.22.0. Use `N8N_GRACEFUL_SHUTDOWN_TIMEOUT` instead. How long should n8n wait (seconds) for running executions before exiting worker process on shutdown.                                                                                                                                                                                                                                                            |
| `QUEUE_HEALTH_CHECK_ACTIVE`                       | Boolean | `false`     | Whether to enable health checks (true) or disable (false).                                                                                                                                                                                                                                                                                                                                                                               |
| `QUEUE_HEALTH_CHECK_PORT`                         | Number  | `5678`      | The port to serve health checks on. If you experience a port conflict error when starting a worker server using its default port, change this.                                                                                                                                                                                                                                                                                           |
| `QUEUE_WORKER_LOCK_DURATION`                      | Number  | `60000`     | How long (in ms) is the lease period for a worker to work on a message.                                                                                                                                                                                                                                                                                                                                                                  |
| `QUEUE_WORKER_LOCK_RENEW_TIME`                    | Number  | `10000`     | How frequently (in ms) should a worker renew the lease time.                                                                                                                                                                                                                                                                                                                                                                             |
| `QUEUE_WORKER_STALLED_INTERVAL`                   | Number  | `30000`     | How often should a worker check for stalled jobs (use 0 for never).                                                                                                                                                                                                                                                                                                                                                                      |
| `QUEUE_WORKER_MAX_STALLED_COUNT` (**deprecated**) | Number  | `1`         | **Deprecated** Removed in n8n 2.0. Setting this has no effect. See [Remove QUEUE\_WORKER\_MAX\_STALLED\_COUNT](/changelog/v20-breaking-changes#remove-queueworkermaxstalledcount) for migration details.                                                                                                                                                                                                                                 |

## Webhook responses

In queue mode, a worker sends a webhook response back to the main instance inside a queue message. These variables set how large that message can be, and whether n8n stores a larger response body in binary data storage instead of failing the node. Refer to [Large webhook responses](/deploy/host-n8n/configure-n8n/scaling/enable-queue-mode#large-webhook-responses) for details.

| Variable                                     | Type    | Default | Description                                                                                                                                                                                                                                                                                                                                                                                                                    |
| -------------------------------------------- | ------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `N8N_WEBHOOK_RESPONSE_RELAY_SIZE_MAX`        | Number  | `64`    | Maximum size (in MiB) of a response a worker sends back to the main instance inside a queue message. Redis holds several copies of a response in flight, so budget about 1.5 times this value in Redis memory per response in flight. The same limit applies to a tool result an MCP Trigger workflow returns.                                                                                                                 |
| `N8N_WEBHOOK_RESPONSE_RELAY_OFFLOAD_ENABLED` | Boolean | `false` | Whether a worker stores a response body above `N8N_WEBHOOK_RESPONSE_RELAY_SIZE_MAX` in binary data storage, so the main instance can stream it to the client, instead of failing the node. Needs a `N8N_DEFAULT_BINARY_DATA_MODE` that stores (`filesystem`, `database`, `s3`, or `azure`), and storage every instance can read. Set this on your workers only after every main and webhook instance runs n8n 2.34.0 or later. |

## Multi-main setup <a href="#multi-main-setup" id="multi-main-setup"></a>

Refer to [Configuring multi-main setup](/deploy/host-n8n/configure-n8n/scaling/enable-queue-mode#configuring-multi-main-setup) for details.

| Variable                              | Type    | Default | Description                                                           |
| ------------------------------------- | ------- | ------- | --------------------------------------------------------------------- |
| `N8N_MULTI_MAIN_SETUP_ENABLED`        | Boolean | `false` | Whether to enable multi-main setup for queue mode (license required). |
| `N8N_MULTI_MAIN_SETUP_KEY_TTL`        | Number  | `10`    | Time to live (in seconds) for leader key in multi-main setup.         |
| `N8N_MULTI_MAIN_SETUP_CHECK_INTERVAL` | Number  | `3`     | Interval (in seconds) for leader check in multi-main setup.           |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Scheduler

Environment variables to configure the durable scheduler for your self-hosted n8n instance.

These environment variables configure the durable scheduler, which runs time-based workflows from a database-backed queue instead of from each instance's memory. It's on by default from n8n 2.45.0. For what it changes, how it works, and how to use the in-memory scheduler, see [Durable scheduler](/deploy/host-n8n/configure-n8n/durable-scheduler).

Turn on Prometheus metrics for the durable scheduler with `N8N_METRICS_INCLUDE_SCHEDULER_METRICS` and `N8N_METRICS_SCHEDULER_INTERVAL`, which live with the other metrics variables on the [Endpoints](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/endpoints) page. For what each metric means, see [Durable scheduler observability](/deploy/host-n8n/configure-n8n/durable-scheduler#observability).

{% hint style="info" %}
**Feature availability**

The durable scheduler is available from n8n 2.36.0. Earlier versions back to n8n 2.32.0 include it as a Preview feature.
{% endhint %}

## Enable the scheduler <a href="#enable-vars" id="enable-vars"></a>

| Variable                              | Type    | Default | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ------------------------------------- | ------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_SCHEDULER_ENABLED`               | Boolean | `true`  | Whether to use the durable scheduler. Defaults to `true` from n8n 2.45.0 (`false` in earlier versions). Set to `false` to use the in-memory scheduler. Requires `N8N_USE_WORKFLOW_PUBLICATION_SERVICE`, also on by default, to take over Schedule Trigger nodes. Deprecated from n8n 2.45.0: a future version will remove this variable and the in-memory scheduler.                                                                                                                                                                                |
| `N8N_SCHEDULER_POLL_TRIGGERS_ENABLED` | Boolean | `false` | Whether the durable scheduler also takes over polling triggers (trigger nodes with a Poll Times parameter). Requires `N8N_SCHEDULER_ENABLED` and `N8N_USE_WORKFLOW_PUBLICATION_SERVICE`. Available from n8n 2.33.0.                                                                                                                                                                                                                                                                                                                                 |
| `N8N_SCHEDULER_SYSTEM_TASKS_ENABLED`  | Boolean | `false` | Whether the durable scheduler runs n8n's internal maintenance jobs instead of the leader main's in-process timers. Requires `N8N_SCHEDULER_ENABLED`. Give every main the same value for both variables, and run the same n8n version on every main. A main with either flag off removes the durable schedules for these jobs at startup. Use it from n8n 2.45.0, the first version that runs every system task on the durable scheduler. See [System tasks](/deploy/host-n8n/configure-n8n/system-tasks#run-system-tasks-on-the-durable-scheduler). |

n8n 2.45.0 removes `N8N_ENV_FEAT_SKIP_DURABLE_SCHEDULER` and the **Skip Durable Scheduler** node setting. To use the in-memory scheduler for all Schedule Trigger nodes, set `N8N_SCHEDULER_ENABLED=false` and restart n8n. See [Use the in-memory scheduler](/deploy/host-n8n/configure-n8n/durable-scheduler#use-the-in-memory-scheduler).

{% hint style="warning" %}
Poll trigger support isn't 100% stable yet. Keep `N8N_SCHEDULER_POLL_TRIGGERS_ENABLED` off in production unless you're prepared to keep a close watch on your polling workflows: check their execution lists for gaps or duplicate runs, and turn on scheduler metrics to watch scheduling lag, retries, and dead-letters (see [Durable scheduler observability](/deploy/host-n8n/configure-n8n/durable-scheduler#observability)). This doesn't affect Schedule Trigger support, which is stable.
{% endhint %}

## Poll triggers

Controls trigger nodes with a **Poll Times** parameter (such as Google Sheets Trigger or Airtable Trigger): how they store their cursor, the node's record of how far it has already read, and how long a single poll may run. To route these nodes through the durable scheduler, turn on `N8N_SCHEDULER_POLL_TRIGGERS_ENABLED` (in the Enable the scheduler table). See [Poll triggers](/deploy/host-n8n/configure-n8n/durable-scheduler#poll-triggers).

| Variable                             | Type    | Default | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ------------------------------------ | ------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `N8N_POLLER_DURABLE_CURSORS_ENABLED` | Boolean | `false` | Whether n8n stores a poll trigger node's cursor in a dedicated database table and commits it in the same transaction as the execution the poll produced, so a crash mid-poll can't drop or duplicate data. Available from n8n 2.36.0. From n8n 2.37.0, requires `N8N_SCHEDULER_ENABLED`, `N8N_SCHEDULER_POLL_TRIGGERS_ENABLED`, and `N8N_USE_WORKFLOW_PUBLICATION_SERVICE`. See [Durable poll cursors](/deploy/host-n8n/configure-n8n/durable-scheduler#durable-poll-cursors).                                                                                                                                                 |
| `N8N_SCHEDULER_POLL_TIMEOUT`         | Number  | `45`    | How long, in seconds, a single poll may run before n8n abandons it. An abandoned poll records nothing: the cursor stays put and the next poll covers the same ground, so no data goes missing. A poll that keeps timing out counts as failing, so n8n re-polls it at a widening interval. Keep the timeout below `N8N_SCHEDULER_LEASE_DURATION`: the timeout clock only starts once the poll itself does, so a poll allowed the full lease can still be running when another instance takes its run over. n8n warns at startup when the timeout reaches the lease duration. Must be greater than 0. Available from n8n 2.37.0. |

## Materialization <a href="#materialization-vars" id="materialization-vars"></a>

Controls how far ahead and how often the scheduler records upcoming runs to the database.

| Variable                                 | Type   | Default | Description                                                                                                                                                                                               |
| ---------------------------------------- | ------ | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_SCHEDULER_MATERIALIZATION_WINDOW`   | Number | `60`    | How far into the future, in seconds, the scheduler records upcoming runs. A larger window commits more runs in advance (more resilient to downtime, slightly more storage churn). Must be greater than 0. |
| `N8N_SCHEDULER_MATERIALIZATION_INTERVAL` | Number | `10`    | How often, in seconds, the scheduler scans active schedules to record the runs falling within the window. Must be greater than 0.                                                                         |
| `N8N_SCHEDULER_MATERIALIZATION_TIMEOUT`  | Number | `60`    | How long, in seconds, a single scan may run before it's abandoned and retried on the next interval. Guards against a scan stuck on a slow database. Must be greater than 0.                               |

## Execution <a href="#execution-vars" id="execution-vars"></a>

Controls how often the scheduler starts due runs and how it claims each one so only one instance runs it.

| Variable                          | Type   | Default | Description                                                                                                                                                                                                                                                                                                                                                                                           |
| --------------------------------- | ------ | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_SCHEDULER_EXECUTOR_INTERVAL` | Number | `5`     | How often, in seconds, the scheduler checks for recorded runs coming due. Each check claims the runs due within the next interval and holds them on a precise timer, so a run starts at its scheduled instant rather than on the polling cadence. The interval caps how long the scheduler takes to pick up a newly activated or edited schedule. Must be greater than 0.                             |
| `N8N_SCHEDULER_EXECUTOR_TIMEOUT`  | Number | `60`    | How long, in seconds, a single check for due runs may run before it's abandoned and retried on the next interval. Must be greater than 0.                                                                                                                                                                                                                                                             |
| `N8N_SCHEDULER_LEASE_DURATION`    | Number | `60`    | How long, in seconds, an instance holds an exclusive claim on a run it picked up, so no other instance starts the same one. If the instance stops without finishing, the claim expires after this long and another instance may take over. Keep it comfortably above the time a run needs to get going: too short risks a double run, too long delays recovery after a crash. Must be greater than 0. |
| `N8N_SCHEDULER_CLAIM_BATCH_SIZE`  | Number | `100`   | The most runs a single claim takes from the queue in one pass. Larger batches drain a backlog faster but hold more work on one instance per tick. Must be greater than 0.                                                                                                                                                                                                                             |

## Recovery <a href="#recovery-vars" id="recovery-vars"></a>

Controls the reaper, which releases runs an instance claimed but never finished so another instance can take them.

| Variable                          | Type   | Default | Description                                                                                                                                                                                                                                                                               |
| --------------------------------- | ------ | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_SCHEDULER_REAPER_INTERVAL`   | Number | `30`    | How often, in seconds, the scheduler looks for runs an instance claimed but never finished (for example after a crash or shutdown) and makes them available again. Must be greater than 0.                                                                                                |
| `N8N_SCHEDULER_REAPER_BATCH_SIZE` | Number | `100`   | The most expired-claim runs a single reaper pass reclaims. Larger batches recover a backlog faster but hold more work on one instance per pass. Must be greater than 0.                                                                                                                   |
| `N8N_SCHEDULER_REAPER_TIMEOUT`    | Number | `60`    | How long, in seconds, a single recovery pass may run before it's abandoned and retried on the next interval. Must be greater than 0.                                                                                                                                                      |
| `N8N_SCHEDULER_MAX_ATTEMPTS`      | Number | `5`     | How many times a scheduled run may be reclaimed (for example after a crash) or retried on error before n8n gives up on it and dead-letters it. Raise it on infrastructure prone to instance restarts or transient errors; lower it to give up and move on sooner. Must be greater than 0. |

## Retention <a href="#retention-vars" id="retention-vars"></a>

Controls how long the scheduler keeps finished runs as history and how often it deletes old ones. n8n keeps failed and missed runs longer than clean ones so you have time to notice and debug a problem.

| Variable                           | Type   | Default  | Description                                                                                                                                                                                                                                                                        |
| ---------------------------------- | ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_SCHEDULER_RETENTION`          | Number | `86400`  | How long, in seconds, the scheduler keeps runs that finished cleanly (a success or a cancellation) before deleting them. Defaults to one day. Raise it to keep more history, lower it to reclaim database space sooner. Must be greater than 0.                                    |
| `N8N_SCHEDULER_FAILED_RETENTION`   | Number | `604800` | How long, in seconds, the scheduler keeps runs that went wrong (a failure, or a missed run) before deleting them. Defaults to seven days. Keep it longer than `N8N_SCHEDULER_RETENTION` so there's time to debug; the scheduler warns if you set it lower. Must be greater than 0. |
| `N8N_SCHEDULER_RETENTION_INTERVAL` | Number | `3600`   | How often, in seconds, the scheduler deletes finished runs older than the retention windows. Defaults to one hour. Must be greater than 0.                                                                                                                                         |
| `N8N_SCHEDULER_RETENTION_TIMEOUT`  | Number | `300`    | How long, in seconds, a single cleanup pass may run before it's abandoned and retried on the next interval. Defaults to five minutes. Must be greater than 0.                                                                                                                      |

## Owner reconciliation

Controls the sweep that retires schedules whose owner no longer exists, such as a workflow that's no longer published. The sweep stops them right away and deletes them after a grace period. See [How the durable scheduler works](/deploy/host-n8n/configure-n8n/durable-scheduler#how-it-works).

{% hint style="info" %}
**Feature availability**

Owner reconciliation is available from n8n 2.39.0.
{% endhint %}

| Variable                                        | Type    | Default | Description                                                                                                                                                                                                                                                    |
| ----------------------------------------------- | ------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_SCHEDULER_OWNER_RECONCILIATION_ENABLED`    | Boolean | `true`  | Whether the scheduler periodically checks that every schedule's owner still exists and retires the schedules whose owner is missing. Turning it off leaves those schedules in place.                                                                           |
| `N8N_SCHEDULER_OWNER_RECONCILIATION_INTERVAL`   | Number  | `900`   | How often, in seconds, the sweep runs. Defaults to 15 minutes. It's a safety net rather than the usual cleanup path, so a long interval is fine. Must be greater than 0.                                                                                       |
| `N8N_SCHEDULER_OWNER_RECONCILIATION_TIMEOUT`    | Number  | `300`   | How long, in seconds, a single sweep may run before it's abandoned and retried on the next interval. Defaults to five minutes. Must be greater than 0.                                                                                                         |
| `N8N_SCHEDULER_OWNER_RECONCILIATION_BATCH_SIZE` | Number  | `500`   | How many owners the sweep checks per database query. Larger batches finish a sweep in fewer queries; smaller ones keep each query light. Must be between 1 and 1000.                                                                                           |
| `N8N_SCHEDULER_OWNER_QUARANTINE_GRACE`          | Number  | `86400` | How long, in seconds, the sweep keeps a stopped schedule before deleting it. Defaults to one day. The schedule stops firing as soon as the sweep finds it, so this only delays the delete. Must be greater than 0.                                             |
| `N8N_SCHEDULER_OWNER_SETTLE_PERIOD`             | Number  | `300`   | How old, in seconds, a schedule must be before the sweep considers it. Defaults to five minutes. n8n can write a schedule a moment before its owner, so this stops the sweep from mistaking a brand-new schedule for an abandoned one. Must be greater than 0. |

## Coordination across instances <a href="#coordination-vars" id="coordination-vars"></a>

Controls how the scheduler overlaps its background passes and spreads database load across instances.

| Variable                              | Type   | Default | Description                                                                                                                                                                                                                                                                                                                                                                                                   |
| ------------------------------------- | ------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_SCHEDULER_MAX_CONCURRENT_PASSES` | Number | `10`    | The most background passes of the same kind that can run at once on one instance, when the database supports overlapping passes (PostgreSQL). If a pass comes due while the limit is already in use, n8n skips it. On SQLite, passes never overlap, so this setting has no effect. Must be greater than 0.                                                                                                    |
| `N8N_SCHEDULER_JITTER_RATIO`          | Number | `0.1`   | A small random variation added to the timing of each periodic pass, as a fraction of the interval. With `0.1`, a pass set to run every 10 seconds actually runs every 9 to 11 seconds. This spreads out database queries from instances started at the same time, such as during a rolling deploy. Set it to `0` for exact intervals, or raise it to spread load more evenly. Must be at least 0 and below 1. |

## Schedule behavior <a href="#behavior-vars" id="behavior-vars"></a>

| Variable                          | Type                   | Default | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| --------------------------------- | ---------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `N8N_SCHEDULER_TRIGGER_NODE_MODE` | Enum (`legacy`, `new`) | `new`   | How a Schedule Trigger node's "every N seconds" and "every N minutes" schedules fire. `new` spaces runs a steady N apart from workflow publication. It's the default from n8n 2.45.0. `legacy` keeps clock-aligned timing matching the in-memory scheduler and is the default in earlier versions. Only affects second and minute intervals. Deprecated from n8n 2.45.0: a future version will remove this variable and the `legacy` mode. See [Schedule Trigger timing](/deploy/host-n8n/configure-n8n/durable-scheduler#trigger-node-mode).                                                                |
| `N8N_SCHEDULER_MISFIRE_GRACE`     | Number                 | `60`    | How late, in seconds, a run may start and still count as on time. A run later than this counts as missed, and its trigger's misfire policy decides what happens to it and to any backlog behind it. This is the default a schedule inherits; from n8n 2.36.0, a Schedule Trigger node can set its own grace period instead. Should exceed `N8N_SCHEDULER_EXECUTOR_INTERVAL` and be at least `N8N_SCHEDULER_MATERIALIZATION_WINDOW`; n8n warns at startup if it doesn't. Capped at 30 days. See [Misfire policy](/deploy/host-n8n/configure-n8n/durable-scheduler#misfire-policy). Available from n8n 2.34.0. |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Security

Configure authentication and environment variable access in self-hosted n8n instance.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

| Variable                                     | Type                                 | Default                                                                                 | Description                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| -------------------------------------------- | ------------------------------------ | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_BLOCK_ENV_ACCESS_IN_NODE`               | Boolean                              | `false`                                                                                 | Whether to allow users to access environment variables in expressions and the Code node (false) or not (true).                                                                                                                                                                                                                                                                                                                                |
| `N8N_BLOCK_FILE_ACCESS_TO_N8N_FILES`         | Boolean                              | `true`                                                                                  | Set to `true` to block access to all files in the `.n8n` directory and user defined configuration files.                                                                                                                                                                                                                                                                                                                                      |
| `N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS`      | Boolean                              | `false`                                                                                 | Set to `true` to try to set 0600 permissions for the settings file, giving only the owner read and write access.                                                                                                                                                                                                                                                                                                                              |
| `N8N_RESTRICT_FILE_ACCESS_TO`                | String                               |                                                                                         | Limits access to files in these directories. Provide multiple files as a semicolon-separated list ("`;`").                                                                                                                                                                                                                                                                                                                                    |
| `N8N_SECURITY_AUDIT_DAYS_ABANDONED_WORKFLOW` | Number                               | 90                                                                                      | Number of days to consider a workflow abandoned if it's not executed.                                                                                                                                                                                                                                                                                                                                                                         |
| `N8N_CONTENT_SECURITY_POLICY`                | String                               | `script-src <nonce> 'strict-dynamic' 'unsafe-eval'; object-src 'none'; base-uri 'none'` | The [Content-Security-Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) n8n serves on its own pages. Accepts a policy string, for example `frame-ancestors http://localhost:3000`, or a [helmet.js](https://helmetjs.github.io/#content-security-policy) directives object. Write `<nonce>` where n8n inserts the per-request nonce. Set to `default` for n8n's policy, or `{}` for no header.                                   |
| `N8N_CONTENT_SECURITY_POLICY_REPORT_ONLY`    | String                               |                                                                                         | The policy n8n serves as `Content-Security-Policy-Report-Only`, in the same formats as `N8N_CONTENT_SECURITY_POLICY`. The browser reports violations but doesn't block them, so use it to try a policy before enforcing it.                                                                                                                                                                                                                   |
| `N8N_SECURE_COOKIE`                          | Boolean                              | `true`                                                                                  | Ensures that cookies are only sent over HTTPS, enhancing security.                                                                                                                                                                                                                                                                                                                                                                            |
| `N8N_SAMESITE_COOKIE`                        | Enum string: `strict`, `lax`, `none` | `lax`                                                                                   | <p>Controls cross-site cookie behavior (<a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite">learn more</a>):</p><ul><li><code>strict</code>: Sent only for first-party requests.</li><li><code>lax</code> (default): Sent with top-level navigation requests.</li><li><code>none</code>: Sent in all contexts (requires HTTPS).</li></ul>                                                                 |
| `N8N_INSECURE_DISABLE_FORM_HTML_SANDBOX`     | Boolean                              | `false`                                                                                 | Whether to remove the `sandbox` directive from the Content Security Policy (CSP) on form pages. Only for forms on a separate hostname from the editor. Available from n8n 2.15.0. Refer to [Configure webhook URLs with reverse proxy](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/configure-webhook-urls-with-reverse-proxy#when-its-safe-to-disable-the-form-sandbox) for full details and safety conditions. |
| `N8N_GIT_NODE_DISABLE_BARE_REPOS`            | Boolean                              | `false`                                                                                 | Set to `true` to prevent the [Git node](/integrations/builtin/core-nodes/n8n-nodes-base.git) from working with bare repositories, enhancing security.                                                                                                                                                                                                                                                                                         |
| `N8N_GIT_NODE_ENABLE_HOOKS`                  | Boolean                              | `false`                                                                                 | Set to `true` to allow the [Git node](/integrations/builtin/core-nodes/n8n-nodes-base.git) to execute Git hooks.                                                                                                                                                                                                                                                                                                                              |
| `N8N_POSTMESSAGE_ALLOWED_ORIGINS`            | String                               |                                                                                         | Origins allowed to exchange `postMessage` commands with the editor when it's embedded in another page. Only relevant when embedding the editor is possible, for example when running with `N8N_PREVIEW_MODE=true`. Provide multiple origins as a comma-separated list, for example `https://n8n.io,https://app.example.com`. When empty (the default), the editor accepts messages from any origin.                                           |

## Security policy using environment variables <a href="#security-policy-using-environment-variables" id="security-policy-using-environment-variables"></a>

Set `N8N_SECURITY_POLICY_MANAGED_BY_ENV` to `true` to manage the security policy from environment variables. See [Manage instance settings using environment variables](/deploy/host-n8n/configure-n8n/manage-settings-using-environment-variables) for how the activation pattern works.

| Variable                                | Type    | Default | Description                                                                                                                                                                         |
| --------------------------------------- | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_SECURITY_POLICY_MANAGED_BY_ENV`    | Boolean | `false` | Set to `true` to manage the security policy from environment variables. When `true`, n8n applies the security policy variables on every startup and locks the matching UI controls. |
| `N8N_MFA_ENFORCED_ENABLED`              | Boolean | `false` | Whether to enforce two-factor authentication for all users (`true`) or not (`false`).                                                                                               |
| `N8N_PERSONAL_SPACE_PUBLISHING_ENABLED` | Boolean | `true`  | Whether users can publish from their personal space (`true`) or not (`false`).                                                                                                      |
| `N8N_PERSONAL_SPACE_SHARING_ENABLED`    | Boolean | `true`  | Whether users can share resources from their personal space (`true`) or not (`false`).                                                                                              |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Source control

Environment variable to set the default SSH key type for source control setup.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

n8n uses Git-based source control to support environments. Refer to [Source control and environments](/administer/use-source-control-and-environments/set-up-source-control) for more information on how to link a Git repository to an n8n instance and configure your source control.

| Variable                                 | Type   | Default   | Description                                                                                                                                          |
| ---------------------------------------- | ------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_SOURCECONTROL_DEFAULT_SSH_KEY_TYPE` | String | `ed25519` | Set to `rsa` to make RSA the default SSH key type for [Source control setup](/administer/use-source-control-and-environments/set-up-source-control). |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# SSO

Configure single sign-on for self-hosted n8n using environment variables.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

{% hint style="info" %}
**Feature availability**

Single sign-on is available on:

* **Self-hosted:** Business, Enterprise

n8n Cloud Enterprise also supports single sign-on, but not through the environment variables on this page.
{% endhint %}

Refer to [Set up SSO](/deploy/host-n8n/configure-n8n/security/configure-sso) for in-app setup steps and identity provider guides. See [Manage instance settings using environment variables](/deploy/host-n8n/configure-n8n/manage-settings-using-environment-variables) for how the activation pattern works.

## Activation and shared settings <a href="#activation-and-shared-settings" id="activation-and-shared-settings"></a>

| Variable                         | Type                                                                   | Default    | Description                                                                                                                                                                                                                           |
| -------------------------------- | ---------------------------------------------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_SSO_MANAGED_BY_ENV`         | Boolean                                                                | `false`    | Set to `true` to manage SSO from environment variables. When `true`, n8n applies the SSO variables on every startup and locks the matching UI controls.                                                                               |
| `N8N_SSO_USER_ROLE_PROVISIONING` | Enum string: `disabled`, `instance_role`, `instance_and_project_roles` | `disabled` | How n8n provisions roles for users who sign in through SSO. `disabled` doesn't provision any roles. `instance_role` provisions the instance-level role only. `instance_and_project_roles` provisions both instance and project roles. |

## OIDC <a href="#oidc" id="oidc"></a>

| Variable                          | Type    | Default | Description                                                                                                                  |
| --------------------------------- | ------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `N8N_SSO_OIDC_LOGIN_ENABLED`      | Boolean | `false` | Whether to enable OIDC login.                                                                                                |
| `N8N_SSO_OIDC_CLIENT_ID`          | String  | -       | OIDC client ID issued by your identity provider.                                                                             |
| `N8N_SSO_OIDC_CLIENT_SECRET`      | String  | -       | OIDC client secret issued by your identity provider.                                                                         |
| `N8N_SSO_OIDC_DISCOVERY_ENDPOINT` | String  | -       | OIDC discovery endpoint URL (the `.well-known/openid-configuration` URL for your identity provider).                         |
| `N8N_SSO_OIDC_PROMPT`             | String  | -       | Optional OIDC `prompt` parameter to send with the authorization request, for example `login` or `consent`.                   |
| `N8N_SSO_OIDC_ACR_VALUES`         | String  | -       | Optional OIDC `acr_values` parameter. Use this to request a specific authentication context, for example a step-up MFA flow. |

## SAML <a href="#saml" id="saml"></a>

| Variable                     | Type    | Default | Description                                                                                                            |
| ---------------------------- | ------- | ------- | ---------------------------------------------------------------------------------------------------------------------- |
| `N8N_SSO_SAML_LOGIN_ENABLED` | Boolean | `false` | Whether to enable SAML login.                                                                                          |
| `N8N_SSO_SAML_METADATA`      | String  | -       | SAML identity provider metadata as an XML string. Mutually exclusive with `N8N_SSO_SAML_METADATA_URL`; don't set both. |
| `N8N_SSO_SAML_METADATA_URL`  | String  | -       | URL to fetch SAML identity provider metadata from. Mutually exclusive with `N8N_SSO_SAML_METADATA`; don't set both.    |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# SSRF protection

Configure SSRF protection for your self-hosted n8n instance.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

Server-Side Request Forgery (SSRF) is an attack that tricks a server into making HTTP requests to addresses an attacker chooses, such as internal-only targets like `localhost`, private network ranges, or a cloud provider's metadata endpoint (`169.254.169.254`). Because workflows can build request URLs from user-controlled input, n8n can guard outbound requests whose destination comes from that input.

SSRF protection is off by default. This page lists the variables that turn it on and tune it.

## What protection covers

| Variable                      | Type    | Default   | Description                                                                                                                                                                                                                      |
| ----------------------------- | ------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_SSRF_PROTECTION_ENABLED` | Boolean | `false`   | Turns on SSRF protection for requests to user-controllable targets.                                                                                                                                                              |
| `N8N_SSRF_BLOCKED_IP_RANGES`  | String  | `default` | Comma-separated CIDR ranges to block. The keyword `default` (case-insensitive) expands to n8n's built-in set. Append your own ranges: `default,100.64.0.0/10`.                                                                   |
| `N8N_SSRF_ALLOWED_IP_RANGES`  | String  | `-`       | Comma-separated CIDR ranges to allow. Takes precedence over the block list, so use it to reach a known internal host.                                                                                                            |
| `N8N_SSRF_ALLOWED_HOSTNAMES`  | String  | `-`       | Comma-separated hostnames to allow. Supports a leading `*.` wildcard: `*.internal.example.com` matches any subdomain, including nested ones, but not the bare domain. Matching is case-insensitive.                              |
| `N8N_SSRF_BLOCKED_HOSTNAMES`  | String  | `-`       | Comma-separated hostnames to deny by name, checked before DNS resolution. Uses the same leading `*.` wildcard and case-insensitive matching as `N8N_SSRF_ALLOWED_HOSTNAMES`. An allowed hostname always overrides a blocked one. |
| `N8N_SSRF_DNS_CACHE_MAX_SIZE` | Number  | `1048576` | Maximum size of the internal DNS-resolution cache, in bytes (1 MB by default). n8n evicts the least recently used entries when the cache is full.                                                                                |

n8n logs a warning and skips any invalid CIDR range you set in `N8N_SSRF_BLOCKED_IP_RANGES` or `N8N_SSRF_ALLOWED_IP_RANGES`, so a typo won't stop the instance from starting.

### Blocked by default

When `N8N_SSRF_BLOCKED_IP_RANGES` includes `default`, n8n blocks these ranges:

* Private networks ([RFC 1918](https://datatracker.ietf.org/doc/html/rfc1918)): `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`
* Loopback: `127.0.0.0/8`, `::1/128`
* Link-local, including cloud metadata: `169.254.0.0/16`, `fe80::/10`
* IPv6 unique-local: `fc00::/7`, `fd00::/8`
* Reserved or special-purpose: `0.0.0.0/8`, `192.0.0.0/24`, `192.0.2.0/24`, `198.18.0.0/15`, `198.51.100.0/24`, `203.0.113.0/24`

## How n8n evaluates a request

n8n checks each destination in this order and stops at the first match:

1. **Allowed hostname**: if the request hostname matches `N8N_SSRF_ALLOWED_HOSTNAMES`, n8n allows the request.
2. **Blocked hostname**: if the request hostname matches `N8N_SSRF_BLOCKED_HOSTNAMES`, n8n blocks the request. This check runs before DNS resolution, so n8n rejects the name without a lookup, even if it would resolve to a public IP.
3. **Allowed IP range**: if the resolved IP matches `N8N_SSRF_ALLOWED_IP_RANGES`, n8n allows the request.
4. **Blocked IP range**: if the resolved IP matches `N8N_SSRF_BLOCKED_IP_RANGES`, n8n blocks the request.
5. **Otherwise**: n8n allows the request.

Because n8n checks the allow lists first, an allow entry always overrides the block list.

## Common scenarios

Reach an internal service on purpose. If a workflow must call an internal host, allow just that target rather than turning off protection:

```bash
N8N_SSRF_PROTECTION_ENABLED=true
N8N_SSRF_ALLOWED_IP_RANGES=10.20.0.5/32
```

Allow an internal hostname:

```bash
N8N_SSRF_ALLOWED_HOSTNAMES=*.svc.cluster.local
```

Tighten beyond the defaults. Add ranges specific to your environment:

```bash
N8N_SSRF_BLOCKED_IP_RANGES=default,100.64.0.0/10
```

Deny a hostname by name. Block a host and all its subdomains, regardless of the IP it resolves to:

```bash
N8N_SSRF_BLOCKED_HOSTNAMES=example.com,*.example.com
```

{% hint style="info" %}
**Hostname blocking is egress governance, not SSRF hardening**

`N8N_SSRF_BLOCKED_HOSTNAMES` denies by name, so callers can still reach the same destination through an IP literal, an alternate hostname, or DNS rebinding. Use it to discourage known unwanted destinations, but rely on the IP-based block list for SSRF protection.
{% endhint %}

## When n8n blocks a request

A request blocked by IP fails with the error "The request was blocked because it resolves to a restricted IP address". A request blocked by hostname fails with "The request was blocked because the destination hostname is restricted". Both descriptions name the target and tell the user to ask their n8n administrator to allow the hostname or IP range. Add the expected target to `N8N_SSRF_ALLOWED_IP_RANGES` or `N8N_SSRF_ALLOWED_HOSTNAMES` if the request is genuine.

{% hint style="warning" %}
**Review allow lists before enabling in production**

Protection is off by default so it doesn't break existing self-hosted setups that call internal services. Before you turn it on, list the internal hosts your workflows need and add them to the allow lists. Prefer narrow allow entries, such as a single host or hostname, over turning protection off.
{% endhint %}

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Task runners

Environment variables to confgure task runners your self-hosted n8n instance.

{% hint style="info" %}
**File-based configuration**

Unlike the main n8n image, you CANNOT use file-based configuration for secrets in the task runner image. This means that variables with a `_FILE` suffix added will not be recognized.
{% endhint %}

[Task runners](/deploy/host-n8n/configure-n8n/set-up-task-runners) execute code defined by the [Code node](/integrations/builtin/core-nodes/n8n-nodes-base.code).

## n8n instance environment variables <a href="#n8n-instance-environment-variables" id="n8n-instance-environment-variables"></a>

| Variable                               | Type                                                 | Default         | Description                                                                                                                                                                                                                                                                                                                              |
| -------------------------------------- | ---------------------------------------------------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_RUNNERS_ENABLED` (**deprecated**) | Boolean                                              | `false`         | Are task runners enabled. **Deprecated** from n8n 2.0.                                                                                                                                                                                                                                                                                   |
| `N8N_RUNNERS_MODE`                     | Enum string: `internal` (**deprecated**), `external` | `internal`      | How to launch and run the task runner. `internal` means n8n will launch a task runner as child process. **Deprecated**: internal mode will be removed in a future version. `external` means an external orchestrator will launch the task runner. See [external mode](/deploy/host-n8n/configure-n8n/set-up-task-runners#external-mode). |
| `N8N_RUNNERS_AUTH_TOKEN`               | String                                               | Random string   | Shared secret used by a task runner to authenticate to n8n. Required when using `external` mode.                                                                                                                                                                                                                                         |
| `N8N_RUNNERS_BROKER_PORT`              | Number                                               | `5679`          | Port the task broker listens on for task runner connections.                                                                                                                                                                                                                                                                             |
| `N8N_RUNNERS_BROKER_LISTEN_ADDRESS`    | String                                               | `127.0.0.1`     | Address the task broker listens on.                                                                                                                                                                                                                                                                                                      |
| `N8N_RUNNERS_MAX_PAYLOAD`              | Number                                               | `1 073 741 824` | Maximum payload size in bytes for communication between a task broker and a task runner.                                                                                                                                                                                                                                                 |
| `N8N_RUNNERS_MAX_OLD_SPACE_SIZE`       | String                                               |                 | The `--max-old-space-size` option to use for a task runner (in MB). By default, Node.js will set this based on available memory.                                                                                                                                                                                                         |
| `N8N_RUNNERS_MAX_CONCURRENCY`          | Number                                               | `5`             | The number of concurrent tasks a task runner can execute at a time.                                                                                                                                                                                                                                                                      |
| `N8N_RUNNERS_TASK_TIMEOUT`             | Number                                               | `300`           | The maximum time, in seconds, a task can run before the runner stops it and restarts. This value must be greater than 0.                                                                                                                                                                                                                 |
| `N8N_RUNNERS_HEARTBEAT_INTERVAL`       | Number                                               | `30`            | The interval, in seconds, at which the runner must send a heartbeat to the broker. If the runner doesn't send a heartbeat in time, the task stops and the runner restarts. This value must be greater than 0.                                                                                                                            |
| `N8N_RUNNERS_INSECURE_MODE`            | Boolean                                              | `false`         | Whether to disable all security measures in the task runner, for compatibility with modules that rely on insecure JS features. **Discouraged for production use.**                                                                                                                                                                       |
| `N8N_RUNNERS_TASK_REQUEST_TIMEOUT`     | Number                                               | `60`            | How long (in seconds) a task request can wait for a runner to become available before timing out. This prevents workflows from hanging indefinitely when no runners are available. Must be greater than 0.                                                                                                                               |

## Task runner launcher environment variables <a href="#task-runner-launcher-environment-variables" id="task-runner-launcher-environment-variables"></a>

| Variable                                 | Type                                          | Default                 | Description                                                                              |
| ---------------------------------------- | --------------------------------------------- | ----------------------- | ---------------------------------------------------------------------------------------- |
| `N8N_RUNNERS_LAUNCHER_LOG_LEVEL`         | Enum string: `debug`, `info`, `warn`, `error` | `info`                  | Which log messages to show.                                                              |
| `N8N_RUNNERS_AUTH_TOKEN`                 | String                                        | -                       | Shared secret used to authenticate to n8n.                                               |
| `N8N_RUNNERS_AUTO_SHUTDOWN_TIMEOUT`      | Number                                        | `15`                    | The number of seconds to wait before shutting down an idle runner.                       |
| `N8N_RUNNERS_TASK_BROKER_URI`            | String                                        | `http://127.0.0.1:5679` | The URI of the task broker server (n8n instance).                                        |
| `N8N_RUNNERS_LAUNCHER_HEALTH_CHECK_PORT` | Number                                        | `5680`                  | Port for the launcher's health check server.                                             |
| `N8N_RUNNERS_MAX_PAYLOAD`                | Number                                        | `1 073 741 824`         | Maximum payload size in bytes for communication between a task broker and a task runner. |
| `N8N_RUNNERS_MAX_CONCURRENCY`            | Number                                        | `5`                     | The number of concurrent tasks a task runner can execute at a time.                      |

## Task runner environment variables (all languages) <a href="#task-runner-environment-variables-all-languages" id="task-runner-environment-variables-all-languages"></a>

| Variable                                 | Type   | Default                 | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ---------------------------------------- | ------ | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_RUNNERS_GRANT_TOKEN`                | String | Random string           | Token the runner uses to authenticate with the task broker. This is automatically provided by the launcher.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `N8N_RUNNERS_ID`                         | String | Random string           | ID the runner identifies itself with to the task broker. In `internal` mode, n8n sets it for each runner it launches. In `external` mode, leave it unset unless you need stable IDs in the broker logs: every runner needs a unique value, and two runners sharing one keep evicting each other. Set it per runner type as an `env-override` in the [runners config file](/deploy/host-n8n/configure-n8n/set-up-task-runners#configuring-launcher-in-runners-container-in-external-mode) (`/etc/n8n-task-runners.json`), not as a container environment variable. Available from n8n 2.35.0. |
| `N8N_RUNNERS_AUTO_SHUTDOWN_TIMEOUT`      | Number | `15`                    | The number of seconds to wait before shutting down an idle runner.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `N8N_RUNNERS_TASK_BROKER_URI`            | String | `http://127.0.0.1:5679` | The URI of the task broker server (n8n instance).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `N8N_RUNNERS_LAUNCHER_HEALTH_CHECK_PORT` | Number | `5680`                  | Port for the launcher's health check server.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `N8N_RUNNERS_MAX_PAYLOAD`                | Number | `1 073 741 824`         | Maximum payload size in bytes for communication between a task broker and a task runner.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `N8N_RUNNERS_MAX_CONCURRENCY`            | Number | `5`                     | The number of concurrent tasks a task runner can execute at a time.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |

## Task runner environment variables (JavaScript) <a href="#task-runner-environment-variables-javascript" id="task-runner-environment-variables-javascript"></a>

| Variable                               | Type    | Default            | Description                                                                                                                                                                                                                                                                                                                                                                                                  |
| -------------------------------------- | ------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `NODE_FUNCTION_ALLOW_BUILTIN`          | String  | -                  | Permit users to import specific built-in modules in the Code node. Use \* to allow all. n8n disables importing modules by default. In external mode, set this in the [runners config file](/deploy/host-n8n/configure-n8n/set-up-task-runners#configuring-launcher-in-runners-container-in-external-mode) (`/etc/n8n-task-runners.json`) as an `env-override`, not as a container environment variable.      |
| `NODE_FUNCTION_ALLOW_EXTERNAL`         | String  | -                  | Permit users to import specific external modules (from `n8n/node_modules`) in the Code node. n8n disables importing modules by default. In external mode, set this in the [runners config file](/deploy/host-n8n/configure-n8n/set-up-task-runners#configuring-launcher-in-runners-container-in-external-mode) (`/etc/n8n-task-runners.json`) as an `env-override`, not as a container environment variable. |
| `N8N_RUNNERS_ALLOW_PROTOTYPE_MUTATION` | Boolean | `false`            | Whether to allow prototype mutation for external libraries. Set to `true` to allow modules that rely on runtime prototype mutation (for example, [`puppeteer`](https://pptr.dev/)) at the cost of relaxing security.                                                                                                                                                                                         |
| `GENERIC_TIMEZONE`                     | \*      | `America/New_York` | The [same default timezone as configured for the n8n instance](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/timezone-and-localization).                                                                                                                                                                                                                                      |
| `NODE_OPTIONS`                         | String  | -                  | [Options](https://nodejs.org/api/cli.html#node_optionsoptions) for Node.js.                                                                                                                                                                                                                                                                                                                                  |
| `N8N_RUNNERS_MAX_OLD_SPACE_SIZE`       | String  |                    | The `--max-old-space-size` option to use for a task runner (in MB). By default, Node.js will set this based on available memory.                                                                                                                                                                                                                                                                             |

## Task runner environment variables (Python) <a href="#task-runner-environment-variables-python" id="task-runner-environment-variables-python"></a>

| Variable                               | Type    | Default                                                                                                                                  | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| -------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_RUNNERS_STDLIB_ALLOW`             | String  | -                                                                                                                                        | Python standard library modules that you can use in the Code node, including their submodules. Use `*` to allow all stdlib modules. n8n disables all Python standard library imports by default. In external mode, set this in the [runners config file](/deploy/host-n8n/configure-n8n/set-up-task-runners#configuring-launcher-in-runners-container-in-external-mode) (`/etc/n8n-task-runners.json`) as an `env-override`, not as a container environment variable.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `N8N_RUNNERS_EXTERNAL_ALLOW`           | String  | -                                                                                                                                        | Third-party Python modules that are allowed to be used in the Code node, including their submodules. Use `*` to allow all external modules. n8n disables all third-party Python modules by default. Third-party Python modules must be [included](/deploy/host-n8n/configure-n8n/set-up-task-runners#adding-extra-dependencies) in the `n8nio/runners` image. In external mode, set this in the [runners config file](/deploy/host-n8n/configure-n8n/set-up-task-runners#configuring-launcher-in-runners-container-in-external-mode) (`/etc/n8n-task-runners.json`) as an `env-override`, not as a container environment variable.                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `N8N_RUNNERS_ALLOW_TRANSITIVE_IMPORTS` | Boolean | `false`                                                                                                                                  | Whether imports performed by an allowlisted package's own code skip the import allowlist (both `N8N_RUNNERS_EXTERNAL_ALLOW` and `N8N_RUNNERS_STDLIB_ALLOW`). Set to `true` to let an allowlisted package load whatever it imports (its transitive dependencies and stdlib) without listing each module. This helps with packages whose internal imports pull in other modules (for example, `pandas` imports `pytz`, or `boto3` imports `dateutil`). Your own imports in the Code node are still checked against the allowlist. Enabling this trusts the import activity of all installed packages, not only the named ones: a compromised dependency could pull in modules the allowlist would otherwise block, so only enable it when the runner image's installed packages are trusted. In external mode, set this in the [runners config file](/deploy/host-n8n/configure-n8n/set-up-task-runners#configuring-launcher-in-runners-container-in-external-mode) (`/etc/n8n-task-runners.json`) as an `env-override`, not as a container environment variable. |
| `N8N_RUNNERS_BUILTINS_DENY`            | String  | `eval,exec,compile,open,input,breakpoint,getattr,object,type,vars,setattr,delattr,hasattr,dir,memoryview,__build_class__,globals,locals` | Python built-ins that you can't use in the Code node. Set to an empty string to allow all built-ins.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `N8N_BLOCK_RUNNER_ENV_ACCESS`          | Boolean | `true`                                                                                                                                   | Whether to block access to the runner's environment from within Python code tasks. Set to `false` to enable all Python code node users access to the runner's environment via `os.environ`. For security reasons, environment variable access is blocked by default.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Timezone and localization

Set the timezone and default language locale for self-hosted n8n instance.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

| Variable             | Type   | Default            | Description                                                                                                                                                                                                                                                                                                                                                    |
| -------------------- | ------ | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GENERIC_TIMEZONE`   | \*     | `America/New_York` | The n8n instance timezone. Important for schedule nodes (such as Cron).                                                                                                                                                                                                                                                                                        |
| `N8N_DEFAULT_LOCALE` | String | `en`               | A locale identifier, compatible with the [Accept-Language header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language). n8n doesn't support regional identifiers, such as `de-AT`. When running in a locale other than the default, n8n displays UI strings in the selected locale, and falls back to `en` for any untranslated strings. |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# User management and 2FA

Environment variables to set up user management and emails.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

Refer to [User management](/deploy/host-n8n/configure-n8n/user-management) for more information on setting up user management and emails.

| Variable                                        | Type    | Default | Description                                                                                                                                                                                                                                                          |
| ----------------------------------------------- | ------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_EMAIL_MODE`                                | String  | `smtp`  | Enable emails.                                                                                                                                                                                                                                                       |
| `N8N_SMTP_HOST`                                 | String  | -       | *your\_SMTP\_server\_name*                                                                                                                                                                                                                                           |
| `N8N_SMTP_PORT`                                 | Number  | -       | *your\_SMTP\_server\_port*                                                                                                                                                                                                                                           |
| `N8N_SMTP_USER`                                 | String  | -       | *your\_SMTP\_username*                                                                                                                                                                                                                                               |
| `N8N_SMTP_PASS`                                 | String  | -       | *your\_SMTP\_password*                                                                                                                                                                                                                                               |
| `N8N_SMTP_OAUTH_SERVICE_CLIENT`                 | String  | -       | If using 2LO with a service account this is your client ID                                                                                                                                                                                                           |
| `N8N_SMTP_OAUTH_PRIVATE_KEY`                    | String  | -       | If using 2LO with a service account this is your private key                                                                                                                                                                                                         |
| `N8N_SMTP_SENDER`                               | String  | -       | Sender email address. You can optionally include the sender name. Example with name: *n8n `<contact@n8n.com>`*                                                                                                                                                       |
| `N8N_SMTP_SSL`                                  | Boolean | `true`  | Whether to use SSL for SMTP (true) or not (false).                                                                                                                                                                                                                   |
| `N8N_SMTP_STARTTLS`                             | Boolean | `true`  | Whether to use STARTTLS for SMTP (true) or not (false).                                                                                                                                                                                                              |
| `N8N_UM_EMAIL_TEMPLATES_INVITE`                 | String  | -       | Full path to your HTML email template. This overrides the default template for invite emails.                                                                                                                                                                        |
| `N8N_UM_EMAIL_TEMPLATES_PWRESET`                | String  | -       | Full path to your HTML email template. This overrides the default template for password reset emails.                                                                                                                                                                |
| `N8N_UM_EMAIL_TEMPLATES_WORKFLOW_SHARED`        | String  | -       | Overrides the default HTML template for notifying users that a workflow was shared. Provide the full path to the template.                                                                                                                                           |
| `N8N_UM_EMAIL_TEMPLATES_CREDENTIALS_SHARED`     | String  | -       | Overrides the default HTML template for notifying users that a credential was shared. Provide the full path to the template.                                                                                                                                         |
| `N8N_UM_EMAIL_TEMPLATES_PROJECT_SHARED`         | String  | -       | Overrides the default HTML template for notifying users that a project was shared. Provide the full path to the template.                                                                                                                                            |
| `N8N_USER_MANAGEMENT_JWT_SECRET`                | String  | -       | Set a specific JWT secret. By default, n8n generates one on start.                                                                                                                                                                                                   |
| `N8N_USER_MANAGEMENT_JWT_DURATION_HOURS`        | Number  | 168     | Set an expiration date for the JWTs in hours.                                                                                                                                                                                                                        |
| `N8N_USER_MANAGEMENT_JWT_REFRESH_TIMEOUT_HOURS` | Number  | 0       | How many hours before the JWT expires to automatically refresh it. 0 means 25% of `N8N_USER_MANAGEMENT_JWT_DURATION_HOURS`. -1 means it will never refresh, which forces users to log in again after the period defined in `N8N_USER_MANAGEMENT_JWT_DURATION_HOURS`. |
| `N8N_MFA_ENABLED`                               | Boolean | `true`  | Whether to enable two-factor authentication (true) or disable (false). n8n ignores this if existing users have 2FA enabled.                                                                                                                                          |
| `N8N_INVITE_LINKS_EMAIL_ONLY`                   | Boolean | `false` | When set to true, n8n will only deliver invite links via email and will not expose them through the API. This option enhances security by preventing invite URLs from being accessible programmatically, or to high privileged users.                                |

## Instance owner using environment variables <a href="#instance-owner-using-environment-variables" id="instance-owner-using-environment-variables"></a>

Set `N8N_INSTANCE_OWNER_MANAGED_BY_ENV` to `true` to pre-provision the instance owner from environment variables. See [Manage instance settings using environment variables](/deploy/host-n8n/configure-n8n/manage-settings-using-environment-variables) for how the activation pattern works.

| Variable                            | Type    | Default | Description                                                                                                                                                                                                       |
| ----------------------------------- | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_INSTANCE_OWNER_MANAGED_BY_ENV` | Boolean | `false` | Set to `true` to manage the instance owner from environment variables. When `true`, n8n overwrites the instance owner details below on every startup, locks the UI control for that user, and rejects API writes. |
| `N8N_INSTANCE_OWNER_EMAIL`          | String  | -       | Email address for the instance owner.                                                                                                                                                                             |
| `N8N_INSTANCE_OWNER_FIRST_NAME`     | String  | -       | First name for the instance owner.                                                                                                                                                                                |
| `N8N_INSTANCE_OWNER_LAST_NAME`      | String  | -       | Last name for the instance owner.                                                                                                                                                                                 |
| `N8N_INSTANCE_OWNER_PASSWORD_HASH`  | String  | -       | Bcrypt hash of the instance owner's password. Setting a plaintext password breaks login.                                                                                                                          |

{% hint style="warning" %}
**Owner email must be unique**

`N8N_INSTANCE_OWNER_EMAIL` must not already belong to another user on the instance. This setting updates the existing instance owner account; it doesn't transfer ownership to another existing user or merge user accounts. To use an email address that already belongs to another user, change or delete that user first so the email becomes available.
{% endhint %}

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Workflows

Environment variables to configure workflows in n8n, including default naming, onboarding flow preferences, tag management, and caller policy settings.

{% hint style="info" %}
**File-based configuration**

You can add `_FILE` to individual variables to provide their configuration in a separate file. Refer to [Keeping sensitive data in separate files](/deploy/host-n8n/configure-n8n/basic-configuration#keeping-sensitive-data-in-separate-files) for more details.
{% endhint %}

| Variable                                    | Type    | Default                  | Description                                                                                                                                                                                           |
| ------------------------------------------- | ------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_ONBOARDING_FLOW_DISABLED`              | Boolean | `false`                  | Whether to disable onboarding tips when creating a new workflow (true) or not (false).                                                                                                                |
| `N8N_WORKFLOW_ACTIVATION_BATCH_SIZE`        | Number  | `1`                      | How many workflows to publish simultaneously during startup.                                                                                                                                          |
| `N8N_WORKFLOW_CALLER_POLICY_DEFAULT_OPTION` | String  | `workflowsFromSameOwner` | Which workflows can call a workflow. Options are: `any`, `none`, `workflowsFromAList`, `workflowsFromSameOwner`. This feature requires [Workflow sharing](/build/manage-workflows/share-with-others). |
| `N8N_WORKFLOW_TAGS_DISABLED`                | Boolean | `false`                  | Whether to disable workflow tags (true) or enable tags (false).                                                                                                                                       |
| `WORKFLOWS_DEFAULT_NAME`                    | String  | `My workflow`            | The default name used for new workflows.                                                                                                                                                              |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Workflow history

Environment variables to configure workflow history in n8n.

| Variable                          | Type   | Default | Description                                                                                                                              |
| --------------------------------- | ------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_WORKFLOW_HISTORY_PRUNE_TIME` | Number | `-1`    | How long to keep workflow history versions before automatically deleting them (in hours). Set to `-1` to keep all versions indefinitely. |

## Related resources

* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Configuration examples

An overview containing different configuration examples.

This section contains examples for how to configure n8n to solve particular use cases.

## In this section

* [Isolate n8n](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/isolate-n8n): prevent your n8n instance from connecting with n8n's servers.
* [Configure the Base URL](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/configure-the-base-url): define the front end's access path to the back end's REST API.
* [Configure custom SSL certificate authorities](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/configure-custom-ssl-certificate-authorities): work with self-signed certificates when connecting to services.
* [Set a custom encryption key](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/set-a-custom-encryption-key): set a custom encryption key to securely encrypt credentials.
* [Configure workflow timeouts](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/configure-workflow-timeouts): set execution timeouts to determine how long workflows can run.
* [Specify custom nodes location](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/specify-custom-nodes-location): add folders and specify paths for your custom nodes.
* [Enable modules in Code node](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/enable-modules-in-code-node): allow the use of built-in and external modules in the Code node.
* [Set the timezone](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/set-the-timezone): change the default timezone for your self-hosted instance.
* [Specify user folder path](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/specify-user-folder-path): specify the location of the folder that stores user-specific data.
* [Configure webhook URLs with reverse proxy](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/configure-webhook-urls-with-reverse-proxy): customize webhook URLs for compatibility with reverse proxy setups.
* [Enable Prometheus metrics](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/enable-prometheus-metrics): enable the Prometheus metrics endpoint.
* [Pre-configure Microsoft OAuth credentials](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/pre-configure-microsoft-oauth-credentials): let users connect without their own app registration.
* [Configure a custom workflow templates library](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/configure-a-custom-workflow-templates-library): set up a custom workflow template library.

## Related resources

* [Basic configuration](/deploy/host-n8n/configure-n8n/basic-configuration)
* [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)


# Isolate n8n

Prevent your n8n instance from connecting with n8n's servers.

By default, a self-hosted n8n instance sends data to n8n's servers. It notifies users about available updates, workflow templates, and diagnostics.

To prevent your n8n instance from connecting to n8n's servers, set these environment variables to false:

```
N8N_DIAGNOSTICS_ENABLED=false
N8N_VERSION_NOTIFICATIONS_ENABLED=false
N8N_TEMPLATES_ENABLED=false
```

Unset n8n's diagnostics configuration:

```
EXTERNAL_FRONTEND_HOOKS_URLS=
N8N_DIAGNOSTICS_CONFIG_FRONTEND=
N8N_DIAGNOSTICS_CONFIG_BACKEND=
```

Refer to [Environment variables reference](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/deployment) for more information on these variables.

## Related resources

* [Configuration examples](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples)


# Configure the Base URL

Configure the Base URL environment variable to define the front end's access path to the back end's REST API for n8n.

{% hint style="warning" %}
**Requires manual UI build**

This use case involves configuring the `VUE_APP_URL_BASE_API` environmental variable which requires a manual build of the `n8n-editor-ui` package. You can't use it with the default n8n Docker image where the default setting for this variable is `/`, meaning that it uses the root-domain.
{% endhint %}

You can configure the Base URL that the front end uses to connect to the back end's REST API. This is relevant when you want to host n8n's front end and back end separately.

```bash
export VUE_APP_URL_BASE_API=https://n8n.example.com/
```

Refer to [Environment variables reference](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/deployment) for more information on this variable.

## Related resources

* [Configuration examples](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples)


# Configure custom SSL certificate authorities

Customize the n8n container to work with self signed certificates when connecting to services.

You can add your own certificate authority (CA) or self-signed certificate to n8n. This means you are able to trust a certain SSL certificate instead of trusting all invalid certificates, which is a potential security risk.

{% hint style="info" %}
**Feature availability**

You can use your own certificate authority or self-signed certificate starting from n8n 1.42.0.
{% endhint %}

To use this feature you need to place your certificates in a folder and mount the folder to `/opt/custom-certificates` in the container. The external path that you map to `/opt/custom-certificates` must be writable by the container.

## Docker <a href="#docker" id="docker"></a>

The examples below assume you have a folder called `pki` that contains your certificates in either the directory you run the command from or next to your docker compose file.

### Docker CLI <a href="#docker-cli" id="docker-cli"></a>

When using the CLI you can use the `-v` flag from the command line:

```bash
docker run -it --rm \
 --name n8n \
 -p 5678:5678 \
 -v ./pki:/opt/custom-certificates \
 n8nio/n8n
```

### Docker Compose <a href="#docker-compose" id="docker-compose"></a>

```yaml
name: n8n
services:
    n8n:
        volumes:
            - ./pki:/opt/custom-certificates
        container_name: n8n
        ports:
            - 5678:5678
        image: n8nio/n8n
```

You should also give the right permissions to the imported certs. You can do this once the container is running (assuming n8n as the container name):

```bash
docker exec --user 0 n8n chown -R 1000:1000 /opt/custom-certificates
```

## Certificate requirements for Custom Trust Store <a href="#certificate-requirements-for-custom-trust-store" id="certificate-requirements-for-custom-trust-store"></a>

Supported certificate types:

* Root CA Certificates: these are certificates from Certificate Authorities that sign other certificates. Trust these to accept all certificates signed by that CA.
* Self-Signed Certificates: certificates that servers create and sign themselves. Trust these to accept connections to that specific server only.

You must use PEM format:

* Text-based format with BEGIN/END markers
* Supported file extensions: `.pem`, `.crt`, `.cer`
* Contains the public certificate (no private key needed)

For example:

```
-----BEGIN CERTIFICATE-----
MIIDXTCCAkWgAwIBAgIJAKoK/heBjcOuMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV
[base64 encoded data]
-----END CERTIFICATE-----
```

The system doesn't accept:

* DER/binary format files
* PKCS#7 (.p7b) files
* PKCS#12 (.pfx, .p12) files
* Private key files
* Convert these formats to PEM before use.

## Related resources

* [Configuration examples](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples)


# Set a custom encryption key

Set a custom encryption key for n8n to securely encrypt credentials.

n8n creates a random encryption key automatically on the first launch and saves it in the `~/.n8n` folder. n8n uses that key to encrypt the credentials before they get saved to the database. If the key isn't yet in the settings file, you can set it using an environment variable, so that n8n uses your custom key instead of generating a new one.

In [queue mode](/deploy/host-n8n/configure-n8n/scaling/enable-queue-mode), you must specify the encryption key environment variable for all workers.

```bash
export N8N_ENCRYPTION_KEY=<SOME RANDOM STRING>
```

Refer to [Environment variables reference](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/deployment) for more information on this variable.

## Related resources

* [Configuration examples](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples)


# Configure workflow timeouts

Set execution timeouts to determine how long workflows can run.

A workflow times out and gets canceled after this time (in seconds). If the workflow runs in the main process, a soft timeout happens (takes effect after the current node finishes). If a workflow runs in its own process, n8n attempts a soft timeout first, then kills the process after waiting for a fifth of the given timeout duration.

`EXECUTIONS_TIMEOUT` default is `-1`. For example, if you want to set the timeout to one hour:

```bash
export EXECUTIONS_TIMEOUT=3600
```

You can also set maximum execution time (in seconds) for each workflow individually. For example, if you want to set maximum execution time to two hours:

```bash
export EXECUTIONS_TIMEOUT_MAX=7200
```

Refer to [Environment variables reference](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/executions) for more information on these variables.

## Related resources

* [Configuration examples](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples)


# Specify custom nodes location

Add folders and specify paths for your custom nodes.

Every user can add custom nodes that get loaded by n8n on startup. The default location is in the subfolder `.n8n/custom` of the user who started n8n.

You can define more folders with an environment variable:

```bash
export N8N_CUSTOM_EXTENSIONS="/home/jim/n8n/custom-nodes;/data/n8n/nodes"
```

Refer to [Environment variables reference](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/nodes) for more information on this variable.

## Related resources

* [Configuration examples](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples)


# Enable modules in Code node

Allow the use of both built-in and external modules within the Code node.

For security reasons, the Code node restricts importing modules. It's possible to lift that restriction for built-in and external modules by setting the following environment variables:

* `NODE_FUNCTION_ALLOW_BUILTIN`: For built-in modules
* `NODE_FUNCTION_ALLOW_EXTERNAL`: For external modules sourced from n8n/node\_modules directory. External module support is disabled when an environment variable isn't set.

```bash
# Allows usage of all builtin modules <a href="#allows-usage-of-all-builtin-modules" id="allows-usage-of-all-builtin-modules"></a>
export NODE_FUNCTION_ALLOW_BUILTIN=*

# Allows usage of only crypto <a href="#allows-usage-of-only-crypto" id="allows-usage-of-only-crypto"></a>
export NODE_FUNCTION_ALLOW_BUILTIN=crypto

# Allows usage of only crypto and fs <a href="#allows-usage-of-only-crypto-and-fs" id="allows-usage-of-only-crypto-and-fs"></a>
export NODE_FUNCTION_ALLOW_BUILTIN=crypto,fs

# Allow usage of external npm modules. <a href="#allow-usage-of-external-npm-modules" id="allow-usage-of-external-npm-modules"></a>
export NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash
```

{% hint style="info" %}
**If using Task Runners**

If n8n instance is setup with [Task Runners](/deploy/host-n8n/configure-n8n/set-up-task-runners), add the environment variables to the Task Runners instead to the main n8n node.
{% endhint %}

Refer to [Environment variables reference](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/nodes) for more information on these variables.

## Related resources

* [Configuration examples](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples)


# Set the timezone

Change the default timezone for your self-hosted n8n instance.

The default timezone is America/New\_York. For instance, the Schedule node uses it to know at what time the workflow should start. To set a different default timezone, set `GENERIC_TIMEZONE` to the appropriate value. For example, if you want to set the timezone to Berlin (Germany):

```bash
export GENERIC_TIMEZONE=Europe/Berlin
```

Refer to [the list of timezone names](https://momentjs.com/timezone/) to find your timezone.

Refer to [Environment variables reference](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/timezone-and-localization) for more information on this variable.

## Related resources

* [Configuration examples](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples)


# Specify user folder path

Specify location of the folder that stores user-specific data.

n8n saves user-specific data like the encryption key, SQLite database file, and the ID of the tunnel (if used) in the subfolder `.n8n` of the user who started n8n. It's possible to overwrite the user-folder using an environment variable.

```bash
export N8N_USER_FOLDER=/home/jim/n8n
```

Refer to [Environment variables reference](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/deployment) for more information on this variable.

## Related resources

* [Configuration examples](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples)


# Configure webhook URLs with reverse proxy

Customize n8n webhook URLs for compatibility with reverse proxy setups.

n8n creates the webhook URL by combining `N8N_PROTOCOL`, `N8N_HOST` and `N8N_PORT`. If n8n runs behind a reverse proxy, that won't work. That's because n8n runs internally on port 5678 but the reverse proxy exposes it to the web on port 443.

When running n8n behind a reverse proxy, it's important to do the following:

* set the webhook URL manually with the `N8N_WEBHOOK_URL` environment variable so that n8n can display it in the editor UI and register the correct webhook URLs with external services. (`N8N_WEBHOOK_URL` replaces `WEBHOOK_URL`, which is deprecated from n8n 2.35.0; n8n logs a deprecation warning if you still use `WEBHOOK_URL`.)
* Set the `N8N_PROXY_HOPS` environment variable to `1`.
* On the last proxy on the request path, set the following headers to pass on information about the initial request:
  * [`X-Forwarded-For`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-For)
  * [`X-Forwarded-Host`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-Host)
  * [`X-Forwarded-Proto`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-Proto)

```bash
export N8N_WEBHOOK_URL=https://n8n.example.com/
export N8N_PROXY_HOPS=1
```

Refer to [Environment variables reference](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/endpoints) for more information on this variable.

If you also run n8n's [instance-level MCP server](/connect/connect-to-n8n-mcp-server) behind the same reverse proxy, make sure it forwards the [MCP request headers](/connect/connect-to-n8n-mcp-server#mcp-request-headers) too.

## Serve forms from a separate hostname behind an authentication proxy

{% hint style="info" %}
**Feature availability**

`N8N_INSECURE_DISABLE_FORM_HTML_SANDBOX` is available from n8n 2.15.0.
{% endhint %}

Some authentication proxies, such as Google Identity-Aware Proxy, use a session cookie. To put n8n forms behind such a proxy, serve webhooks and forms from their own hostname. Then set [`N8N_INSECURE_DISABLE_FORM_HTML_SANDBOX`](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/security) to `true`. Ensure the conditions in [When it's safe to disable the form sandbox](#when-its-safe-to-disable-the-form-sandbox) are met.

The setting applies to every page that n8n serves as a form:

* Pages from the [n8n Form Trigger](/integrations/builtin/core-nodes/n8n-nodes-base.formtrigger) and [n8n Form](/integrations/builtin/core-nodes/n8n-nodes-base.form) nodes, including form completion pages
* Forms from the [Wait](/integrations/builtin/core-nodes/n8n-nodes-base.wait#on-form-submitted) node when it resumes **On Form Submitted**
* Approval forms from the **Send and Wait for Response** operation of app nodes such as Slack and Microsoft Teams

### Why form submissions fail behind an authentication proxy

n8n serves form pages with a `sandbox` directive in the Content Security Policy (CSP) header. The sandbox gives the page an opaque origin. As a result, the browser sends the form submission with `Origin: null` and without cookies. The proxy doesn't get its session cookie and rejects the request. The form loads, but submitting it shows **Problem submitting response**, and no execution starts.

Setting `N8N_INSECURE_DISABLE_FORM_HTML_SANDBOX` to `true` removes the `sandbox` directive from form pages. The form page keeps its real origin, and the browser sends the proxy's session cookie with the submission.

### When it's safe to disable the form sandbox

{% hint style="danger" %}
**The form sandbox protects the people who open your forms**

Form pages can show HTML from the workflow, for example from **Custom HTML** form elements and completion pages. The sandbox stops that HTML from using the n8n session of the person who opens the form. Without the sandbox, if the form shares a hostname with the editor, a script on the page can send requests to n8n as that person.
{% endhint %}

Only set `N8N_INSECURE_DISABLE_FORM_HTML_SANDBOX` to `true` when all three conditions are true:

* `N8N_WEBHOOK_URL` and `N8N_EDITOR_BASE_URL` use different hostnames, for example `hooks.example.com` and `n8n.example.com`. A different port on the same hostname isn't enough, because browsers share cookies across ports.
* The webhook hostname serves only webhook and form paths. Configure your proxy so that the editor and n8n's internal REST API (`/rest`) aren't reachable on it. Users don't sign in to n8n through the webhook hostname.
* n8n runs with `NODE_ENV=production`. The official n8n Docker image sets this for you. If you install n8n with npm, set it yourself. Without it, n8n runs in development mode and accepts cross-origin requests from any website.

By default, n8n serves webhooks and forms on these paths. If you changed them with the [endpoint environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/endpoints), use your values instead:

* Forms: `/form/`, `/form-test/`, and `/form-waiting/`, set by `N8N_ENDPOINT_FORM`, `N8N_ENDPOINT_FORM_TEST`, and `N8N_ENDPOINT_FORM_WAIT`
* Webhooks: `/webhook/`, `/webhook-test/`, and `/webhook-waiting/`, set by `N8N_ENDPOINT_WEBHOOK`, `N8N_ENDPOINT_WEBHOOK_TEST`, and `N8N_ENDPOINT_WEBHOOK_WAIT`

With this setup, the browser doesn't send the n8n session cookie to the webhook hostname. A script on the form page can't send authenticated requests to n8n on the editor hostname.

### Example configuration for forms on a separate hostname

This example serves the editor on `n8n.example.com`, and webhooks and forms on `hooks.example.com`:

```bash
# The editor stays on the main hostname
export N8N_EDITOR_BASE_URL=https://n8n.example.com/
# Webhooks and forms use their own hostname, behind the authentication proxy
export N8N_WEBHOOK_URL=https://hooks.example.com/
export N8N_PROXY_HOPS=1
# Required: without it, n8n runs in development mode
export NODE_ENV=production
export N8N_INSECURE_DISABLE_FORM_HTML_SANDBOX=true
```

`N8N_WEBHOOK_URL` is available from n8n 2.30.0. On earlier versions, use `WEBHOOK_URL` instead.

### Test forms from the editor behind an authentication proxy

From n8n 2.47.0, the editor opens test forms on a webhook hostname behind an authentication proxy. When you select **Execute workflow** or **Execute step** on a workflow with an **n8n Form Trigger** node, the editor opens the test form in a new window. If you aren't signed in to the proxy yet, the proxy's sign-in page shows first. After you sign in, the form loads.

On earlier versions, the editor doesn't open the test form in this setup. To test the form, open the **n8n Form Trigger** node, copy its **Test URL**, and open it in a new browser tab.

## Related resources

* [Configuration examples](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples)


# Enable Prometheus metrics

Enable Prometheus metrics endpoint.

To collect and expose metrics, n8n uses the [prom-client](https://www.npmjs.com/package/prom-client) library.

The `/metrics` endpoint is disabled by default, but it's possible to enable it using the `N8N_METRICS` environment variable.

{% hint style="warning" %}
**Don't expose the metrics endpoint publicly**

Only expose the `/metrics` endpoint to internal services that consume the Prometheus data. Don't make it accessible on the public internet, as it can reveal sensitive operational data about your n8n instance.
{% endhint %}

```bash
export N8N_METRICS=true
```

Refer to the respective [Environment Variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/endpoints) (`N8N_METRICS_INCLUDE_*`) for configuring which metrics and labels should get exposed.

Both `main` and `worker` instances are able to expose metrics.

For guidance on connecting Grafana to Prometheus to visualize n8n metrics, refer to [Grafana](/deploy/host-n8n/keep-n8n-running/visualize-metrics-with-grafana).

## Queue metrics <a href="#queue-metrics" id="queue-metrics"></a>

To enable queue metrics, set the `N8N_METRICS_INCLUDE_QUEUE_METRICS` env var to `true`. You can adjust the refresh rate with `N8N_METRICS_QUEUE_METRICS_INTERVAL`.

n8n gathers these metrics from Bull and exposes them on the main instances. On multi-main setups, when aggregating queries, you can identify the leader using the `instance_role_leader` gauge, set to `1` for the leader main and `0` otherwise.

```
# HELP n8n_scaling_mode_queue_jobs_active Current number of jobs being processed across all workers in scaling mode. <a href="#help-n8nscalingmodequeuejobsactive-current-number-of-jobs-being-processed-across-all-workers-in-scaling-mode" id="help-n8nscalingmodequeuejobsactive-current-number-of-jobs-being-processed-across-all-workers-in-scaling-mode"></a>
# TYPE n8n_scaling_mode_queue_jobs_active gauge <a href="#type-n8nscalingmodequeuejobsactive-gauge" id="type-n8nscalingmodequeuejobsactive-gauge"></a>
n8n_scaling_mode_queue_jobs_active 0

# HELP n8n_scaling_mode_queue_jobs_completed Total number of jobs completed across all workers in scaling mode since instance start. <a href="#help-n8nscalingmodequeuejobscompleted-total-number-of-jobs-completed-across-all-workers-in-scaling-mode-since-instance-start" id="help-n8nscalingmodequeuejobscompleted-total-number-of-jobs-completed-across-all-workers-in-scaling-mode-since-instance-start"></a>
# TYPE n8n_scaling_mode_queue_jobs_completed counter <a href="#type-n8nscalingmodequeuejobscompleted-counter" id="type-n8nscalingmodequeuejobscompleted-counter"></a>
n8n_scaling_mode_queue_jobs_completed 0

# HELP n8n_scaling_mode_queue_jobs_failed Total number of jobs failed across all workers in scaling mode since instance start. <a href="#help-n8nscalingmodequeuejobsfailed-total-number-of-jobs-failed-across-all-workers-in-scaling-mode-since-instance-start" id="help-n8nscalingmodequeuejobsfailed-total-number-of-jobs-failed-across-all-workers-in-scaling-mode-since-instance-start"></a>
# TYPE n8n_scaling_mode_queue_jobs_failed counter <a href="#type-n8nscalingmodequeuejobsfailed-counter" id="type-n8nscalingmodequeuejobsfailed-counter"></a>
n8n_scaling_mode_queue_jobs_failed 0

# HELP n8n_scaling_mode_queue_jobs_waiting Current number of enqueued jobs waiting for pickup in scaling mode. <a href="#help-n8nscalingmodequeuejobswaiting-current-number-of-enqueued-jobs-waiting-for-pickup-in-scaling-mode" id="help-n8nscalingmodequeuejobswaiting-current-number-of-enqueued-jobs-waiting-for-pickup-in-scaling-mode"></a>
# TYPE n8n_scaling_mode_queue_jobs_waiting gauge <a href="#type-n8nscalingmodequeuejobswaiting-gauge" id="type-n8nscalingmodequeuejobswaiting-gauge"></a>
n8n_scaling_mode_queue_jobs_waiting 0
```

If you deploy n8n on AWS using the [terraform-aws-n8n](https://github.com/n8n-io/terraform-aws-n8n) module, see [Configure Enterprise features on AWS](/deploy/host-n8n/install-options/use-a-cloud-provider/deploy-to-aws-with-terraform/use-enterprise-features-on-aws#prometheus-metrics) for the module-specific setup, including Bull queue depth metrics.

## Related resources

* [Configuration examples](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples)


# Pre-configure Microsoft OAuth credentials

Use credential overwrites to pre-configure Microsoft OAuth2 credentials in n8n so users can connect without their own app registration.

After [setting up a Microsoft Entra ID app registration with delegated access](/integrations/builtin/credentials/microsoftentra#delegated-access-for-organisation-wide-microsoft-integrations), you can use [credential overwrites](/administer/manage-credentials/credential-overwrites) to inject the Client ID and Client Secret into n8n at startup. This means users in your organisation can connect to Microsoft services without completing their own OAuth app registration.

n8n supports three environment variables for credential overwrites. This guide uses `CREDENTIALS_OVERWRITE_DATA_FILE`. Refer to [Credentials environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/credentials) for the full variable reference.

## Create the credentials file <a href="#create-the-credentials-file" id="create-the-credentials-file"></a>

On the host running n8n, create a file named `credentials-overwrite.json` in the same directory as your `docker-compose.yaml`.

The file contains a JSON object keyed by the n8n credential type name. For example, to pre-configure Microsoft Outlook:

```json
{
  "microsoftOutlookOAuth2Api": {
    "clientId": "YOUR_CLIENT_ID",
    "clientSecret": "YOUR_CLIENT_SECRET"
  }
}
```

To pre-configure multiple Microsoft services at once, add each credential type as a separate key:

```json
{
  "microsoftOutlookOAuth2Api": {
    "clientId": "YOUR_CLIENT_ID",
    "clientSecret": "YOUR_CLIENT_SECRET"
  },
  "microsoftOneDriveOAuth2Api": {
    "clientId": "YOUR_CLIENT_ID",
    "clientSecret": "YOUR_CLIENT_SECRET"
  }
}
```

{% hint style="info" %}
**Minified JSON**

n8n requires the JSON to be minified (no spaces or newlines). The examples above are formatted for readability. Make sure your actual file contains no extra whitespace:

```json
{"microsoftOutlookOAuth2Api":{"clientId":"YOUR_CLIENT_ID","clientSecret":"YOUR_CLIENT_SECRET"}}
```

{% endhint %}

Refer to [Required scopes by integration](/integrations/builtin/credentials/microsoftentra#required-scopes-by-integration) for the credential type name of each Microsoft service.

## Docker Compose <a href="#docker-compose" id="docker-compose"></a>

Mount the credentials file as a read-only volume and set the environment variable in your `compose.yaml`:

```yaml
services:
  n8n:
    image: n8nio/n8n:latest
    container_name: n8n
    restart: always
    ports:
      - "5678:5678"
    environment:
      - GENERIC_TIMEZONE=America/New_York
      - TZ=America/New_York
      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
      - N8N_LOG_LEVEL=debug
      - N8N_LOG_OUTPUT=file,console
      - N8N_LOG_FILE_COUNT_MAX=5
      - CREDENTIALS_OVERWRITE_DATA_FILE=/run/secrets/credentials-overwrite.json
    volumes:
      - n8n_data:/home/node/.n8n
      - ./credentials-overwrite.json:/run/secrets/credentials-overwrite.json:ro
    networks:
      - default
volumes:
  n8n_data:
    name: ${N8N_VOLUME:-n8n_data}
    external: true
```

Apply the changes by restarting the container:

```bash
docker compose up -d
```

## Verify the overwrite is applied <a href="#verify-the-overwrite-is-applied" id="verify-the-overwrite-is-applied"></a>

After n8n starts, have a user create a new credential for one of the pre-configured services (for example, Microsoft Outlook). They should see a **Managed OAuth2 (recommended)** option in the credential selection.

![Microsoft Entra credentials screen](https://2773773108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fjm0ZYRpZIPWge2ZSiDYO%2Fuploads%2Fgit-blob-496fa5f4883e7585a12562fc7e42fe48d3e78bca%2Fmicrosoft-entra-oauth.png?alt=media)

The user can click **Connect to Microsoft Outlook**, with no auth required. An **Account connected** message should appear

If the **Managed OAuth 2** option doesn't appear, the environment variable wasn't applied correctly. Check that the file path in the volume mount matches the value of `CREDENTIALS_OVERWRITE_DATA_FILE`.

## Kubernetes <a href="#kubernetes" id="kubernetes"></a>

For Kubernetes deployments, replace the Docker volume mount with Kubernetes-native primitives. The approach differs by cloud provider. Choose the section that matches your environment.

### Plain Kubernetes Secret (EKS / AKS / GKE) <a href="#plain-kubernetes-secret-eks-aks-gke" id="plain-kubernetes-secret-eks-aks-gke"></a>

This approach works across all three managed Kubernetes providers without additional dependencies.

**1. Create the Secret:**

```yaml
apiVersion: v1
kind: Secret
metadata:
  name: n8n-credentials-overwrite
  namespace: your-namespace
type: Opaque
stringData:
  credentials-overwrite.json: '{"microsoftOutlookOAuth2Api":{"clientId":"YOUR_CLIENT_ID","clientSecret":"YOUR_CLIENT_SECRET"}}'
```

**2. Mount the Secret in your Deployment:**

```yaml
spec:
  containers:
    - name: n8n
      image: n8nio/n8n:latest
      env:
        - name: CREDENTIALS_OVERWRITE_DATA_FILE
          value: /run/secrets/credentials-overwrite.json
        # ...your other env vars
      volumeMounts:
        - name: credentials-overwrite
          mountPath: /run/secrets/credentials-overwrite.json
          subPath: credentials-overwrite.json
          readOnly: true
  volumes:
    - name: credentials-overwrite
      secret:
        secretName: n8n-credentials-overwrite
```

The `subPath` field is important. Without it, Kubernetes replaces the entire `/run/secrets/` directory rather than mounting just the single file.

{% hint style="info" %}
**Alternative: inline environment variable**

To skip the volume mount entirely, reference the Secret directly as an environment variable:

```yaml
env:
  - name: CREDENTIALS_OVERWRITE_DATA
    valueFrom:
      secretKeyRef:
        name: n8n-credentials-overwrite
        key: credentials-overwrite.json
```

```yaml
stringData:
  credentials-json: '{"microsoftOutlookOAuth2Api":{"clientId":"...","clientSecret":"..."}}'
```

This is cleaner for single-service setups, but note that some Kubernetes environments restrict environment variable size (for example, to 128KB per variable). The file-based approach is safer if you have many credential overwrites.
{% endhint %}

### AWS Secrets Manager (EKS) <a href="#aws-secrets-manager-eks" id="aws-secrets-manager-eks"></a>

This approach uses the [AWS Secrets Store CSI Driver](https://docs.aws.amazon.com/secretsmanager/latest/userguide/integrating_csi_driver.html) to mount a secret from AWS Secrets Manager directly into the pod. It adds rotation support, CloudTrail audit logging, and centralised secret management.

**Prerequisites:**

* Secrets Store CSI Driver and ASCP (AWS Secrets and Configuration Provider) installed on the cluster
* IAM OIDC provider configured for the cluster (required for IRSA)
* An IAM role with `secretsmanager:GetSecretValue` and `secretsmanager:DescribeSecret` permissions

**1. Create the secret in AWS Secrets Manager:**

```bash
aws secretsmanager create-secret \
  --name n8n/credentials-overwrite \
  --description "n8n credential overwrites for Microsoft OAuth" \
  --secret-string '{"microsoftOutlookOAuth2Api":{"clientId":"YOUR_CLIENT_ID","clientSecret":"YOUR_CLIENT_SECRET"}}'
```

**2. Create an IAM policy:**

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "secretsmanager:GetSecretValue",
        "secretsmanager:DescribeSecret"
      ],
      "Resource": "arn:aws:secretsmanager:REGION:ACCOUNT_ID:secret:n8n/credentials-overwrite-*"
    }
  ]
}
```

```bash
aws iam create-policy \
  --policy-name n8n-credentials-overwrite-read \
  --policy-document file://policy.json
```

**3. Create a service account with IRSA:**

```bash
eksctl create iamserviceaccount \
  --name n8n-sa \
  --namespace your-namespace \
  --cluster your-cluster \
  --attach-policy-arn arn:aws:iam::ACCOUNT_ID:policy/n8n-credentials-overwrite-read \
  --approve
```

**4. Create the SecretProviderClass:**

```yaml
apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
  name: n8n-credentials-overwrite
  namespace: your-namespace
spec:
  provider: aws
  parameters:
    objects: |
      - objectName: "n8n/credentials-overwrite"
        objectType: "secretsmanager"
        objectAlias: "credentials-overwrite.json"
```

**5. Update your n8n Deployment:**

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: n8n
  namespace: your-namespace
spec:
  template:
    spec:
      serviceAccountName: n8n-sa
      containers:
        - name: n8n
          image: n8nio/n8n:latest
          env:
            - name: CREDENTIALS_OVERWRITE_DATA_FILE
              value: /run/secrets/credentials-overwrite.json
          volumeMounts:
            - name: credentials-overwrite
              mountPath: /run/secrets/credentials-overwrite.json
              subPath: credentials-overwrite.json
              readOnly: true
      volumes:
        - name: credentials-overwrite
          csi:
            driver: secrets-store.csi.k8s.io
            readOnly: true
            volumeAttributes:
              secretProviderClass: n8n-credentials-overwrite
```

**Rotating the secret:**

To update the credentials, update the value in Secrets Manager:

```bash
aws secretsmanager update-secret \
  --secret-id n8n/credentials-overwrite \
  --secret-string '{"microsoftOutlookOAuth2Api":{"clientId":"NEW_CLIENT_ID","clientSecret":"NEW_CLIENT_SECRET"}}'
```

The CSI driver syncs the updated value on its polling interval (default two minutes). Restart the n8n pod for n8n to read the updated file, as n8n reads the credentials file at startup.

### Azure Key Vault (AKS) <a href="#azure-key-vault-aks" id="azure-key-vault-aks"></a>

This approach uses the [Azure Key Vault Provider for the Secrets Store CSI Driver](https://learn.microsoft.com/en-us/azure/aks/csi-secrets-store-driver) to mount secrets from Azure Key Vault into the pod.

**Prerequisites:**

* Secrets Store CSI Driver and Azure Key Vault Provider addon enabled on the AKS cluster
* An Azure Key Vault instance
* A managed identity or service principal with access to the vault
* Workload Identity enabled on the cluster (recommended over pod identity)

**1. Create or use an existing Key Vault:**

```bash
az keyvault create \
  --name n8n-credentials-vault \
  --resource-group your-resource-group \
  --location your-region
```

**2. Create the secret in Key Vault:**

```bash
az keyvault secret set \
  --vault-name n8n-credentials-vault \
  --name n8n-credentials-overwrite \
  --value '{"microsoftOutlookOAuth2Api":{"clientId":"YOUR_CLIENT_ID","clientSecret":"YOUR_CLIENT_SECRET"}}'
```

**3. Set up Workload Identity:**

Create a managed identity and establish the federated credential:

```bash
# Create a managed identity <a href="#create-a-managed-identity" id="create-a-managed-identity"></a>
az identity create \
  --name n8n-workload-identity \
  --resource-group your-resource-group \
  --location your-region

# Get the identity client ID <a href="#get-the-identity-client-id" id="get-the-identity-client-id"></a>
CLIENT_ID=$(az identity show \
  --name n8n-workload-identity \
  --resource-group your-resource-group \
  --query clientId -o tsv)

# Grant the identity access to the Key Vault <a href="#grant-the-identity-access-to-the-key-vault" id="grant-the-identity-access-to-the-key-vault"></a>
az keyvault set-policy \
  --name n8n-credentials-vault \
  --secret-permissions get \
  --spn "$CLIENT_ID"

# Get the OIDC issuer URL for your cluster <a href="#get-the-oidc-issuer-url-for-your-cluster" id="get-the-oidc-issuer-url-for-your-cluster"></a>
OIDC_ISSUER=$(az aks show \
  --name your-cluster \
  --resource-group your-resource-group \
  --query "oidcIssuerProfile.issuerUrl" -o tsv)

# Create the federated credential <a href="#create-the-federated-credential" id="create-the-federated-credential"></a>
az identity credential create \
  --name n8n-workload-identity \
  --resource-group your-resource-group \
  --issuer "$OIDC_ISSUER" \
  --subject system:serviceaccount:your-namespace:n8n-sa \
  --audience api://AzureADTokenExchange
```

**4. Create the Kubernetes ServiceAccount:**

```yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: n8n-sa
  namespace: your-namespace
  annotations:
    azure.workload.identity/client-id: "YOUR_MANAGED_IDENTITY_CLIENT_ID"
  labels:
    azure.workload.identity/use: "true"
```

**5. Create the SecretProviderClass:**

```yaml
apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
  name: n8n-credentials-overwrite
  namespace: your-namespace
spec:
  provider: azure
  parameters:
    usePodIdentity: "false"
    useWorkloadIdentity: "true"
    clientID: "YOUR_MANAGED_IDENTITY_CLIENT_ID"
    keyvaultName: "n8n-credentials-vault"
    objects: |
      array:
        - |
          objectName: n8n-credentials-overwrite
          objectType: secret
          objectAlias: credentials-overwrite.json
    tenantId: "YOUR_TENANT_ID"
```

**6. Update your n8n Deployment:**

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: n8n
  namespace: your-namespace
spec:
  template:
    spec:
      serviceAccountName: n8n-sa
      containers:
        - name: n8n
          image: n8nio/n8n:latest
          env:
            - name: CREDENTIALS_OVERWRITE_DATA_FILE
              value: /run/secrets/credentials-overwrite.json
          volumeMounts:
            - name: credentials-overwrite
              mountPath: /run/secrets/credentials-overwrite.json
              subPath: credentials-overwrite.json
              readOnly: true
      volumes:
        - name: credentials-overwrite
          csi:
            driver: secrets-store.csi.k8s.io
            readOnly: true
            volumeAttributes:
              secretProviderClass: n8n-credentials-overwrite
```

**Rotating the secret:**

```bash
az keyvault secret set \
  --vault-name n8n-credentials-vault \
  --name n8n-credentials-overwrite \
  --value '{"microsoftOutlookOAuth2Api":{"clientId":"NEW_CLIENT_ID","clientSecret":"NEW_CLIENT_SECRET"}}'
```

The CSI driver syncs on its polling interval (default two minutes). Restart the n8n pod afterward for n8n to pick up the updated file.

### Google Secret Manager (GKE) <a href="#google-secret-manager-gke" id="google-secret-manager-gke"></a>

This approach uses the [GCP provider for the Secrets Store CSI Driver](https://github.com/GoogleCloudPlatform/secrets-store-csi-driver-provider-gcp) to mount secrets from Google Secret Manager into the pod.

**Prerequisites:**

* A GKE cluster with Workload Identity Federation enabled
* The Secret Manager API enabled on the project
* A Google service account with the `secretmanager.secretAccessor` role

**1. Enable the Secret Manager API:**

```bash
gcloud services enable secretmanager.googleapis.com \
  --project your-project-id
```

**2. Create the secret:**

```bash
echo -n '{"microsoftOutlookOAuth2Api":{"clientId":"YOUR_CLIENT_ID","clientSecret":"YOUR_CLIENT_SECRET"}}' | \
  gcloud secrets create n8n-credentials-overwrite \
    --data-file=- \
    --project your-project-id
```

**3. Set up Workload Identity Federation:**

```bash
# Create a Google service account <a href="#create-a-google-service-account" id="create-a-google-service-account"></a>
gcloud iam service-accounts create n8n-secret-reader \
  --display-name="n8n Secret Reader" \
  --project your-project-id

# Grant it access to the secret <a href="#grant-it-access-to-the-secret" id="grant-it-access-to-the-secret"></a>
gcloud secrets add-iam-policy-binding n8n-credentials-overwrite \
  --member="serviceAccount:n8n-secret-reader@your-project-id.iam.gserviceaccount.com" \
  --role="roles/secretmanager.secretAccessor" \
  --project your-project-id

# Bind the Kubernetes service account to the Google service account <a href="#bind-the-kubernetes-service-account-to-the-google-service-account" id="bind-the-kubernetes-service-account-to-the-google-service-account"></a>
gcloud iam service-accounts add-iam-policy-binding \
  n8n-secret-reader@your-project-id.iam.gserviceaccount.com \
  --role="roles/iam.workloadIdentityUser" \
  --member="serviceAccount:your-project-id.svc.id.goog[your-namespace/n8n-sa]"
```

**4. Create the Kubernetes ServiceAccount:**

```yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: n8n-sa
  namespace: your-namespace
  annotations:
    iam.gke.io/gcp-service-account: n8n-secret-reader@your-project-id.iam.gserviceaccount.com
```

**5. Install the CSI Driver and GCP provider:**

```bash
# Install the CSI driver <a href="#install-the-csi-driver" id="install-the-csi-driver"></a>
helm repo add secrets-store-csi-driver https://kubernetes-sigs.github.io/secrets-store-csi-driver/charts
helm install csi-secrets-store secrets-store-csi-driver/secrets-store-csi-driver \
  --namespace kube-system

# Install the GCP provider <a href="#install-the-gcp-provider" id="install-the-gcp-provider"></a>
kubectl apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/secrets-store-csi-driver-provider-gcp/main/deploy/provider-gcp-plugin.yaml
```

**6. Create the SecretProviderClass:**

```yaml
apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
  name: n8n-credentials-overwrite
  namespace: your-namespace
spec:
  provider: gcp
  parameters:
    secrets: |
      - resourceName: "projects/your-project-id/secrets/n8n-credentials-overwrite/versions/latest"
        path: "credentials-overwrite.json"
```

**7. Update your n8n Deployment:**

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: n8n
  namespace: your-namespace
spec:
  template:
    spec:
      serviceAccountName: n8n-sa
      containers:
        - name: n8n
          image: n8nio/n8n:latest
          env:
            - name: CREDENTIALS_OVERWRITE_DATA_FILE
              value: /run/secrets/credentials-overwrite.json
          volumeMounts:
            - name: credentials-overwrite
              mountPath: /run/secrets/credentials-overwrite.json
              subPath: credentials-overwrite.json
              readOnly: true
      volumes:
        - name: credentials-overwrite
          csi:
            driver: secrets-store.csi.k8s.io
            readOnly: true
            volumeAttributes:
              secretProviderClass: n8n-credentials-overwrite
```

**Rotating the secret:**

Create a new version of the secret:

```bash
echo -n '{"microsoftOutlookOAuth2Api":{"clientId":"NEW_CLIENT_ID","clientSecret":"NEW_CLIENT_SECRET"}}' | \
  gcloud secrets versions add n8n-credentials-overwrite \
    --data-file=- \
    --project your-project-id
```

Because the SecretProviderClass references `versions/latest`, the CSI driver picks up the new version on its next sync. Restart the n8n pod for n8n to read the updated file.

## Related resources

* [Configuration examples](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples)


# Configure a custom workflow templates library

Set up a custom workflow template library for your self-hosted n8n instance.

n8n provides a library of workflow templates[^1]. When self-hosting n8n, you can:

* Continue to use n8n's workflow templates library (this is the default behavior)
* Disable workflow templates
* Create your own workflow templates library

## Disable workflow templates <a href="#disable-workflow-templates" id="disable-workflow-templates"></a>

In your environment variables, set `N8N_TEMPLATES_ENABLED` to false.

## Use your own workflow templates library <a href="#use-your-own-workflow-templates-library" id="use-your-own-workflow-templates-library"></a>

In your environment variables, set `N8N_TEMPLATES_HOST` to the base URL of your API.

#### Endpoints <a href="#endpoints" id="endpoints"></a>

Your API must provide the same endpoints and data structure as n8n's.

The endpoints are:

| Method | Path                          | Purpose                                      |
| ------ | ----------------------------- | -------------------------------------------- |
| GET    | `/templates/workflows/<id>`   | Fetch template metadata for preview/browsing |
| GET    | `/workflows/templates/<id>`   | Fetch workflow data to import onto canvas    |
| GET    | `/templates/search`           | Search for workflow templates                |
| GET    | `/templates/collections/<id>` | Get a specific template collection           |
| GET    | `/templates/collections`      | List all template collections                |
| GET    | `/templates/categories`       | List all template categories                 |
| GET    | `/health`                     | Health check endpoint                        |

{% hint style="warning" %}
**Critical: Two different response formats required**

The two workflow endpoints require **different response formats**:

* **`/templates/workflows/{id}`**: Returns the template itself, which includes the workflow in the `workflow` key
* **`/workflows/templates/{id}`**: Returns the workflow the template contains

See Schemas below for details.
{% endhint %}

#### Query parameters <a href="#query-parameters" id="query-parameters"></a>

The `/templates/search` endpoint accepts the following query parameters:

| Parameter  | Type                                         | Description                                      |
| ---------- | -------------------------------------------- | ------------------------------------------------ |
| `page`     | integer                                      | The page of results to return                    |
| `rows`     | integer                                      | The maximum number of results to return per page |
| `category` | comma-separated list of strings (categories) | The categories to search within                  |
| `search`   | string                                       | The search query                                 |

The `/templates/collections` endpoint accepts the following query parameters:

| Parameter  | Type                                         | Description                     |
| ---------- | -------------------------------------------- | ------------------------------- |
| `category` | comma-separated list of strings (categories) | The categories to search within |
| `search`   | string                                       | The search query                |

#### Schemas <a href="#schemas" id="schemas"></a>

The key difference between the two workflow endpoints:

```json
// GET /templates/workflows/{id} returns (wrapped):
{
  "workflow": {
    "id": 123,
    "name": "...",
    "totalViews": 1000,
    // ... see full workflow item schema below
    "workflow": {    // actual workflow definition
      "nodes": [...],
      "connections": {}
    }
  }
}

// GET /workflows/templates/{id} returns (flat):
{
  "id": 123,
  "name": "...",
  "workflow": {      // actual workflow definition
    "nodes": [...],
    "connections": {}
  }
}
```

Detailed schemas for response objects:

<details>

<summary>Show <code>workflow</code> item data schema</summary>

Used by `/templates/workflows/{id}` endpoint (wrapped in a `workflow` key).

This schema describes the template metadata used for displaying templates in search/browse UI. It includes a nested `workflow` property that contains the actual importable workflow definition.

```json
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Generated schema for Root",
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "totalViews": {
      "type": "number"
    },
    "price": {},
    "purchaseUrl": {},
    "recentViews": {
      "type": "number"
    },
    "createdAt": {
      "type": "string"
    },
    "user": {
      "type": "object",
      "properties": {
        "username": {
          "type": "string"
        },
        "verified": {
          "type": "boolean"
        }
      },
      "required": [
        "username",
        "verified"
      ]
    },
    "nodes": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "icon": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "codex": {
            "type": "object",
            "properties": {
              "data": {
                "type": "object",
                "properties": {
                  "details": {
                    "type": "string"
                  },
                  "resources": {
                    "type": "object",
                    "properties": {
                      "generic": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string"
                            },
                            "icon": {
                              "type": "string"
                            },
                            "label": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "url",
                            "label"
                          ]
                        }
                      },
                      "primaryDocumentation": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "url"
                          ]
                        }
                      }
                    },
                    "required": [
                      "primaryDocumentation"
                    ]
                  },
                  "categories": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "nodeVersion": {
                    "type": "string"
                  },
                  "codexVersion": {
                    "type": "string"
                  }
                },
                "required": [
                  "categories"
                ]
              }
            }
          },
          "group": {
            "type": "string"
          },
          "defaults": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "color": {
                "type": "string"
              }
            },
            "required": [
              "name"
            ]
          },
          "iconData": {
            "type": "object",
            "properties": {
              "icon": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "fileBuffer": {
                "type": "string"
              }
            },
            "required": [
              "type"
            ]
          },
          "displayName": {
            "type": "string"
          },
          "typeVersion": {
            "type": "number"
          },
          "nodeCategories": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "number"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "name"
              ]
            }
          }
        },
        "required": [
          "id",
          "icon",
          "name",
          "codex",
          "group",
          "defaults",
          "iconData",
          "displayName",
          "typeVersion"
        ]
      }
    },
    "description": {
      "type": "string"
    },
    "image": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "url": {
            "type": "string"
          }
        }
      }
    },
    "categories": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "name": {
            "type": "string"
          }
        }
      }
    },
    "workflowInfo": {
      "type": "object",
      "properties": {
        "nodeCount": {
          "type": "number"
        },
        "nodeTypes": {
          "type": "object"
        }
      }
    },
    "workflow": {
      "type": "object",
      "properties": {
        "nodes": {
          "type": "array"
        },
        "connections": {
          "type": "object"
        },
        "settings": {
          "type": "object"
        },
        "pinData": {
          "type": "object"
        }
      },
      "required": [
        "nodes",
        "connections"
      ]
    }
  },
  "required": [
    "id",
    "name",
    "totalViews",
    "createdAt",
    "user",
    "nodes",
    "workflow"
  ]
}
```

</details>

<details>

<summary>Show <code>category</code> item data schema</summary>

```json
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name"
  ]
}
```

</details>

<details>

<summary>Show <code>collection</code> item data schema</summary>

```json
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "rank": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "totalViews": {},
    "createdAt": {
      "type": "string"
    },
    "workflows": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          }
        },
        "required": [
          "id"
        ]
      }
    },
    "nodes": {
      "type": "array",
      "items": {}
    }
  },
  "required": [
    "id",
    "rank",
    "name",
    "totalViews",
    "createdAt",
    "workflows",
    "nodes"
  ]
}
```

</details>

You can also interactively explore n8n's API endpoints:

<https://api.n8n.io/templates/categories> <https://api.n8n.io/templates/collections> <https://api.n8n.io/templates/search> <https://api.n8n.io/health>

You can [contact us](mailto:help@n8n.io) for more support.

## Add your workflows to the n8n library <a href="#add-your-workflows-to-the-n8n-library" id="add-your-workflows-to-the-n8n-library"></a>

You can submit your workflows to n8n's template library.

n8n is working on a creator program, and developing a marketplace of templates. This is an ongoing project, and details are likely to change.

Refer to [n8n Creator hub](https://www.notion.so/n8n/n8n-Creator-hub-7bd2cbe0fce0449198ecb23ff4a2f76f) for information on how to submit templates and become a creator.

## Related resources

* [Configuration examples](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples)

[^1]: n8n templates are pre-built workflows designed by n8n and community members that you can import into your n8n instance. When using templates, you may need to fill in credentials and adjust the configuration to suit your needs.


# Choose n8n's database

By default, n8n uses SQLite to save credentials, past executions, and workflows. n8n also supports PostgresDB. Refer to [Supported PostgreSQL versions](#supported-postgresql-versions) for n8n's PostgreSQL version policy.

## Database type by n8n installation <a href="#database-type-by-n8n-installation" id="database-type-by-n8n-installation"></a>

The database type used varies depending on your n8n installation:

### Self-hosted n8n <a href="#self-hosted-n8n" id="self-hosted-n8n"></a>

By default, self-hosted installations use **SQLite**. You can optionally configure PostgreSQL by setting the appropriate environment variables (see [PostgresDB configuration](#postgresdb)).

### n8n Cloud <a href="#n8n-cloud" id="n8n-cloud"></a>

n8n Cloud installations use different databases depending on your plan tier:

* **SQLite**: Starter, Pro, and legacy Enterprise plans
* **PostgreSQL**: Enterprise Scaling plans only

## Shared settings <a href="#shared-settings" id="shared-settings"></a>

The following environment variables get used by all databases:

* `DB_TABLE_PREFIX` (default: -) - Prefix for table names

## PostgresDB <a href="#postgresdb" id="postgresdb"></a>

### Supported PostgreSQL versions <a href="#supported-postgresql-versions" id="supported-postgresql-versions"></a>

n8n supports:

* The latest two actively maintained PostgreSQL major versions (**17** and **18**, as of July 2026).
* One additional major version for compatibility (**16**).

Run the latest minor release within your major version.

Amazon Aurora PostgreSQL is **experimental**. n8n's hosting templates offer it for high-availability setups, where Aurora recovers faster when the primary database goes down. n8n doesn't test or certify Aurora, and n8n's PostgreSQL version support doesn't extend to it. Use upstream PostgreSQL unless you specifically need what Aurora offers.

n8n doesn't support other PostgreSQL-compatible derivatives, such as AlloyDB, CockroachDB, or YugabyteDB.

The PostgreSQL project retires its oldest maintained major version and releases a new one every November, so n8n's supported version range shifts each year. Check this page for the current supported versions, rather than relying on a specific version number you've seen elsewhere.

To use PostgresDB as the database, you can provide the following environment variables:

* `DB_TYPE=postgresdb`
* `DB_POSTGRESDB_DATABASE` (default: 'n8n')
* `DB_POSTGRESDB_HOST` (default: 'localhost')
* `DB_POSTGRESDB_PORT` (default: 5432)
* `DB_POSTGRESDB_USER` (default: 'postgres')
* `DB_POSTGRESDB_PASSWORD` (default: empty)
* `DB_POSTGRESDB_SCHEMA` (default: 'public')
* `DB_POSTGRESDB_SSL_CA` (default: undefined): Path to the server's CA certificate used to validate the connection (opportunistic encryption isn't supported)
* `DB_POSTGRESDB_SSL_CERT` (default: undefined): Path to the client's TLS certificate
* `DB_POSTGRESDB_SSL_KEY` (default: undefined): Path to the client's private key corresponding to the certificate
* `DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED` (default: true): If TLS connections that fail validation should be rejected

```bash
export DB_TYPE=postgresdb
export DB_POSTGRESDB_DATABASE=n8n
export DB_POSTGRESDB_HOST=postgresdb
export DB_POSTGRESDB_PORT=5432
export DB_POSTGRESDB_USER=n8n
export DB_POSTGRESDB_PASSWORD=n8n
export DB_POSTGRESDB_SCHEMA=n8n

# optional: <a href="#optional" id="optional"></a>
export DB_POSTGRESDB_SSL_CA_FILE=$(pwd)/ca.crt
export DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED=false

n8n start
```

### Required permissions <a href="#required-permissions" id="required-permissions"></a>

n8n needs to create and modify the schemas of the tables it uses.

Recommended permissions:

```sql
CREATE DATABASE n8n-db;
CREATE USER n8n-user WITH PASSWORD 'random-password';
GRANT ALL PRIVILEGES ON DATABASE n8n-db TO n8n-user;
```

### TLS <a href="#tls" id="tls"></a>

You can choose between these configurations:

* Not declaring (default): Connect with `SSL=off`
* Declaring only the CA and unauthorized flag: Connect with `SSL=on` and verify the server's signature
* Declaring `_{CERT,KEY}` and the above: Use the certificate and key for client TLS authentication

## SQLite <a href="#sqlite" id="sqlite"></a>

This is the default database that gets used if nothing is defined.

The database file is located at: `~/.n8n/database.sqlite`

## Related resources

* [Configure n8n](/deploy/host-n8n/configure-n8n)


# External hooks

Use external hooks to execute custom code whenever n8n runs a specific operation.

External hooks let you run custom code whenever n8n performs a specific operation. Use them to log data, change data, or forbid an action by throwing an error.

There are two types:

* **Backend hooks**: run server-side, registered using the `EXTERNAL_HOOK_FILES` environment variable.
* **Frontend hooks**: run in the browser, loaded with a script tag.

For the environment variables used to register hooks, refer to [External hooks environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/external-hooks).

## Backend hooks <a href="#backend-hooks" id="backend-hooks"></a>

### Available hooks <a href="#available-hooks" id="available-hooks"></a>

| Hook                      | Arguments                                                                                                                                                            | Description                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `credentials.create`      | `[credentialData: ICredentialsDb]`                                                                                                                                   | Called before new credentials get created. Use to restrict the number of credentials.                                                                                                                                                                                                                                                                                                                                                    |
| `credentials.delete`      | `[id: credentialId]`                                                                                                                                                 | Called before credentials get deleted.                                                                                                                                                                                                                                                                                                                                                                                                   |
| `credentials.update`      | `[credentialData: ICredentialsDb]`                                                                                                                                   | Called before n8n saves existing credentials.                                                                                                                                                                                                                                                                                                                                                                                            |
| `frontend.settings`       | `[frontendSettings: IN8nUISettings]`                                                                                                                                 | Gets called on n8n startup. Allows you to, for example, overwrite frontend data like the displayed OAuth URL.                                                                                                                                                                                                                                                                                                                            |
| `n8n.ready`               | `[app: App]`                                                                                                                                                         | Called once n8n is ready. Use to, for example, register custom API endpoints.                                                                                                                                                                                                                                                                                                                                                            |
| `n8n.stop`                |                                                                                                                                                                      | Called when an n8n process gets stopped. Allows you to save some process data.                                                                                                                                                                                                                                                                                                                                                           |
| `oauth1.authenticate`     | `[oAuthOptions: clientOAuth1.Options, oauthRequestData: {oauth_callback: string}]`                                                                                   | Called before an OAuth1 authentication. Use to overwrite an OAuth callback URL.                                                                                                                                                                                                                                                                                                                                                          |
| `oauth2.callback`         | `[oAuth2Parameters: {clientId: string, clientSecret: string \| undefined, accessTokenUri: string, authorizationUri: string, redirectUri: string, scopes: string[]}]` | Called in an OAuth2 callback. Use to overwrite an OAuth callback URL.                                                                                                                                                                                                                                                                                                                                                                    |
| `workflow.activate`       | `[workflowData: IWorkflowBase, workflowContext: WorkflowHookContextService, actor?: WorkflowLifecycleHookActor]`                                                     | Called before a workflow gets activated. Use to restrict the number of active workflows. Refer to [Workflow hook context](#workflow-hook-context) for the `workflowContext` argument and [Workflow lifecycle hook actor](#workflow-lifecycle-hook-actor) for the `actor` argument.                                                                                                                                                       |
| `workflow.afterCreate`    | `[workflowData: IWorkflowBase, workflowContext: WorkflowHookContextService, actor?: WorkflowLifecycleHookActor]`                                                     | Called after a workflow gets created. Refer to [Workflow hook context](#workflow-hook-context) for the `workflowContext` argument and [Workflow lifecycle hook actor](#workflow-lifecycle-hook-actor) for the `actor` argument.                                                                                                                                                                                                          |
| `workflow.afterDelete`    | `[workflowId: string, actor?: WorkflowLifecycleHookActor]`                                                                                                           | Called after a workflow gets deleted. Refer to [Workflow lifecycle hook actor](#workflow-lifecycle-hook-actor) for the `actor` argument.                                                                                                                                                                                                                                                                                                 |
| `workflow.afterUpdate`    | `[workflowData: IWorkflowBase, workflowContext: WorkflowHookContextService, actor?: WorkflowLifecycleHookActor]`                                                     | Called after an existing workflow gets saved. Refer to [Workflow hook context](#workflow-hook-context) for the `workflowContext` argument and [Workflow lifecycle hook actor](#workflow-lifecycle-hook-actor) for the `actor` argument.                                                                                                                                                                                                  |
| `workflow.create`         | `[workflowData: IWorkflowBase, workflowContext: WorkflowHookContextService, actor?: WorkflowLifecycleHookActor]`                                                     | Called before a workflow gets created. Use to restrict the number of saved workflows. Refer to [Workflow hook context](#workflow-hook-context) for the `workflowContext` argument and [Workflow lifecycle hook actor](#workflow-lifecycle-hook-actor) for the `actor` argument.                                                                                                                                                          |
| `workflow.deactivate`     | `[workflowData: IWorkflowBase, workflowContext: WorkflowHookContextService, actor?: WorkflowLifecycleHookActor]`                                                     | Called before a workflow gets deactivated, while `active` is still `true`. Throw an error to abort the deactivation and keep the workflow active. Available from n8n 2.33.1. Refer to [Workflow hook context](#workflow-hook-context) for the `workflowContext` argument and [Workflow lifecycle hook actor](#workflow-lifecycle-hook-actor) for the `actor` argument.                                                                   |
| `workflow.delete`         | `[workflowId: string, actor?: WorkflowLifecycleHookActor]`                                                                                                           | Called before a workflow gets deleted. Refer to [Workflow lifecycle hook actor](#workflow-lifecycle-hook-actor) for the `actor` argument.                                                                                                                                                                                                                                                                                                |
| `workflow.postExecute`    | `[fullRunData: IRun \| undefined, workflowData: IWorkflowBase, executionId: string, workflowContext: WorkflowHookContextService]`                                    | Called after a workflow gets executed. Refer to [Workflow hook context](#workflow-hook-context) for the `workflowContext` argument.                                                                                                                                                                                                                                                                                                      |
| `workflow.preExecute`     | `[workflow: Workflow, mode: WorkflowExecuteMode, workflowContext: WorkflowHookContextService]`                                                                       | Called before a workflow gets executed. Use it to count or limit workflow executions. If the hook throws, n8n never creates an execution record. Before n8n 3.0.0, set `N8N_PRE_EXECUTE_ERROR_CREATES_EXECUTION=true` to still create a failed execution when the hook throws. n8n 3.0.0 removes this variable. Refer to [Workflow hook context](#workflow-hook-context) for the `workflowContext` argument (available from n8n 2.23.0). |
| `workflow.update`         | `[workflowData: IWorkflowBase, workflowContext: WorkflowHookContextService, actor?: WorkflowLifecycleHookActor]`                                                     | Called before an existing workflow gets saved. Refer to [Workflow hook context](#workflow-hook-context) for the `workflowContext` argument and [Workflow lifecycle hook actor](#workflow-lifecycle-hook-actor) for the `actor` argument.                                                                                                                                                                                                 |
| `workflow.afterArchive`   | `[workflowId: string, actor?: WorkflowLifecycleHookActor]`                                                                                                           | Called after you archive a workflow. Refer to [Workflow lifecycle hook actor](#workflow-lifecycle-hook-actor) for the `actor` argument.                                                                                                                                                                                                                                                                                                  |
| `workflow.afterUnarchive` | `[workflowId: string, actor?: WorkflowLifecycleHookActor]`                                                                                                           | Called after you restore a workflow from the archive. Refer to [Workflow lifecycle hook actor](#workflow-lifecycle-hook-actor) for the `actor` argument.                                                                                                                                                                                                                                                                                 |

### Registering hooks <a href="#registering-hooks" id="registering-hooks"></a>

Set hooks by registering a hook file that contains the hook functions. To register a hook, set the environment variable `EXTERNAL_HOOK_FILES`.

You can set the variable to a single file:

`EXTERNAL_HOOK_FILES=/data/hook.js`

Or to contain multiple files separated by a colon:

`EXTERNAL_HOOK_FILES=/data/hook1.js:/data/hook2.js`

### Hook files <a href="#hook-files" id="hook-files"></a>

Hook files are regular JavaScript files that have the following format:

```js
module.exports = {
    "frontend": {
        "settings": [
            async function (settings) {
                settings.oauthCallbackUrls.oauth1 = 'https://n8n.example.com/oauth1/callback';
                settings.oauthCallbackUrls.oauth2 = 'https://n8n.example.com/oauth2/callback';
            }
        ]
    },
    "workflow": {
        "activate": [
            async function (workflowData) {
                const activeWorkflows = await this.dbCollections.Workflow.count({ active: true });

                if (activeWorkflows > 1) {
                    throw new Error(
                        'Active workflow limit reached.'
                    );
                }
            }
        ]
    }
}
```

### Hook examples <a href="#hook-examples" id="hook-examples"></a>

#### Block workflow execution if a required tag is missing <a href="#block-workflow-execution-if-a-required-tag-is-missing" id="block-workflow-execution-if-a-required-tag-is-missing"></a>

Please note: the `workflowContext` argument is supplied to `workflow.preExecute` hooks from n8n 2.23.0. Refer to [Workflow hook context](#workflow-hook-context) for the full list of hooks that receive it and from which version.

Use `workflow.preExecute` to abort execution when a workflow doesn't have a required tag:

```js
module.exports = {
	workflow: {
		preExecute: [
			async function (workflow, mode, workflowContext) {
				const requiredTag = 'exampleTag';
				const workflowTags = await workflowContext.getWorkflowTags(workflow.id);
				if (!workflowTags.includes(requiredTag)) {
					throw new Error(`Workflow is missing required tag "${requiredTag}", aborting`);
				}
			},
		],
	},
};
```

### Workflow hook context

Some workflow hooks receive a `workflowContext` argument, an instance of `WorkflowHookContextService`. It exposes helper methods you can call inside the hook function.

{% hint style="info" %}
**Available from n8n 2.23.0**

n8n passes `workflowContext` to the `workflow.preExecute` hook.
{% endhint %}

{% hint style="info" %}
**Available from n8n 2.33.1**

n8n passes `workflowContext` to the `workflow.create`, `workflow.afterCreate`, `workflow.activate`, `workflow.deactivate`, `workflow.update`, `workflow.afterUpdate`, and `workflow.postExecute` hooks.
{% endhint %}

The context provides these methods:

| Method                                                         | Returns             | Description                                                                                                                                                                                                                                                                                                        |
| -------------------------------------------------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `getWorkflowTags(workflowId: string)`                          | `Promise<string[]>` | Returns the names of the tags attached to the given workflow.                                                                                                                                                                                                                                                      |
| `resolveIsTriggerNodeType(type: string, typeVersion?: number)` | `boolean`           | Returns `true` if the given node type is a trigger. `type` is the fully qualified node type name, for example `n8n-nodes-base.manualTrigger`. `typeVersion` defaults to the latest registered version. Returns `false` when n8n can't resolve the node type, for example when it isn't registered on the instance. |

This example uses `resolveIsTriggerNodeType` to block activating a workflow that doesn't contain a trigger node:

```js
module.exports = {
	workflow: {
		activate: [
			async function (workflowData, workflowContext) {
				const hasTrigger = workflowData.nodes.some((node) =>
					workflowContext.resolveIsTriggerNodeType(node.type, node.typeVersion),
				);
				if (!hasTrigger) {
					throw new Error('Workflow must contain a trigger node, aborting activation');
				}
			},
		],
	},
};
```

### Workflow lifecycle hook actor

Some workflow lifecycle hooks receive an `actor` argument, a minimal projection of the user who performed the operation. Use it to attribute the action, for example to allow or reject an operation based on the user's identity or role.

{% hint style="info" %}
**Available from n8n 2.33.1**

n8n passes `actor` to the `workflow.create`, `workflow.afterCreate`, `workflow.activate`, `workflow.deactivate`, `workflow.update`, `workflow.afterUpdate`, `workflow.delete`, `workflow.afterDelete`, `workflow.afterArchive`, and `workflow.afterUnarchive` hooks. The argument is optional and can be `undefined` when n8n can't determine the acting user.
{% endhint %}

The `actor` object has these properties:

| Property    | Type             | Description                                                                                 |
| ----------- | ---------------- | ------------------------------------------------------------------------------------------- |
| `id`        | `string`         | The user's unique ID.                                                                       |
| `email`     | `string \| null` | The user's email address. Can be `null`, for example for a user invited but not yet set up. |
| `firstName` | `string \| null` | The user's first name. Can be `null`, for example for a user invited but not yet set up.    |
| `lastName`  | `string \| null` | The user's last name. Can be `null`, for example for a user invited but not yet set up.     |
| `role`      | `string`         | The user's role slug, for example `global:admin`. Optional.                                 |

This example uses `actor` to log who deleted a workflow:

```js
module.exports = {
	workflow: {
		delete: [
			async function (workflowId, actor) {
				console.log(`Workflow ${workflowId} deleted by ${actor?.email} (${actor?.role})`);
			},
		],
	},
};
```

### Hook functions <a href="#hook-functions" id="hook-functions"></a>

A hook or a hook file can contain multiple hook functions, with all functions executed one after another.

If the parameters of the hook function are objects, it's possible to change the data of that parameter to change the behavior of n8n.

You can also access the database in any hook function using `this.dbCollections` (refer to the code sample in [Hook files](#hook-files) above).

## Frontend external hooks <a href="#frontend-external-hooks" id="frontend-external-hooks"></a>

Like backend external hooks, it's possible to define external hooks in the frontend code that get executed by n8n whenever a user performs a specific operation. You can use them, for example, to log data and change data.

### Available hooks <a href="#available-hooks" id="available-hooks"></a>

| Hook                                       | Description                                                                 |
| ------------------------------------------ | --------------------------------------------------------------------------- |
| `credentialsEdit.credentialTypeChanged`    | Called when an existing credential's type changes.                          |
| `credentials.create`                       | Called when someone creates a new credential.                               |
| `credentialsList.dialogVisibleChanged`     |                                                                             |
| `dataDisplay.nodeTypeChanged`              |                                                                             |
| `dataDisplay.onDocumentationUrlClick`      | Called when someone selects the help documentation link.                    |
| `execution.open`                           | Called when an existing execution opens.                                    |
| `executionsList.openDialog`                | Called when someone selects an execution from existing Workflow Executions. |
| `expressionEdit.itemSelected`              |                                                                             |
| `expressionEdit.dialogVisibleChanged`      |                                                                             |
| `nodeCreateList.filteredNodeTypesComputed` |                                                                             |
| `nodeCreateList.nodeFilterChanged`         | Called when someone makes any changes to the node panel filter.             |
| `nodeCreateList.selectedTypeChanged`       |                                                                             |
| `nodeCreateList.mounted`                   |                                                                             |
| `nodeCreateList.destroyed`                 |                                                                             |
| `nodeSettings.credentialSelected`          |                                                                             |
| `nodeSettings.valueChanged`                |                                                                             |
| `nodeView.createNodeActiveChanged`         |                                                                             |
| `nodeView.addNodeButton`                   |                                                                             |
| `nodeView.mount`                           |                                                                             |
| `pushConnection.executionFinished`         |                                                                             |
| `showMessage.showError`                    |                                                                             |
| `runData.displayModeChanged`               |                                                                             |
| `workflow.activeChange`                    |                                                                             |
| `workflow.activeChangeCurrent`             |                                                                             |
| `workflow.afterUpdate`                     | Called when someone updates an existing workflow.                           |
| `workflow.open`                            |                                                                             |
| `workflowRun.runError`                     |                                                                             |
| `workflowRun.runWorkflow`                  | Called when a workflow executes.                                            |
| `workflowSettings.dialogVisibleChanged`    |                                                                             |
| `workflowSettings.saveSettings`            | Called when someone saves the settings of a workflow.                       |

### Registering frontend hooks <a href="#registering-frontend-hooks" id="registering-frontend-hooks"></a>

You can set hooks by loading the hooks script on the page. One way to do this is by creating a hooks file in the project and adding a script tag in your `editor-ui/public/index.html` file:

```html
<script src="frontend-hooks.js"></script>
```

### Frontend hook files <a href="#frontend-hook-files" id="frontend-hook-files"></a>

Frontend external hook files are regular JavaScript files which have the following format:

```js
window.n8nExternalHooks = {
  nodeView: {
    mount: [
      function (store, meta) {
        // do something
      },
    ],
    createNodeActiveChanged: [
      function (store, meta) {
        // do something
      },
      function (store, meta) {
        // do something else
      },
    ],
    addNodeButton: [
      function (store, meta) {
        // do something
      },
    ],
  },
};
```

### Frontend hook functions <a href="#frontend-hook-functions" id="frontend-hook-functions"></a>

You can define multiple hook functions per hook. n8n calls each hook function with the following arguments:

* `store`: The Vuex store object. You can use this to change or get data from the store.
* `metadata`: The object that contains any data provided by the hook. To see what's passed, search for the hook in the `editor-ui` package.

## Related resources

* [Configure n8n](/deploy/host-n8n/configure-n8n)


# Use the command line

Commands available in the Server CLI, the built-in n8n command-line interface.

The **Server CLI** is a built-in command-line interface that runs on the same machine as your n8n installation. It provides direct database access for administrative tasks and can execute most commands even when n8n isn't running.

{% hint style="info" %}
**n8n CLI**

Looking to interact with n8n programmatically from a remote machine or integrate with AI agents? Check out the [n8n CLI](https://docs.n8n.io/connect/).
{% endhint %}

## When to use Server CLI vs n8n CLI <a href="#when-to-use-server-cli-vs-n8n-cli" id="when-to-use-server-cli-vs-n8n-cli"></a>

| Feature                  | Server CLI                                                    | n8n CLI                                                  |
| ------------------------ | ------------------------------------------------------------- | -------------------------------------------------------- |
| **Where it runs**        | Same machine as n8n                                           | Any machine with network access                          |
| **Authentication**       | Direct database access                                        | API key                                                  |
| **Requires running n8n** | No (most commands)                                            | Yes                                                      |
| **Best for**             | Instance operators, backups, migrations                       | Programmers, AI agents, remote management                |
| **Security model**       | Bypasses access controls                                      | Respects user permissions and API key scope              |
| **Use case examples**    | Backup/restore, license management, emergency password resets | Workflow automation, credentials management through code |

## Running CLI commands <a href="#running-cli-commands" id="running-cli-commands"></a>

You can use CLI commands with self-hosted n8n. Depending on how you choose to install n8n, there are differences in how to run the commands:

* npm: the `n8n` command is directly available. The documentation uses this in the examples below.
* Docker: the `n8n` command is available within your Docker container:

  ```sh
  docker exec -u node -it <n8n-container-name> <n8n-cli-command>
  ```

## Start a workflow <a href="#start-a-workflow" id="start-a-workflow"></a>

You can start workflows directly using the CLI.

Execute a saved workflow by its ID:

```bash
n8n execute --id <ID>
```

## Publish or unpublish a workflow <a href="#publish-or-unpublish-a-workflow" id="publish-or-unpublish-a-workflow"></a>

You can publish or unpublish a workflow using the CLI. In n8n 2.0, the [previous active/inactive toggle](/changelog/v20-breaking-changes) was replaced by a publish/unpublish model. Use `publish:workflow` and `unpublish:workflow` to change a workflow's published state from the CLI.

{% hint style="info" %}
**When changes take effect**

These commands change your n8n database. When a running n8n applies the change depends on your setup:

* If `N8N_USE_WORKFLOW_PUBLICATION_SERVICE` is on (the default), the running instance applies the change without a restart. It checks for changes every 15 seconds by default. If n8n isn't running, it applies the change when it starts.
* Otherwise, restart n8n to apply the change.
  {% endhint %}

### Publish a workflow <a href="#publish-a-workflow" id="publish-a-workflow"></a>

Use `publish:workflow` to publish a workflow by its ID. You can optionally publish a specific historical version by passing its `versionId`.

`publish:workflow` runs the same checks as publishing from the editor, such as node validation and webhook path conflicts. If the workflow fails a check, the command doesn't publish it and prints the reason.

{% hint style="warning" %}
**Republishing a published workflow**

If `N8N_USE_WORKFLOW_PUBLICATION_SERVICE` is `false`, `publish:workflow` refuses to publish a workflow that's already published. Unpublish the workflow first, publish it again, and then restart n8n.
{% endhint %}

Command flags:

| Flag        | Description                                                                 |
| ----------- | --------------------------------------------------------------------------- |
| --help      | Help prompt.                                                                |
| --id        | The ID of the workflow to publish. Required.                                |
| --versionId | Optional version ID to publish. If omitted, the current draft is published. |

{% hint style="info" %}
**No `--all` flag**

Unlike the deprecated `update:workflow` command, `publish:workflow` doesn't support `--all`. This is intentional: it prevents accidental bulk publishing of workflows in production environments. Publish workflows individually by ID.
{% endhint %}

Publish the current draft of a workflow by ID:

```bash
n8n publish:workflow --id=<ID>
```

Publish a specific historical version of a workflow:

```bash
n8n publish:workflow --id=<ID> --versionId=<VERSION_ID>
```

### Unpublish a workflow <a href="#unpublish-a-workflow" id="unpublish-a-workflow"></a>

Use `unpublish:workflow` to unpublish a workflow by its ID, or all workflows at once.

Command flags:

| Flag   | Description                                                      |
| ------ | ---------------------------------------------------------------- |
| --help | Help prompt.                                                     |
| --id   | The ID of the workflow to unpublish. Can't be used with `--all`. |
| --all  | Unpublish all workflows. Can't be used with `--id`.              |

Unpublish a workflow by its ID:

```bash
n8n unpublish:workflow --id=<ID>
```

Unpublish all workflows:

```bash
n8n unpublish:workflow --all
```

### update:workflow (deprecated) <a href="#updateworkflow-deprecated" id="updateworkflow-deprecated"></a>

{% hint style="warning" %}
**Feature availability**

The `update:workflow` command is deprecated from n8n 2.0 and will be removed. Use [`publish:workflow`](#publish-a-workflow) and [`unpublish:workflow`](#unpublish-a-workflow) instead. See the [n8n 2.0 breaking changes](/changelog/v20-breaking-changes) for details.
{% endhint %}

Set the active status of a workflow by its ID to false:

```bash
n8n update:workflow --id=<ID> --active=false
```

Set the active status of a workflow by its ID to true:

```bash
n8n update:workflow --id=<ID> --active=true
```

This publishes the current version of the workflow, with the same checks and limits as [`publish:workflow`](#publish-a-workflow).

Set the active status to false for all the workflows:

```bash
n8n update:workflow --all --active=false
```

Set the active status to true for all the workflows:

```bash
n8n update:workflow --all --active=true
```

## Export entities <a href="#export-entities" id="export-entities"></a>

You can export your database entities from n8n using the CLI. This tooling allows you to export all entity types from one database type, such as SQLite, and import them into another database type, such as Postgres.

Command flags:

| Flag                                | Description                                                                                    |
| ----------------------------------- | ---------------------------------------------------------------------------------------------- |
| --help                              | Help prompt.                                                                                   |
| --outputDir                         | Output directory path                                                                          |
| --includeExecutionHistoryDataTables | Include execution history data tables, these are excluded by default as they can be very large |

```bash
n8n export:entities --outputDir=./outputs --includeExecutionHistoryDataTables=true
```

## Export workflows and credentials <a href="#export-workflows-and-credentials" id="export-workflows-and-credentials"></a>

You can export your workflows and credentials from n8n using the CLI.

{% hint style="info" %}
**Planning a full backup**

The `--backup` flag exports workflows and credentials only. For what a complete backup of a self-hosted instance includes, and how to restore it, see [Back up and restore](/deploy/host-n8n/keep-n8n-running/backup-and-restore).
{% endhint %}

Command flags:

| Flag         | Description                                                                                                                                                                                         |
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| --help       | Help prompt.                                                                                                                                                                                        |
| --all        | Exports all workflows/credentials.                                                                                                                                                                  |
| --backup     | Sets --all --pretty --separate for backups. You can optionally set --output.                                                                                                                        |
| --id         | The ID of the workflow to export.                                                                                                                                                                   |
| --output, -o | Outputs file name or directory if using separate files.                                                                                                                                             |
| --pretty     | Formats the output in an easier to read fashion.                                                                                                                                                    |
| --separate   | Exports one file per workflow (useful for versioning). Must set a directory using --output.                                                                                                         |
| --decrypted  | Exports the credentials in a plain text format. (Credentials only.)                                                                                                                                 |
| --version    | The version ID of a specific historical version to export. (Workflows only, can't be used with `--all` or `--published`.)                                                                           |
| --published  | Exports the published/active version of the workflow instead of the current draft. When combined with `--all`, unpublished workflows are skipped. (Workflows only, can't be used with `--version`.) |

### Workflows <a href="#workflows" id="workflows"></a>

Export all your workflows to the standard output (terminal):

```bash
n8n export:workflow --all
```

Export a workflow by its ID and specify the output file name:

```bash
n8n export:workflow --id=<ID> --output=file.json
```

Export all workflows to a specific directory in a single file:

```bash
n8n export:workflow --all --output=backups/latest/file.json
```

Export all the workflows to a specific directory using the `--backup` flag (details above):

```bash
n8n export:workflow --backup --output=backups/latest/
```

#### Export a specific workflow version <a href="#export-a-specific-workflow-version" id="export-a-specific-workflow-version"></a>

You can export a specific historical version of a workflow by passing its `versionId` with `--version`:

```bash
n8n export:workflow --id=<ID> --version=<VERSION_ID> --output=workflow-v1.json
```

#### Export the published version of a workflow <a href="#export-the-published-version-of-a-workflow" id="export-the-published-version-of-a-workflow"></a>

Use `--published` to export the currently published/active version of a workflow rather than the current draft:

```bash
n8n export:workflow --id=<ID> --published --output=published.json
```

You can combine `--published` with `--all` to export every workflow's published version. Workflows that don't have a published version are skipped:

```bash
n8n export:workflow --all --published --output=workflows.json
```

{% hint style="info" %}
**Version metadata**

When exporting a workflow, n8n includes a `versionMetadata` property containing the workflow's historical name and description for that version. The import command preserves this data in the workflow history table on import. The current workflow's name and description aren't overridden.
{% endhint %}

### Credentials <a href="#credentials" id="credentials"></a>

Export all your credentials to the standard output (terminal):

```bash
n8n export:credentials --all
```

Export credentials by their ID and specify the output file name:

```bash
n8n export:credentials --id=<ID> --output=file.json
```

Export all credentials to a specific directory in a single file:

```bash
n8n export:credentials --all --output=backups/latest/file.json
```

Export all the credentials to a specific directory using the `--backup` flag (details above):

```bash
n8n export:credentials --backup --output=backups/latest/
```

Export all the credentials in plain text format. You can use this to migrate from one installation to another that has a different secret key in the configuration file.

{% hint style="warning" %}
**Sensitive information**

All sensitive information is visible in the files.
{% endhint %}

```bash
n8n export:credentials --all --decrypted --output=backups/decrypted.json
```

## Import entities <a href="#import-entities" id="import-entities"></a>

You can import entities from a previous `export:entities` command using this command, it allows importing of entities into a database type that differs from the exported database type. Current supported database types include: SQLite, Postgres.

The database is expected to be empty prior to import, this can be forced with the `--truncateTables` parameter.

Command flags:

| Flag             | Description                                        |
| ---------------- | -------------------------------------------------- |
| --help           | Help prompt.                                       |
| --inputDir       | Input directory that holds output files for import |
| --truncateTables | Truncate tables before import                      |

```bash
n8n import:entities --inputDir ./outputs --truncateTables true
```

## Import workflows and credentials <a href="#import-workflows-and-credentials" id="import-workflows-and-credentials"></a>

You can import your workflows and credentials from n8n using the CLI.

{% hint style="warning" %}
**Update the IDs**

When exporting workflows and credentials, n8n also exports their IDs. If you have workflows and credentials with the same IDs in your existing database, they will be overwritten. To avoid this, delete or change the IDs before importing.
{% endhint %}

Available flags:

| Flag                  | Description                                                                                                                                                                                             |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| --help                | Help prompt.                                                                                                                                                                                            |
| --input               | Input file name or directory if you use --separate.                                                                                                                                                     |
| --projectId           | Import the workflow or credential to the specified project. Can't be used with `--userId`.                                                                                                              |
| --separate            | Imports `*.json` files from directory provided by --input.                                                                                                                                              |
| --userId              | Import the workflow or credential to the specified user. Can't be used with `--projectId`.                                                                                                              |
| --skipMigrationChecks | Skip migration validation checks.                                                                                                                                                                       |
| --activeState         | Controls the active state of imported workflows. Accepts `false` (default, deactivates all imported workflows) or `fromJson` (uses the `active` field from each workflow's JSON; multi-main mode only). |

{% hint style="info" %}
**Migrating to SQLite**

n8n limits workflow and credential names to 128 characters, but SQLite doesn't enforce size limits.

This might result in errors like **Data too long for column name** during the import process.

In this case, you can edit the names from the n8n interface and export again, or edit the JSON file directly before importing.
{% endhint %}

### Workflows <a href="#workflows" id="workflows"></a>

{% hint style="warning" %}
**Known issue: cron triggers keep running after import**

The behaviour of importing a previously active workflow differs depending on the mode you are running. This is a known bug.

On multi-main and queue-mode instances the previously active workflow's cron triggers are deactivated on import.

On non multi-main instances the previously active workflows cron triggers will remain running until you restart the n8n instance.
{% endhint %}

Import workflows from a specific file:

```bash
n8n import:workflow --input=file.json
```

Import all the workflow files as JSON from the specified directory:

```bash
n8n import:workflow --separate --input=backups/latest/
```

{% hint style="info" %}
**Version metadata on import**

If the imported file includes a `versionMetadata` property (added by exports that target a specific version or the published version), n8n preserves that historical name and description in the workflow history table. The current workflow entity's name and description are kept as-is.
{% endhint %}

By default, `import:workflow` deactivates every imported workflow. To preserve the `active` field from each JSON file instead, pass `--activeState=fromJson` (only supported in multi-main & queue mode):

```bash
n8n import:workflow --separate --input=backups/latest/ --activeState=fromJson
```

### Credentials <a href="#credentials" id="credentials"></a>

Import credentials from a specific file:

```bash
n8n import:credentials --input=file.json
```

Import all the credentials files as JSON from the specified directory:

```bash
n8n import:credentials --separate --input=backups/latest/
```

## License <a href="#license" id="license"></a>

### Clear <a href="#clear" id="clear"></a>

Clear your existing license from n8n's database and reset n8n to default features:

```sh
n8n license:clear
```

If your license includes [floating entitlements](#user-content-fn-1)[^1], running this command will also attempt to release them back to the pool, making them available for other instances.

### Info <a href="#info" id="info"></a>

Display information about the existing license:

```sh
n8n license:info
```

## User management <a href="#user-management" id="user-management"></a>

You can reset user management using the n8n CLI. This returns user management to its pre-setup state. It removes all user accounts.

Use this if you forget your password, and don't have SMTP set up to do password resets by email.

```sh
n8n user-management:reset
```

### Disable MFA for a user <a href="#disable-mfa-for-a-user" id="disable-mfa-for-a-user"></a>

If a user loses their recovery codes you can disable MFA for a user with this command. The user will then be able to log back in to set up MFA again.

```sh
n8n mfa:disable --email=johndoe@example.com
```

### Disable LDAP <a href="#disable-ldap" id="disable-ldap"></a>

You can reset the LDAP settings using the command below.

```sh
n8n ldap:reset
```

## Uninstall community nodes and credentials <a href="#uninstall-community-nodes-and-credentials" id="uninstall-community-nodes-and-credentials"></a>

You can manage [community nodes](/integrations/community-nodes/installation-and-management) using the n8n CLI. For now, you can only uninstall community nodes and credentials, which is useful if a community node causes instability.

Command flags:

| Flag         | Description                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------- |
| --help       | Show CLI help.                                                                                                             |
| --credential | The credential type. Get this value by visiting the node's `<NODE>.credential.ts` file and getting the value of `name`.    |
| --package    | Package name of the community node.                                                                                        |
| --uninstall  | Uninstalls the node.                                                                                                       |
| --userId     | The ID of the user who owns the credential. On self-hosted, query the database. On cloud, query the API with your API key. |

### Nodes <a href="#nodes" id="nodes"></a>

Uninstall a community node by package name:

```sh
n8n community-node --uninstall --package <COMMUNITY_NODE_NAME>
```

For example, to uninstall the [Evolution API community node](https://www.npmjs.com/package/n8n-nodes-evolution-api), type:

```sh
n8n community-node --uninstall --package n8n-nodes-evolution-api
```

### Credentials <a href="#credentials" id="credentials"></a>

Uninstall a community node credential:

```sh
n8n community-node --uninstall --credential <CREDENTIAL_TYPE> --userId <ID>
```

For example, to uninstall the [Evolution API community node credential](https://www.npmjs.com/package/n8n-nodes-evolution-api), visit the [repository](https://github.com/oriondesign2015/n8n-nodes-evolution-api) and navigate to the [`credentials.ts` file](https://github.com/oriondesign2015/n8n-nodes-evolution-api/blob/main/credentials/EvolutionApi.credentials.ts) to find the `name`:

```sh
n8n community-node --uninstall --credential evolutionApi --userId 1234
```

## Security audit <a href="#security-audit" id="security-audit"></a>

You can run a [security audit](/deploy/host-n8n/configure-n8n/security/run-security-audits) on your n8n instance, to detect common security issues.

```sh
n8n audit
```

## Related resources

* [Configure n8n](/deploy/host-n8n/configure-n8n)

[^1]: In n8n, entitlements grant n8n instances access to plan-restricted features for a specific period of time.


# User management

Configure self-hosted n8n for user management

User management in n8n allows you to invite people to work in your n8n instance.

This document describes how to configure your n8n instance to support user management, and the steps to start inviting users.

Refer to the main [User management](/administer/manage-users-and-access) guide for more information about usage, including:

* [Managing users](/administer/manage-users-and-access/add-and-remove-users)
* [Instance roles](/administer/manage-users-and-access/understand-instance-roles)
* [Best practices](/administer/manage-users-and-access/follow-best-practices)

For LDAP setup information, refer to [LDAP](/administer/manage-users-and-access/verify-user-identity/connect-ldap).

For SAML setup information, refer to [SAML](/administer/manage-users-and-access/verify-user-identity/use-saml).

{% hint style="warning" %}
**Feature availability**

Support for basic auth and JWT authentication was removed from n8n 1.0.

The `N8N_USER_MANAGEMENT_DISABLED` environment variable was also removed from n8n 1.0. No supported way to disable the login screen exists in recent versions of n8n, including for local or development use. If you need to simplify login for local development, consider using a password manager, setting a simple local password, or scripting the standard login flow.
{% endhint %}

## Setup <a href="#setup" id="setup"></a>

There are three stages to set up user management in n8n:

1. Configure your n8n instance to use your SMTP server.
2. Start n8n and follow the setup steps in the app.
3. Invite users.

### Step one: SMTP <a href="#step-one-smtp" id="step-one-smtp"></a>

n8n recommends setting up an SMTP server, for user invites and password resets.

{% hint style="info" %}
**Feature availability**

Setting up SMTP is optional from n8n 0.210.1. You can choose to manually copy and send invite links instead of setting up SMTP. Note that if you skip this step, users can't reset passwords.
{% endhint %}

Get the following information from your SMTP provider:

* Server name
* SMTP username
* SMTP password
* SMTP sender name

To set up SMTP with n8n, configure the SMTP environment variables for your n8n instance. For information on how to set environment variables, refer to [Configuration](/deploy/host-n8n/configure-n8n/basic-configuration)

| Variable                                    | Type    | Description                                                                                                                  | Required? |
| ------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | --------- |
| `N8N_EMAIL_MODE`                            | string  | `smtp`                                                                                                                       | Required  |
| `N8N_SMTP_HOST`                             | string  | *your\_SMTP\_server\_name*                                                                                                   | Required  |
| `N8N_SMTP_PORT`                             | number  | *your\_SMTP\_server\_port* Default is `465`.                                                                                 | Optional  |
| `N8N_SMTP_USER`                             | string  | *your\_SMTP\_username*                                                                                                       | Optional  |
| `N8N_SMTP_PASS`                             | string  | *your\_SMTP\_password*                                                                                                       | Optional  |
| `N8N_SMTP_OAUTH_SERVICE_CLIENT`             | string  | *your\_OAuth\_service\_client*                                                                                               | Optional  |
| `N8N_SMTP_OAUTH_PRIVATE_KEY`                | string  | *your\_OAuth\_private\_key*                                                                                                  | Optional  |
| `N8N_SMTP_SENDER`                           | string  | Sender email address. You can optionally include the sender name. Example with name: *n8n `<contact@n8n.com>`*               | Required  |
| `N8N_SMTP_SSL`                              | boolean | Whether to use SSL for SMTP (true) or not (false). Defaults to `true`.                                                       | Optional  |
| `N8N_UM_EMAIL_TEMPLATES_INVITE`             | string  | Full path to your HTML email template. This overrides the default template for invite emails.                                | Optional  |
| `N8N_UM_EMAIL_TEMPLATES_PWRESET`            | string  | Full path to your HTML email template. This overrides the default template for password reset emails.                        | Optional  |
| `N8N_UM_EMAIL_TEMPLATES_WORKFLOW_SHARED`    | String  | Overrides the default HTML template for notifying users that a credential was shared. Provide the full path to the template. | Optional  |
| `N8N_UM_EMAIL_TEMPLATES_CREDENTIALS_SHARED` | String  | Overrides the default HTML template for notifying users that a credential was shared. Provide the full path to the template. | Optional  |
| `N8N_UM_EMAIL_TEMPLATES_PROJECT_SHARED`     | String  | Overrides the default HTML template for notifying users that a project was shared. Provide the full path to the template.    | Optional  |

If your n8n instance is already running, you need to restart it to enable the new SMTP settings.

{% hint style="info" %}
**More configuration options**

There are more configuration options available as environment variables. Refer to [Environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables) for a list. These include options to disable tags, workflow templates, and the personalization survey, if you don't want your users to see them.
{% endhint %}

{% hint style="info" %}
**New to SMTP?**

If you're not familiar with SMTP, this [blog post by SendGrid](https://sendgrid.com/blog/what-is-an-smtp-server/) offers a short introduction, while [Wikipedia's Simple Mail Transfer Protocol article](https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol) provides more detailed technical background.
{% endhint %}

### Step two: In-app setup <a href="#step-two-in-app-setup" id="step-two-in-app-setup"></a>

When you set up user management for the first time, you create an owner account.

1. Open n8n. The app displays a signup screen.
2. Enter your details. Your password must be at least eight characters, including at least one number and one capital letter.
3. Click **Next**. n8n logs you in with your new owner account.

#### Pre-provision the instance owner from environment variables <a href="#pre-provision-the-instance-owner-from-environment-variables" id="pre-provision-the-instance-owner-from-environment-variables"></a>

{% hint style="info" %}
**Feature availability**

Pre-provisioning the instance owner from environment variables is available from n8n 2.17.0.
{% endhint %}

You can pre-provision the instance owner from environment variables instead of going through the in-app setup. Set `N8N_INSTANCE_OWNER_MANAGED_BY_ENV` to `true` and provide the owner details. See [Manage instance settings using environment variables](/deploy/host-n8n/configure-n8n/manage-settings-using-environment-variables) for how the activation pattern works.

To change the owner email after setup, see [Change the instance owner email for self-hosted n8n](/deploy/host-n8n/configure-n8n/change-instance-owner-email).

{% hint style="warning" %}
**`N8N_INSTANCE_OWNER_PASSWORD_HASH` must be a bcrypt hash**

This variable expects a pre-hashed bcrypt value. Setting a plaintext password breaks login.
{% endhint %}

| Variable                            | Type    | Default | Description                                                                                                                                                                                                       |
| ----------------------------------- | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_INSTANCE_OWNER_MANAGED_BY_ENV` | Boolean | `false` | Set to `true` to manage the instance owner from environment variables. When `true`, n8n overwrites the instance owner details below on every startup, locks the UI control for that user, and rejects API writes. |
| `N8N_INSTANCE_OWNER_EMAIL`          | String  | -       | Email address for the instance owner.                                                                                                                                                                             |
| `N8N_INSTANCE_OWNER_FIRST_NAME`     | String  | -       | First name for the instance owner.                                                                                                                                                                                |
| `N8N_INSTANCE_OWNER_LAST_NAME`      | String  | -       | Last name for the instance owner.                                                                                                                                                                                 |
| `N8N_INSTANCE_OWNER_PASSWORD_HASH`  | String  | -       | Bcrypt hash of the instance owner's password. Setting a plaintext password breaks login.                                                                                                                          |

{% hint style="warning" %}
**Owner email must be unique**

`N8N_INSTANCE_OWNER_EMAIL` must not already belong to another user on the instance. This setting updates the existing instance owner account; it doesn't transfer ownership to another existing user or merge user accounts. To use an email address that already belongs to another user, change or delete that user first so the email becomes available.
{% endhint %}

### Step three: Invite users <a href="#step-three-invite-users" id="step-three-invite-users"></a>

You can now invite other people to your n8n instance.

1. Sign in to your n8n instance with your owner account. On n8n Cloud, if you're in the n8n Cloud console, select **Open instance** on the **Overview** page.
2. Click the three dots next to your user icon at the bottom left and click **Settings**.
3. Click **Users** to go to the **Users** page.
4. Click **Invite**.
5. Enter the new user's email address.
6. Click **Invite user**. n8n sends an email with a link for the new user to join.

## Related resources

* [Configure n8n](/deploy/host-n8n/configure-n8n)


# Change instance owner email

Change the owner email address for a self-hosted n8n instance using the UI or environment variables.

You can change the instance owner email from the UI, or from environment variables if you manage the instance owner that way.

{% hint style="info" %}
**Owner email must be unique**

The owner email must not already belong to another user on the instance. If the email you want is already used by another user, change or delete that user first so the email becomes available.
{% endhint %}

Changing the owner email updates the existing instance owner account. It doesn't transfer ownership to another existing user or merge user accounts.

## Change the owner email in the UI <a href="#change-the-owner-email-in-the-ui" id="change-the-owner-email-in-the-ui"></a>

1. Log in as the instance owner.
2. Go to **Settings** > **Profile & preferences**.
3. Update the **Email** field.
4. Select **Save**.

## Change the owner email using environment variables <a href="#change-the-owner-email-using-environment-variables" id="change-the-owner-email-using-environment-variables"></a>

If you manage the instance owner using environment variables:

1. Set `N8N_INSTANCE_OWNER_MANAGED_BY_ENV` to `true`.
2. Set `N8N_INSTANCE_OWNER_EMAIL` to the new owner email.
3. Keep `N8N_INSTANCE_OWNER_FIRST_NAME`, `N8N_INSTANCE_OWNER_LAST_NAME`, and `N8N_INSTANCE_OWNER_PASSWORD_HASH` set.
4. Restart n8n.

When `N8N_INSTANCE_OWNER_MANAGED_BY_ENV` is `true`, n8n reapplies the owner details on every startup. The matching UI controls become read-only.

{% hint style="warning" %}
**`N8N_INSTANCE_OWNER_PASSWORD_HASH` must be a bcrypt hash**

This variable expects a pre-hashed bcrypt value. Setting a plaintext password breaks login.
{% endhint %}

For more information, see [Manage instance settings using environment variables](/deploy/host-n8n/configure-n8n/manage-settings-using-environment-variables#instance-owner).

## Related resources

* [Configure n8n](/deploy/host-n8n/configure-n8n)


# Manage settings using environment variables

Configure a self-hosted n8n instance owner, SSO, security policy, log streaming, MCP, and community packages from environment variables.

You can manage a subset of instance settings from environment variables, instead of configuring them through the UI. This is useful when you provision n8n instances automatically, such as through an internal deployment pipeline.

Each supported area has a dedicated environment variable named `<AREA>_MANAGED_BY_ENV`. Set this variable to `true` to activate environment variable management for that area. n8n then applies the related environment variables and locks the matching UI controls.

## How it works <a href="#how-it-works" id="how-it-works"></a>

When you set `<AREA>_MANAGED_BY_ENV` to `true`:

* n8n reapplies the settings from environment variables **on every startup**.
* The matching UI controls become **read-only**.

When `<AREA>_MANAGED_BY_ENV` is `false` (the default), n8n ignores the related environment variables, even if you set them.

{% hint style="info" %}
**Values persist when you turn off `*_MANAGED_BY_ENV`**

Setting `*_MANAGED_BY_ENV` back to `false` restores UI write access but keeps the values that were last applied. Edit them through the UI afterward if you want to change them.
{% endhint %}

{% hint style="info" %}
**Unexpected read-only UI controls**

If a setting appears as read-only and you didn't expect it, check whether the matching `*_MANAGED_BY_ENV` variable is `true` in your environment.
{% endhint %}

The supported areas and their activating variables:

* Instance owner: `N8N_INSTANCE_OWNER_MANAGED_BY_ENV`
* SSO: `N8N_SSO_MANAGED_BY_ENV`
* Security policy: `N8N_SECURITY_POLICY_MANAGED_BY_ENV`
* Log streaming: `N8N_LOG_STREAMING_MANAGED_BY_ENV`
* MCP: `N8N_MCP_MANAGED_BY_ENV`
* Community packages: `N8N_COMMUNITY_PACKAGES_MANAGED_BY_ENV`

{% hint style="info" %}
**Set `<AREA>_MANAGED_BY_ENV` to activate the group**

The other environment variables for an area have no effect unless `<AREA>_MANAGED_BY_ENV` is `true`. Set it to `true` to activate the group.
{% endhint %}

## Instance owner <a href="#instance-owner" id="instance-owner"></a>

{% hint style="info" %}
**Feature availability**

Instance owner management through environment variables is available from n8n 2.17.0.
{% endhint %}

Pre-provision the [instance owner](/deploy/host-n8n/configure-n8n/user-management) from environment variables instead of going through the in-app setup. To change the owner email after setup, see [Change the instance owner email for self-hosted n8n](/deploy/host-n8n/configure-n8n/change-instance-owner-email).

{% hint style="warning" %}
**`N8N_INSTANCE_OWNER_PASSWORD_HASH` must be a bcrypt hash**

This variable expects a pre-hashed bcrypt value. Setting a plaintext password breaks login.
{% endhint %}

| Variable                            | Type    | Default | Description                                                                                                                                                                                                       |
| ----------------------------------- | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_INSTANCE_OWNER_MANAGED_BY_ENV` | Boolean | `false` | Set to `true` to manage the instance owner from environment variables. When `true`, n8n overwrites the instance owner details below on every startup, locks the UI control for that user, and rejects API writes. |
| `N8N_INSTANCE_OWNER_EMAIL`          | String  | -       | Email address for the instance owner.                                                                                                                                                                             |
| `N8N_INSTANCE_OWNER_FIRST_NAME`     | String  | -       | First name for the instance owner.                                                                                                                                                                                |
| `N8N_INSTANCE_OWNER_LAST_NAME`      | String  | -       | Last name for the instance owner.                                                                                                                                                                                 |
| `N8N_INSTANCE_OWNER_PASSWORD_HASH`  | String  | -       | Bcrypt hash of the instance owner's password. Setting a plaintext password breaks login.                                                                                                                          |

{% hint style="warning" %}
**Owner email must be unique**

`N8N_INSTANCE_OWNER_EMAIL` must not already belong to another user on the instance. This setting updates the existing instance owner account; it doesn't transfer ownership to another existing user or merge user accounts. To use an email address that already belongs to another user, change or delete that user first so the email becomes available.
{% endhint %}

## SSO <a href="#sso" id="sso"></a>

{% hint style="info" %}
**Feature availability**

Single sign-on is available on:

* **Self-hosted:** Business, Enterprise

n8n Cloud Enterprise also supports single sign-on, but not through the environment variables on this page.

Managing SSO from environment variables is available from n8n 2.18.0.
{% endhint %}

Configure [single sign-on](/deploy/host-n8n/configure-n8n/security/configure-sso) from environment variables.

### Activation and shared settings <a href="#activation-and-shared-settings" id="activation-and-shared-settings"></a>

| Variable                         | Type                                                                   | Default    | Description                                                                                                                                                                                                                           |
| -------------------------------- | ---------------------------------------------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_SSO_MANAGED_BY_ENV`         | Boolean                                                                | `false`    | Set to `true` to manage SSO from environment variables. When `true`, n8n applies the SSO variables on every startup and locks the matching UI controls.                                                                               |
| `N8N_SSO_USER_ROLE_PROVISIONING` | Enum string: `disabled`, `instance_role`, `instance_and_project_roles` | `disabled` | How n8n provisions roles for users who sign in through SSO. `disabled` doesn't provision any roles. `instance_role` provisions the instance-level role only. `instance_and_project_roles` provisions both instance and project roles. |

### OIDC <a href="#oidc" id="oidc"></a>

| Variable                          | Type    | Default | Description                                                                                                                  |
| --------------------------------- | ------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `N8N_SSO_OIDC_LOGIN_ENABLED`      | Boolean | `false` | Whether to enable OIDC login.                                                                                                |
| `N8N_SSO_OIDC_CLIENT_ID`          | String  | -       | OIDC client ID issued by your identity provider.                                                                             |
| `N8N_SSO_OIDC_CLIENT_SECRET`      | String  | -       | OIDC client secret issued by your identity provider.                                                                         |
| `N8N_SSO_OIDC_DISCOVERY_ENDPOINT` | String  | -       | OIDC discovery endpoint URL (the `.well-known/openid-configuration` URL for your identity provider).                         |
| `N8N_SSO_OIDC_PROMPT`             | String  | -       | Optional OIDC `prompt` parameter to send with the authorization request, for example `login` or `consent`.                   |
| `N8N_SSO_OIDC_ACR_VALUES`         | String  | -       | Optional OIDC `acr_values` parameter. Use this to request a specific authentication context, for example a step-up MFA flow. |

### SAML <a href="#saml" id="saml"></a>

{% hint style="warning" %}
**SAML metadata variables are mutually exclusive**

Set either `N8N_SSO_SAML_METADATA` (inline XML) or `N8N_SSO_SAML_METADATA_URL` (URL), not both.
{% endhint %}

| Variable                     | Type    | Default | Description                                                                                                            |
| ---------------------------- | ------- | ------- | ---------------------------------------------------------------------------------------------------------------------- |
| `N8N_SSO_SAML_LOGIN_ENABLED` | Boolean | `false` | Whether to enable SAML login.                                                                                          |
| `N8N_SSO_SAML_METADATA`      | String  | -       | SAML identity provider metadata as an XML string. Mutually exclusive with `N8N_SSO_SAML_METADATA_URL`; don't set both. |
| `N8N_SSO_SAML_METADATA_URL`  | String  | -       | URL to fetch SAML identity provider metadata from. Mutually exclusive with `N8N_SSO_SAML_METADATA`; don't set both.    |

## Security policy <a href="#security-policy" id="security-policy"></a>

{% hint style="info" %}
**Feature availability**

Managing the security policy from environment variables is available from n8n 2.18.0.
{% endhint %}

Manage the instance security policy from environment variables, including MFA enforcement and personal space restrictions.

| Variable                                | Type    | Default | Description                                                                                                                                                                         |
| --------------------------------------- | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_SECURITY_POLICY_MANAGED_BY_ENV`    | Boolean | `false` | Set to `true` to manage the security policy from environment variables. When `true`, n8n applies the security policy variables on every startup and locks the matching UI controls. |
| `N8N_MFA_ENFORCED_ENABLED`              | Boolean | `false` | Whether to enforce two-factor authentication for all users (`true`) or not (`false`).                                                                                               |
| `N8N_PERSONAL_SPACE_PUBLISHING_ENABLED` | Boolean | `true`  | Whether users can publish from their personal space (`true`) or not (`false`).                                                                                                      |
| `N8N_PERSONAL_SPACE_SHARING_ENABLED`    | Boolean | `true`  | Whether users can share resources from their personal space (`true`) or not (`false`).                                                                                              |

## Log streaming <a href="#log-streaming" id="log-streaming"></a>

{% hint style="info" %}
**Feature availability**

Managing log streaming from environment variables is available from n8n 2.19.0.
{% endhint %}

Manage [log streaming](/administer/observe-and-log/stream-logs-to-external-systems) destinations from environment variables. See [Configure using environment variables](/administer/observe-and-log/stream-logs-to-external-systems#configure-using-environment-variables) for the per-destination JSON shape.

| Variable                           | Type        | Default | Description                                                                                                                                                                 |
| ---------------------------------- | ----------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_LOG_STREAMING_MANAGED_BY_ENV` | Boolean     | `false` | Set to `true` to manage log streaming from environment variables. When `true`, n8n applies the log streaming variables on every startup and locks the matching UI controls. |
| `N8N_LOG_STREAMING_DESTINATIONS`   | JSON string | -       | JSON array of log streaming destinations. Each destination is an object with a `type` of `webhook`, `syslog`, or `sentry`, plus the configuration for that type.            |

## MCP <a href="#mcp" id="mcp"></a>

{% hint style="info" %}
**Feature availability**

Managing instance-level MCP access from environment variables is available from n8n 2.20.0.
{% endhint %}

Manage [instance-level MCP access](/connect/connect-to-n8n-mcp-server) from environment variables.

| Variable                 | Type    | Default | Description                                                                                                                                                      |
| ------------------------ | ------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_MCP_MANAGED_BY_ENV` | Boolean | `false` | Set to `true` to manage MCP settings from environment variables. When `true`, n8n applies the MCP variables on every startup and locks the matching UI controls. |
| `N8N_MCP_ACCESS_ENABLED` | Boolean | `false` | Whether to enable instance-level MCP access (`true`) or not (`false`).                                                                                           |

## Community packages <a href="#community-packages" id="community-packages"></a>

{% hint style="info" %}
**Feature availability**

Managing installed community packages from environment variables is available from n8n 2.21.0.
{% endhint %}

Manage the set of installed [community packages](/integrations/community-nodes/installation-and-management) from environment variables. n8n reconciles the installed packages against the list on every startup. Managed packages can't be uninstalled or updated through the UI.

`N8N_COMMUNITY_PACKAGES_ENABLED` must also be set to `true` (the default). When community packages are disabled, n8n ignores `N8N_COMMUNITY_PACKAGES_MANAGED_BY_ENV` and logs a warning.

| Variable                                | Type        | Default | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| --------------------------------------- | ----------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_COMMUNITY_PACKAGES_MANAGED_BY_ENV` | Boolean     | `false` | Set to `true` to manage installed community packages from environment variables. When `true`, n8n reconciles the installed packages against `N8N_COMMUNITY_PACKAGES` on every startup, installing missing packages, correcting versions, and **uninstalling any currently-installed packages that aren't in the list**. The **Community nodes** settings page becomes read-only: you can't install, update, or uninstall packages from the UI while this is enabled. |
| `N8N_COMMUNITY_PACKAGES`                | JSON string | -       | JSON array of community packages to install. Each entry is an object with a `name` (required) and optional `version` and `checksum` fields. You can also embed the version in the name as `<package-name>@<version>`. See [environment variable installation](/integrations/community-nodes/installation-and-management/environment-variable-installation) for the full per-field reference.                                                                         |

## Combined example <a href="#combined-example" id="combined-example"></a>

The following example configures an instance with all six areas managed by environment variables. It creates the instance owner, configures OIDC SSO, enforces MFA, registers a webhook log streaming destination, enables MCP access, and manages a community package.

```bash
# Instance owner <a href="#instance-owner" id="instance-owner"></a>
export N8N_INSTANCE_OWNER_MANAGED_BY_ENV=true
export N8N_INSTANCE_OWNER_EMAIL=<owner-email>
export N8N_INSTANCE_OWNER_FIRST_NAME=<first-name>
export N8N_INSTANCE_OWNER_LAST_NAME=<last-name>
export N8N_INSTANCE_OWNER_PASSWORD_HASH=<bcrypt-hash>

# SSO using OIDC <a href="#sso-using-oidc" id="sso-using-oidc"></a>
export N8N_SSO_MANAGED_BY_ENV=true
export N8N_SSO_USER_ROLE_PROVISIONING=instance_role
export N8N_SSO_OIDC_LOGIN_ENABLED=true
export N8N_SSO_OIDC_CLIENT_ID=<client-id>
export N8N_SSO_OIDC_CLIENT_SECRET=<client-secret>
export N8N_SSO_OIDC_DISCOVERY_ENDPOINT=<discovery-url>

# Security policy <a href="#security-policy" id="security-policy"></a>
export N8N_SECURITY_POLICY_MANAGED_BY_ENV=true
export N8N_MFA_ENFORCED_ENABLED=true
export N8N_PERSONAL_SPACE_PUBLISHING_ENABLED=false
export N8N_PERSONAL_SPACE_SHARING_ENABLED=false

# Log streaming <a href="#log-streaming" id="log-streaming"></a>
export N8N_LOG_STREAMING_MANAGED_BY_ENV=true
export N8N_LOG_STREAMING_DESTINATIONS='[{"type":"webhook","url":"https://logs.example.com/n8n"}]'

# MCP <a href="#mcp" id="mcp"></a>
export N8N_MCP_MANAGED_BY_ENV=true
export N8N_MCP_ACCESS_ENABLED=true

# Community packages <a href="#community-packages" id="community-packages"></a>
export N8N_COMMUNITY_PACKAGES_MANAGED_BY_ENV=true
export N8N_COMMUNITY_PACKAGES='[{"name":"n8n-nodes-foo","version":"1.2.3"}]'
```

## Set environment variables <a href="#set-environment-variables" id="set-environment-variables"></a>

For the supported ways to set environment variables, see [Configuration methods](/deploy/host-n8n/configure-n8n/basic-configuration).

## Related resources

* [Configure n8n](/deploy/host-n8n/configure-n8n)


# Set up task runners

How to configure task runners to execute tasks using internal or external runner processes.

Task runners are a generic mechanism to execute tasks in a secure and performant way. They're used to execute user-provided JavaScript and Python code in the [Code node](/integrations/builtin/core-nodes/n8n-nodes-base.code).

This document describes how task runners work and how you can configure them.

{% hint style="warning" %}
**Always use task runners in production**

Task runners are the only isolation layer between user-provided code and n8n. Without them, or with [internal mode](#internal-mode), anyone who can edit a workflow could potentially read your database, [encryption key](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/set-a-custom-encryption-key), stored credentials, and environment variables.

In production, and on any instance holding sensitive data, use [external mode](#external-mode) plus the measures in [Hardening task runners](/deploy/host-n8n/configure-n8n/security/harden-task-runners). Skipping external mode to save hosting costs is only a reasonable tradeoff on isolated instances that hold nothing but trusted or mock data.
{% endhint %}

## How it works <a href="#how-it-works" id="how-it-works"></a>

The task runner feature consists of these components: one or more task runners, a task broker, and a task requester.

![Task runner overview](https://2773773108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fjm0ZYRpZIPWge2ZSiDYO%2Fuploads%2Fgit-blob-55207f2deade3c6c7123a6086cdea2bca06208ff%2Ftask-runner-concept.png?alt=media)

Task runners connect to the task broker using a websocket connection. A task requester submits a task request to the broker where an available task runner can pick it up for execution.

The runner executes the task and submits the results to the task requester. The task broker coordinates communication between the runner and the requester.

The n8n instance (main and worker) acts as the broker. The Code node in this case is the task requester.

## Task runner modes <a href="#task-runner-modes" id="task-runner-modes"></a>

You can use task runners in two different modes: internal and external.

### Internal mode <a href="#internal-mode" id="internal-mode"></a>

In internal mode, the n8n instance launches the task runner as a child process, which is insecure by design. The n8n process monitors and manages the life cycle of the task runner. The task runner process shares the same `uid` and `gid` as n8n.

{% hint style="warning" %}
**Feature availability**

Internal mode is deprecated from n8n 3.0 and will be removed in a future version. n8n logs a deprecation warning at startup while it runs in internal mode, including when `N8N_RUNNERS_MODE` isn't set. Move to [external mode](#external-mode) for more secure isolation and scaling.

Internal mode isn't recommended for production. Because the runner runs as the same user on the same host as n8n, code that escapes the runner's sandbox has the same access as n8n, including to stored credentials (see the warning at the top of this page). Use internal mode only on isolated instances that hold no sensitive data.
{% endhint %}

### External mode <a href="#external-mode" id="external-mode"></a>

In external mode, a [launcher application](https://github.com/n8n-io/task-runner-launcher) launches task runners on demand and manages their lifecycle. Typically, this means that next to n8n you add a sidecar container running the [`n8nio/runners`](https://hub.docker.com/r/n8nio/runners) image containing the launcher, the JS task runner and the Python task runner. This sidecar container is independent from the n8n instance. The launcher exposes a health-check endpoint that it uses to monitor the task runner processes.

![Task runner deployed as a side-car container](https://2773773108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fjm0ZYRpZIPWge2ZSiDYO%2Fuploads%2Fgit-blob-cb63fb1f1b7c6647e817f6eaff5ae1bd1a08dba6%2Ftask-runner-external-mode.png?alt=media)

When using [Queue mode](/deploy/host-n8n/configure-n8n/scaling/enable-queue-mode), each worker needs to have its own sidecar container for task runners.

In addition, if [`OFFLOAD_MANUAL_EXECUTIONS_TO_WORKERS=false`](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/queue-mode#queue-mode-environment-variables), then your main instance will run manual executions and needs its own sidecar container for task runners as well. Please note that running n8n with offloading disabled isn't recommended for production.

## Setting up external mode <a href="#setting-up-external-mode" id="setting-up-external-mode"></a>

In external mode, you run the `n8nio/runners` image as a sidecar container next to n8n. Below you will find a docker compose as a reference. Keep in mind that the `n8nio/runners` image version must match that of the `n8nio/n8n` image, and the n8n version must be >=1.111.0.

```yaml
services:
  n8n:
    image: n8nio/n8n:1.111.0
    container_name: n8n-main
    environment:
      - N8N_RUNNERS_ENABLED=true
      - N8N_RUNNERS_MODE=external
      - N8N_RUNNERS_BROKER_LISTEN_ADDRESS=0.0.0.0
      - N8N_RUNNERS_AUTH_TOKEN=your-secret-here
      - N8N_NATIVE_PYTHON_RUNNER=true
    ports:
      - "5678:5678"
    volumes:
      - n8n_data:/home/node/.n8n
    # etc.

  task-runners:
    image: n8nio/runners:1.111.0
    container_name: n8n-runners
    environment:
      - N8N_RUNNERS_TASK_BROKER_URI=http://n8n-main:5679
      - N8N_RUNNERS_AUTH_TOKEN=your-secret-here
      # etc.
    depends_on:
      - n8n

volumes:
  n8n_data:
```

There are three layers of configuration: the n8n container, the runners container, and the launcher inside the runners container.

### Configuring n8n container in external mode <a href="#configuring-n8n-container-in-external-mode" id="configuring-n8n-container-in-external-mode"></a>

These are the main environment variables that you can set on the n8n container running in external mode:

{% hint style="warning" %}
**Feature availability**

`N8N_RUNNERS_ENABLED` is deprecated from n8n 2.0. You no longer need to set it. It's still supported in n8n 1.x, where you must set it to `true` to enable task runners. Leaving task runners disabled on 1.x runs Code node scripts inside the main n8n process with no isolation at all. Don't do this on any instance that holds sensitive credentials or data.
{% endhint %}

| Environment variables                                  | Description                                                                                                                                                                   |
| ------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_RUNNERS_ENABLED=true`                             | Enables task runners. Deprecated from n8n 2.0. Still supported in n8n 1.x.                                                                                                    |
| `N8N_RUNNERS_MODE=external`                            | Use task runners in external mode.                                                                                                                                            |
| `N8N_RUNNERS_AUTH_TOKEN=<random secure shared secret>` | A shared secret task runners use to connect to the broker.                                                                                                                    |
| `N8N_RUNNERS_BROKER_LISTEN_ADDRESS=0.0.0.0`            | By default, the task broker only listens to localhost. When using multiple containers (for example, with Docker Compose), it needs to be able to accept external connections. |

For full list of environment variables see [task runner environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/task-runners).

### Configuring runners container in external mode <a href="#configuring-runners-container-in-external-mode" id="configuring-runners-container-in-external-mode"></a>

These are the main environment variables that you can set on the runners container running in external mode:

| Environment variables                                  | Description                                                                                                                                                                                                                 |
| ------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `N8N_RUNNERS_AUTH_TOKEN=<random secure shared secret>` | The shared secret the task runner uses to connect to the broker.                                                                                                                                                            |
| `N8N_RUNNERS_TASK_BROKER_URI=localhost:5679`           | The address of the task broker server within the n8n instance.                                                                                                                                                              |
| `N8N_RUNNERS_AUTO_SHUTDOWN_TIMEOUT=15`                 | Number of seconds of inactivity to wait before shutting down the task runner process. The launcher will automatically start the runner again when there are new tasks to execute. Set to `0` to disable automatic shutdown. |

For full list of environment variables see [task runner environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/task-runners).

### Configuring launcher in runners container in external mode <a href="#configuring-launcher-in-runners-container-in-external-mode" id="configuring-launcher-in-runners-container-in-external-mode"></a>

The launcher reads environment variables from runners container environment, and performs the following actions:

* Passing environment variables from the launcher's own environment to all runners (`allowed-env`)
* Setting specific environment variables on specific runners (`env-overrides`)

Which environment variables to pass and to set are defined in the [launcher config file](https://github.com/n8n-io/n8n/blob/master/docker/images/runners/n8n-task-runners.json) included in the runners image. This config file is located in the container at `/etc/task-runners.json`. To learn more about the launcher config file, refer to the [Config file documentation](https://github.com/n8n-io/task-runner-launcher/blob/main/docs/setup.md#config-file).

The default launcher configuration file is locked down, but you can edit this file, for example, to allowlist first- or third-party modules. To customize the launcher configuration file, mount to this path:

```
path/to/n8n-task-runners.json:/etc/n8n-task-runners.json
```

## Adding extra dependencies <a href="#adding-extra-dependencies" id="adding-extra-dependencies"></a>

### 1. Extend the `n8nio/runners` image <a href="#id-1-extend-the-n8niorunners-image" id="id-1-extend-the-n8niorunners-image"></a>

You can extend the `n8nio/runners` image to add extra dependencies to the runners. You'll need at least `n8nio/runners:1.121.0` to do this.

```dockerfile
FROM n8nio/runners:1.121.0
USER root
RUN cd /opt/runners/task-runner-javascript && pnpm add moment uuid
RUN cd /opt/runners/task-runner-python && uv pip install numpy pandas
COPY n8n-task-runners.json /etc/n8n-task-runners.json
USER runner
```

You must also allowlist any first-party or third-party packages for use by the Code node. Do this by editing the configuration file `n8n-task-runners.json` to include the packages in your extended image.

```json
{
  "task-runners": [
    {
      "runner-type": "javascript",
      "env-overrides": {
        "NODE_FUNCTION_ALLOW_BUILTIN": "crypto",         // <-- allowlist Node.js builtin modules here
        "NODE_FUNCTION_ALLOW_EXTERNAL": "moment,uuid",   // <-- allowlist third-party JS packages here
      }
    },
    {
      "runner-type": "python",
      "env-overrides": {
        "PYTHONPATH": "/opt/runners/task-runner-python",
        "N8N_RUNNERS_STDLIB_ALLOW": "json",              // <-- allowlist Python standard library packages here
        "N8N_RUNNERS_EXTERNAL_ALLOW": "numpy,pandas"     // <-- allowlist third-party Python packages here
      }
    }
  ]
}
```

* `NODE_FUNCTION_ALLOW_BUILTIN`: comma-separated list of allowed node builtin modules.
* `NODE_FUNCTION_ALLOW_EXTERNAL`: comma-separated list of allowed JS packages.
* `N8N_RUNNERS_STDLIB_ALLOW`: comma-separated list of allowed Python standard library packages.
* `N8N_RUNNERS_EXTERNAL_ALLOW`: comma-separated list of allowed Python packages.

### 2. Build your custom image <a href="#id-2-build-your-custom-image" id="id-2-build-your-custom-image"></a>

For example, from the n8n repository root:

```bash
docker buildx build \
  -f docker/images/runners/Dockerfile \
  -t n8nio/runners:custom \
  .
```

### 3. Run the image <a href="#id-3-run-the-image" id="id-3-run-the-image"></a>

For example:

```bash
docker run --rm -it \
  -e N8N_RUNNERS_AUTH_TOKEN=test \
  -e N8N_RUNNERS_LAUNCHER_LOG_LEVEL=debug \
  -e N8N_RUNNERS_TASK_BROKER_URI=http://host.docker.internal:5679 \
  -p 5680:5680 \
  n8nio/runners:custom
```

## Related resources

* [Configure n8n](/deploy/host-n8n/configure-n8n)


# Durable scheduler

How the durable scheduler runs time-based workflows from a database-backed queue for your self-hosted n8n instance.

The durable scheduler runs time-based workflows, such as those that start with a Schedule Trigger node, from a database-backed queue instead of from each instance's memory. It's on by default from n8n 2.45.0. This page explains what it changes, how to configure it, and how to [use the in-memory scheduler](#use-the-in-memory-scheduler). For the environment variables that configure it, see [Scheduler environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/scheduler).

{% hint style="info" %}
**Feature availability**

The durable scheduler is available from n8n 2.36.0. Earlier versions back to n8n 2.32.0 include it as a Preview feature. Before n8n 2.45.0, it's off by default. From n8n 2.45.0, it's on by default for both new and existing instances, unless you explicitly turn it off.
{% endhint %}

## In-memory scheduler compared to the durable scheduler <a href="#in-memory-vs-durable" id="in-memory-vs-durable"></a>

The in-memory scheduler was the default before n8n 2.45.0. It works out when its active schedules should fire and holds those timers in the main instance's process. This works well for a single instance, but it has limits:

* **Restarts lose pending runs.** When an instance stops, its in-memory timers go with it. n8n skips any run whose time passed during the downtime rather than catching it up.
* **Multiple instances need a leader.** In a multi-main setup, only the leader fires schedules. If leadership changes at the wrong moment, timing can slip.

The durable scheduler addresses both by moving scheduling into the database:

* **Runs survive restarts.** The scheduler records each upcoming run in the database before it's due. A restart doesn't drop it. A run whose time passed while the instance was down still fires late when the instance comes back, as long as it's within its grace period; beyond that, the trigger's [misfire policy](#misfire-policy) decides what happens to it.
* **One instance claims each run.** Every main instance shares the same queue and claims runs from it. Only one instance holds each run at a time, so the work spreads across your mains instead of depending on a single leader.

### What changes functionally <a href="#functional-changes" id="functional-changes"></a>

When you upgrade to n8n 2.45.0 or turn on the durable scheduler, these behaviors apply:

* **Timing stays precise.** Runs still fire at their scheduled instant, as they do on the in-memory scheduler.
* **Fixed intervals are the default from n8n 2.45.0.** "Every N seconds" and "every N minutes" schedules run at uniform intervals measured from workflow publication. Set `N8N_SCHEDULER_TRIGGER_NODE_MODE=legacy` to keep clock-aligned timing. See [Schedule Trigger timing](#trigger-node-mode).
* **Missed runs follow a misfire policy.** Because the scheduler records runs in advance, a run missed during downtime stays on record. Within its grace period it still fires, late; beyond that, the trigger's [misfire policy](#misfire-policy) decides whether n8n discards it or runs a catch-up run.

## Configure the durable scheduler <a href="#turn-on" id="turn-on"></a>

From n8n 2.45.0, `N8N_SCHEDULER_ENABLED` defaults to `true`, so you don't need to set it. If you set it to `false` before upgrading, keep it to stay on the in-memory scheduler, or remove it and restart n8n to use the durable scheduler. Before n8n 2.45.0, set it to `true` to opt in.

{% hint style="warning" %}
The durable scheduler only takes over Schedule Trigger nodes when the workflow publication service is also on. `N8N_USE_WORKFLOW_PUBLICATION_SERVICE` is on by default. If you set it to `false`, n8n logs a warning and Schedule Trigger nodes keep running on the in-memory scheduler, even when `N8N_SCHEDULER_ENABLED` is `true`.
{% endhint %}

The [remaining variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/scheduler) only take effect while the scheduler is on. The defaults suit most instances, so change them only to tune timing precision, storage, or load across instances. All durations are in seconds unless stated otherwise.

### Use the in-memory scheduler

To keep or restore in-memory scheduling, set this environment variable and restart n8n:

```bash
export N8N_SCHEDULER_ENABLED=false
```

This applies to all Schedule Trigger and legacy Cron nodes on the instance. In a multi-main setup, use the same value on every main instance.

n8n 2.45.0 deprecates the in-memory scheduler and `N8N_SCHEDULER_ENABLED`. They remain available as a fallback, but a future version will remove them. If you set `N8N_SCHEDULER_ENABLED` or `N8N_SCHEDULER_TRIGGER_NODE_MODE`, n8n logs a deprecation warning at startup. If the value matches the new default, remove the variable.

n8n 2.45.0 also removes the **Skip Durable Scheduler** node setting and `N8N_ENV_FEAT_SKIP_DURABLE_SCHEDULER`. Existing node settings no longer keep individual triggers in memory. Use `N8N_SCHEDULER_ENABLED=false` to switch the whole instance instead.

### Poll triggers and system tasks

Poll triggers (trigger nodes with a **Poll Times** parameter, such as Google Sheets Trigger or Airtable Trigger) stay on the in-memory scheduler unless you also opt them in with [`N8N_SCHEDULER_POLL_TRIGGERS_ENABLED`](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/scheduler#enable-vars), available from n8n 2.33.0. Poll trigger support isn't 100% stable yet, so keep it off in production unless you're prepared to keep a close watch on your polling workflows. For how polls behave under the durable scheduler, and for the [durable poll cursors](#durable-poll-cursors) that n8n recommends turning on together with `N8N_SCHEDULER_POLL_TRIGGERS_ENABLED`, see [Poll triggers](#poll-triggers).

n8n's internal maintenance jobs also stay on in-process timers unless you opt them in with [`N8N_SCHEDULER_SYSTEM_TASKS_ENABLED`](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/scheduler#enable-vars), from n8n 2.45.0. See [Run system tasks on the durable scheduler](/deploy/host-n8n/configure-n8n/system-tasks#run-system-tasks-on-the-durable-scheduler).

## How the durable scheduler works <a href="#how-it-works" id="how-it-works"></a>

These terms make the environment variables easier to reason about:

* **Schedule**: a recurring rule, such as a Schedule Trigger node's "every 15 minutes" setting. The scheduler stores each schedule in the database.
* **Run**: a single firing of a schedule at a specific time. The scheduler records upcoming runs ahead of time as individual rows.

The scheduler runs five stages, and each stage has its own [environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/scheduler):

1. **Materialization.** The scheduler scans your active schedules and records the runs coming up soon (within the *materialization window*). This commits runs to the database before they're due. If a run is already past its [misfire grace](#misfire-policy) when materialization catches it, the schedule's misfire policy handles it instead of the scheduler recording it as-is.
2. **Execution.** The scheduler claims each recorded run up to one check interval before its time, so no other instance takes it, and starts the workflow at the scheduled instant.
3. **Recovery.** If an instance claims a run but stops before finishing (for example after a crash), the *reaper* releases the run so another instance can pick it up.
4. **Retention.** The scheduler keeps finished runs for a while as recent history, then deletes them to keep its tables small.
5. **Owner reconciliation.** Every schedule has an owner, such as the workflow that created it. The scheduler periodically checks that each owner still exists and retires the schedules whose owner no longer exists. See the [owner reconciliation environment variables](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/scheduler#owner-reconciliation).

Across multiple instances, every main runs all five stages. Claiming keeps this safe: because only one instance claims each run, running the loops everywhere shares the load rather than duplicating work.

## Misfire policy <a href="#misfire-policy" id="misfire-policy"></a>

A run counts as missed once it's later than its grace period. The grace period defaults to `N8N_SCHEDULER_MISFIRE_GRACE` (one minute by default); from n8n 2.36.0, a Schedule Trigger node added from that version on can set its own with the **Missed Execution Grace Period (Seconds)** node option. n8n raises a node's grace period to an instance-derived minimum (based on `N8N_SCHEDULER_EXECUTOR_INTERVAL` and `N8N_SCHEDULER_MATERIALIZATION_WINDOW`) when set below it, and caps it at 30 days.

What happens to a missed run, and to any backlog behind it, depends on the trigger's misfire policy:

* **Don't Run Missed Executions** (default). n8n discards the backlog of missed runs entirely, and the schedule resumes from its next run. This matches the in-memory scheduler, which never runs a missed occurrence late.
* **Run the Most Recent Missed Execution.** The backlog collapses into a single catch-up run for the node, at the most recent missed time across all its trigger rules, then the schedule resumes.
* **Run the Most Recent Missed Execution Per Rule.** Like the previous policy, but each trigger rule catches up on its own, so a node with several trigger rules can fire one catch-up run per rule.

From n8n 2.36.0, a Schedule Trigger node added from that version on chooses the policy with the **If Execution Is Missed** node option; see the [Schedule Trigger node documentation](/integrations/builtin/core-nodes/n8n-nodes-base.scheduletrigger#node-options). Trigger nodes that poll (such as Google Sheets Trigger or Airtable Trigger) always skip missed runs, and polling resumes from the next scheduled run.

Whatever the policy, the schedule's clock advances past the backlog: no policy replays it run by run. A one-off schedule has no next occurrence to resume from, so a catch-up policy still runs it late, while skipping discards it for good.

{% hint style="info" %}
To pick a grace period, start from the floor: keep `N8N_SCHEDULER_MISFIRE_GRACE` above `N8N_SCHEDULER_EXECUTOR_INTERVAL` and at least `N8N_SCHEDULER_MATERIALIZATION_WINDOW` (n8n warns at startup if it isn't). Above that floor, set it to the longest delay a run should tolerate before it counts as missed, such as the time a restart or a leadership change takes on your instance. With the defaults, that's 60 seconds or more.
{% endhint %}

## Schedule Trigger timing (deviations) <a href="#trigger-node-mode" id="trigger-node-mode"></a>

Under the durable scheduler, most Schedule Trigger schedules fire the same way they did in memory. The instance-wide changes above still apply: missed runs follow a misfire policy, and one instance claims each run. On top of that, two cadences fire differently from the in-memory scheduler in specific cases:

* **"Every N seconds" and "every N minutes".** `N8N_SCHEDULER_TRIGGER_NODE_MODE` controls how these fire. It's the only cadence the setting affects.
* **"Every N hours", "days", "weeks", or "months".** These fire as before in everyday use, under either mode. The durable scheduler handles a few rare calendar edge cases more correctly than the in-memory scheduler: leap years, the 53rd week of a year, and daylight-saving transitions, where the in-memory scheduler could be off by one period.

`N8N_SCHEDULER_TRIGGER_NODE_MODE` has two values:

* `new` (default from n8n 2.45.0): runs fire a fixed number of seconds apart, counted from the moment you published the workflow instead of from clock boundaries. For example, publishing at 7 seconds past the minute places "every 30 seconds" runs at :37, then :07 of the next minute, and so on. The gap stays at the interval you set, including across minute boundaries, so "every 7 seconds" never drifts.
* `legacy` (default before n8n 2.45.0): runs fire on clock boundaries, the same as the in-memory scheduler. "Every 30 seconds" fires at :00 and :30 of each minute. The pattern restarts at the top of every minute, so an interval that doesn't divide evenly into 60 leaves an uneven gap at the minute boundary. "Every 7 seconds" fires at :00, :07, :14, and so on up to :56, then jumps back to :00, a 4-second gap instead of 7.

To keep clock-aligned timing, set `N8N_SCHEDULER_TRIGGER_NODE_MODE=legacy`. This keeps the durable scheduler on. n8n 2.45.0 deprecates the `legacy` mode and this variable. A future version will remove them. If you already set the variable to `new`, you can remove it.

{% hint style="info" %}
`N8N_SCHEDULER_TRIGGER_NODE_MODE` only affects "every N seconds" and "every N minutes" schedules. Every other cadence, including raw cron expressions, fires the same way under either value.
{% endhint %}

## Poll triggers

When [`N8N_SCHEDULER_POLL_TRIGGERS_ENABLED`](#turn-on) is on, each of a poll trigger's poll times runs as its own durable schedule: polls survive restarts and spread across instances like any other run. Three behaviors are specific to poll triggers:

* **Missed polls are always skipped.** A poll fetches everything new since it last ran, so a catch-up poll would repeat the same fetch. See [Misfire policy](#misfire-policy).
* **A poll can occasionally run twice.** The scheduler guarantees each dispatched poll runs at least once, not that it runs only once. A poll can repeat, for example when an instance stalls and another takes over. Turn on [durable poll cursors](#durable-poll-cursors) so a repeated poll can't drop or duplicate items.
* **A poll that runs too long is abandoned.** From n8n 2.37.0, a poll that runs longer than [`N8N_SCHEDULER_POLL_TIMEOUT`](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/scheduler#poll-triggers) (45 seconds by default) is abandoned. n8n stops waiting for it and records nothing: the cursor stays put, so the next poll covers the same ground and no data goes missing. This guards against a poll stuck on a service that never answers. A poll that keeps timing out counts as failing. n8n re-polls it at a widening interval instead of hammering a service that can't keep up. Keep the timeout below `N8N_SCHEDULER_LEASE_DURATION`, so an abandoned poll can't still be running when another instance takes its run over. n8n warns at startup when the timeout reaches the lease duration.

### Durable poll cursors

Each poll trigger node keeps a cursor: its record of how far it has already read, so each poll only fetches what's new. By default, n8n stores the cursor in the workflow's static data and saves it separately from the execution the poll produced. If the instance crashes between the two saves, or two instances poll the same node at once, the cursor and the execution fall out of step, and the workflow either skips items or processes them twice.

From n8n 2.36.0, set `N8N_POLLER_DURABLE_CURSORS_ENABLED` to `true` to prevent this. n8n then keeps each node's cursor in its own database table and saves it together with the execution, so a poll round either fully happened or didn't happen at all. n8n recommends turning it on whenever poll triggers run on the durable scheduler.

From n8n 2.37.0, the setting only takes effect when `N8N_SCHEDULER_ENABLED`, `N8N_SCHEDULER_POLL_TRIGGERS_ENABLED`, and `N8N_USE_WORKFLOW_PUBLICATION_SERVICE` are all on. If any of them is off, n8n logs a warning at startup and cursors stay in workflow static data.

What to expect when you turn it on:

* **The switch is safe.** The node's next poll carries its current cursor over to the new table, so nothing is fetched twice or skipped.
* **n8n checks your workflows first (n8n 2.36 only).** At startup, n8n scans every active workflow's published version for duplicate or missing trigger node ids. If it finds any, or can't scan a workflow, it turns off durable poll cursors, keeps poll triggers on the in-memory scheduler for the whole instance, and logs an error naming the affected workflows and how to fix them.
* **Turning it back off doesn't undo it.** Cursors stay in their table; they just stop saving together with the execution.
* **You can watch cursor saves.** Turn on the [poll trigger metrics](#poll-trigger-metrics) with `N8N_METRICS_INCLUDE_POLL_TRIGGER_METRICS`.

{% hint style="warning" %}
Turn on `N8N_POLLER_DURABLE_CURSORS_ENABLED` together with `N8N_SCHEDULER_POLL_TRIGGERS_ENABLED`. Running poll triggers on the durable scheduler while cursors still live in workflow static data risks dropped or duplicated items.
{% endhint %}

## Observability

The durable scheduler exposes Prometheus metrics on the `/metrics` endpoint, so you can tell whether runs start on time, whether they succeed, and whether the queue is draining. Turn them on with two environment variables:

```bash
export N8N_METRICS=true
export N8N_METRICS_INCLUDE_SCHEDULER_METRICS=true
```

Only main instances emit scheduler metrics. To set up the endpoint itself, see [Enable Prometheus metrics](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/enable-prometheus-metrics). To chart the metrics, see [Visualize metrics with Grafana](/deploy/host-n8n/keep-n8n-running/visualize-metrics-with-grafana); n8n publishes a [ready-made durable scheduler dashboard](https://github.com/n8n-io/n8n-observability/tree/main/dashboards/grafana/n8n-scheduler) with a suggested action for each panel.

n8n's own maintenance tasks have their own metric set, behind `N8N_METRICS_INCLUDE_SYSTEM_TASK_METRICS`. It covers them whether they run on the durable scheduler or on an in-memory timer. See [System tasks](/deploy/host-n8n/configure-n8n/system-tasks).

Two words in the metric names need translating. A *task* is a run the scheduler recorded in the database. An *occurrence* is a run it computed from a schedule, which becomes a task once materialization records it. Most series carry a `task_type` label, either `workflow:schedule-trigger` or `workflow:poll-trigger`, so you can tell Schedule Trigger nodes and poll triggers apart.

### Queue health

These four gauges are a snapshot of the queue, read fresh on each scrape. They describe the whole cluster, so every main reports the same values: aggregate them with `max` or `avg`, never `sum`.

| Metric                                     | What it tells you                                                                                                                                                |
| ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `n8n_scheduler_tasks_pending`              | How many recorded runs are waiting. This tracks how many schedules you have, so watch the trend rather than the number.                                          |
| `n8n_scheduler_tasks_due`                  | How many recorded runs are already past their time and still haven't started. Should sit near zero.                                                              |
| `n8n_scheduler_tasks_running`              | How many runs instances across the cluster have claimed and are running right now.                                                                               |
| `n8n_scheduler_oldest_pending_age_seconds` | How far behind the oldest due run is. The clearest backlog signal: `0` means nothing is due and waiting, and a climbing value means the scheduler can't keep up. |

Each scrape queries the database once for all four gauges. `N8N_METRICS_SCHEDULER_INTERVAL` (20 seconds by default) caches that query, so a tight scrape interval doesn't hammer the tables the scheduler reads.

### Run throughput and failures

Counters and the histogram record each main's own work, so sum them across your mains for cluster totals.

| Metric                                    | Type      | What it tells you                                                                                                                                                                                                                                                                                       |
| ----------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `n8n_scheduler_tasks_dispatched_total`    | Counter   | How many runs the scheduler handed to a handler to start. Your scheduling throughput.                                                                                                                                                                                                                   |
| `n8n_scheduler_tasks_completed_total`     | Counter   | How many runs reached a final outcome, split by a `result` label of `success` or `failure`. A rising failure share points at the workflow or the database, not at the scheduler.                                                                                                                        |
| `n8n_scheduler_task_retries_total`        | Counter   | How many failed runs the scheduler queued for another attempt.                                                                                                                                                                                                                                          |
| `n8n_scheduler_tasks_reclaimed_total`     | Counter   | How many runs the reaper took back from an instance that claimed one and stopped. A rising count means instances are crashing or losing their claim mid-run.                                                                                                                                            |
| `n8n_scheduler_tasks_lease_lost_total`    | Counter   | How many runs finished after another instance had already reclaimed their claim, so the same run may have executed twice. Split by `task_type`. For poll triggers this is the cross-instance overlap signal, and [durable poll cursors](#durable-poll-cursors) keep the cursor correct when it happens. |
| `n8n_scheduler_tasks_dead_lettered_total` | Counter   | How many runs n8n gave up on after `N8N_SCHEDULER_MAX_ATTEMPTS` attempts. Every one is a run that never happened, so treat any increase as an alert.                                                                                                                                                    |
| `n8n_scheduler_dispatch_lag_seconds`      | Histogram | How long each run waited between falling due and starting. Watch the high percentiles: a p99 pulling away from the p50 means a subset of runs stalls rather than the whole queue slowing down.                                                                                                          |

### Background passes

These counters cover the [five stages](#how-it-works) that keep the queue moving. They're most useful when a stage stops doing its job.

| Metric                                         | Type    | What it tells you                                                                                                                                                                                                                  |
| ---------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `n8n_scheduler_occurrences_materialized_total` | Counter | How many upcoming runs the scheduler wrote to the database. Flat at zero while you have published schedules means materialization stopped.                                                                                         |
| `n8n_scheduler_jobs_deferred_total`            | Counter | How many schedules materialization couldn't plan and will retry, such as one with an expression it can't read.                                                                                                                     |
| `n8n_scheduler_occurrences_misfired_total`     | Counter | How many due runs a [misfire policy](#misfire-policy) discarded instead of recording, split by `task_type` and by the `policy` that discarded them. Expect a spike after downtime; steady growth means runs routinely arrive late. |
| `n8n_scheduler_occurrences_retired_total`      | Counter | How many recorded runs the scheduler dropped because a catch-up run superseded them.                                                                                                                                               |
| `n8n_scheduler_occurrences_missed_total`       | Counter | How many recorded runs went past their deadline unclaimed and the reaper marked missed.                                                                                                                                            |
| `n8n_scheduler_tasks_pruned_total`             | Counter | How many finished runs retention deleted. If it never rises, the scheduler tables keep growing.                                                                                                                                    |
| `n8n_scheduler_jobs_quarantined_total`         | Counter | How many schedules owner reconciliation stopped because their owner no longer exists. Available from n8n 2.39.0.                                                                                                                   |
| `n8n_scheduler_orphaned_jobs_deleted_total`    | Counter | How many stopped schedules owner reconciliation deleted after their owner stayed missing past the quarantine grace. Available from n8n 2.39.0.                                                                                     |
| `n8n_scheduler_jobs_revived_total`             | Counter | How many stopped schedules owner reconciliation resumed because their owner turned out to exist after all. Available from n8n 2.39.0.                                                                                              |

### Poll trigger metrics

Poll triggers have their own metric set behind a separate switch, `N8N_METRICS_INCLUDE_POLL_TRIGGER_METRICS`, independent of the scheduler metrics above:

```bash
export N8N_METRICS=true
export N8N_METRICS_INCLUDE_POLL_TRIGGER_METRICS=true
```

Only main instances emit them. They come from the poll engine itself, not the scheduler, so they work even when the durable scheduler doesn't dispatch your polls. Like the scheduler counters, they record each main's own polls: sum across mains for cluster totals. n8n publishes a [ready-made poll triggers dashboard](https://github.com/n8n-io/n8n-observability/tree/main/dashboards/grafana/n8n-poll-triggers) for them.

| Metric                                            | Type      | What it tells you                                                                                                                                                                                                                                                                                                                                                                                          |
| ------------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `n8n_poll_trigger_duration_seconds`               | Histogram | How long each poll takes, split by `node_type` and `status`. A poll that grows slower over time is drifting toward its own interval. Once the duration crosses that interval, polls start overlapping.                                                                                                                                                                                                     |
| `n8n_poll_trigger_errors_total`                   | Counter   | How many polls threw, split by `node_type` and a `kind` label of `auth`, `rate_limited`, or `thrown`. `auth` points at a broken credential, `rate_limited` at polling faster than the service allows.                                                                                                                                                                                                      |
| `n8n_poll_trigger_overlapping_ticks_total`        | Counter   | How many polls started while the previous poll for the same node was still running in the same process. Overlap across instances shows up in `n8n_scheduler_tasks_lease_lost_total` instead.                                                                                                                                                                                                               |
| `n8n_poll_trigger_timeouts_total`                 | Counter   | How many polls the durable scheduler abandoned because they ran longer than `N8N_SCHEDULER_POLL_TIMEOUT`, split by `node_type`. An abandoned poll records nothing, and the next poll covers the same window. Steady growth means a polled service answers slower than the timeout. Only the durable scheduler abandons polls, so this stays at zero on the in-memory scheduler. Available from n8n 2.37.0. |
| `n8n_poll_trigger_cursor_commits_total`           | Counter   | How many cursor saves settled, split by `operation` (`with_execution` or `cursor_only`) and `result`. A `result` of `fence_rejected` means a stale poll lost its claim and wasn't allowed to advance the cursor, which is the protection doing its job. A `result` of `failure` means the save itself failed.                                                                                              |
| `n8n_poll_trigger_cursor_commit_duration_seconds` | Histogram | How long each cursor save takes, with the same `operation` and `result` labels.                                                                                                                                                                                                                                                                                                                            |

The two cursor metrics track the dedicated cursor table. A node starts reporting them with its first poll after you turn on [durable poll cursors](#durable-poll-cursors). It keeps reporting them after you turn the setting off, because its cursor stays in the table.

All names above assume the default `n8n_` metrics prefix. If you set `N8N_METRICS_PREFIX`, substitute your own.

## Related resources

* [Configure n8n](/deploy/host-n8n/configure-n8n)


# System tasks

How n8n runs its internal maintenance tasks, and the Prometheus metrics they expose on your self-hosted instance.

System tasks are the recurring maintenance jobs n8n runs on itself: pruning old executions, compacting insights data, cleaning up stale records, renewing your license. They aren't workflows, they don't belong to a project, and they don't show up anywhere in the editor. When one of them stops running, nothing fails: your database just keeps growing, or your insights data goes stale.

This page explains how system tasks run and which Prometheus metrics they expose, so you can tell that they still run, and how well.

## How system tasks run

Each system task has its own cadence, either a fixed interval or a cron schedule, and runs in one of three modes. The `mode` label on the metrics below tells you which one:

* **Leader timer**, `leader_timer`. A timer in the leader main instance runs the task. The timers stop when the leader steps down and start on the new leader. A run that falls due while the instance is down doesn't happen.
* **Instance timer**, `instance_timer`. Every process the task targets runs its own copy, because the task acts on state of that process. Available from n8n 2.42.0.
* **Durable**, `durable`. The [durable scheduler](/deploy/host-n8n/configure-n8n/durable-scheduler) runs the task from its database-backed queue. Any main instance can claim a due run, and a restart doesn't drop it. Available from n8n 2.41.0.

### Run system tasks on the durable scheduler

To move system tasks to the durable scheduler, set these environment variables on every main instance and restart n8n:

```bash
export N8N_SCHEDULER_ENABLED=true
export N8N_SCHEDULER_SYSTEM_TASKS_ENABLED=true
```

Give every main instance the same values for both variables. Only tasks that support durable mode move over. The rest keep their timer mode.

{% hint style="warning" %}
Run the same n8n version on every main instance. During a rolling deploy, an older main instance can run a task from its leader timer while newer ones run it on the durable scheduler, so the task can run twice.
{% endhint %}

A durable system task is also a scheduler task. The [durable scheduler metrics](/deploy/host-n8n/configure-n8n/durable-scheduler#observability) report it with the `task_type` label `system:<task-name>`, for example `system:insights-compaction`. The metrics on this page cover all three modes under the same names.

## Observability

{% hint style="info" %}
**Feature availability**

System task metrics are available from n8n 2.41.0.
{% endhint %}

Turn the metrics on with two environment variables:

```bash
export N8N_METRICS=true
export N8N_METRICS_INCLUDE_SYSTEM_TASK_METRICS=true
```

Workers and webhook processors also emit them for their own instance timer tasks. To set up the endpoint itself, see [Enable Prometheus metrics](/deploy/host-n8n/configure-n8n/basic-configuration/configuration-examples/enable-prometheus-metrics). To chart the metrics, see [Visualize metrics with Grafana](/deploy/host-n8n/keep-n8n-running/visualize-metrics-with-grafana). n8n publishes a [ready-made system tasks dashboard](https://github.com/n8n-io/n8n-observability/tree/main/dashboards/grafana/n8n-system-tasks) with a suggested action for each panel.

All names below assume the default `n8n_` metrics prefix. If you set `N8N_METRICS_PREFIX`, substitute your own.

### Labels

Every series carries a small, fixed set of labels:

| Label    | Values                                                                                              | What it means                                                                                                                                                                                                                                           |
| -------- | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `task`   | The task name, such as `execution-pruning-soft-delete`, `insights-compaction`, or `license-renewal` | Which system task the series describes. Which tasks exist depends on your version, your license, and your settings, so read the list off `n8n_system_task_info` rather than hard-coding it.                                                             |
| `mode`   | `leader_timer`, `instance_timer`, `durable`                                                         | Where the task runs. See [How system tasks run](#how-system-tasks-run). Before n8n 2.42.0, `leader_timer` was `in_memory`.                                                                                                                              |
| `result` | `success`, `failure`, `aborted`, `lease_lost`, `timed_out`                                          | How a run ended. `aborted` means the run was still going when the instance stepped down or shut down, so it stopped without finishing its work. `lease_lost` and `timed_out`, from n8n 2.44.0, mean a durable run lost its claim or passed its timeout. |
| `reason` | `overlap`, `provisioned_elsewhere`, `aborted`, `coalesced`                                          | Why an occurrence didn't run. See [In-memory scheduling](#in-memory-scheduling).                                                                                                                                                                        |

There's no instance label. Prometheus adds `instance` and `job` per scrape target, so aggregate with `max by (task)` for the gauges that describe a task, and `sum by (task)` for counters, histograms, and the in-flight gauge.

### Run health

These three series cover the runs themselves, in all three modes.

| Metric                                           | Type      | What it tells you                                                                                                                                                                                                                                                                    |
| ------------------------------------------------ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `n8n_system_task_run_duration_seconds`           | Histogram | How long each run takes, split by `task`, `mode`, and `result`. The `_count` series doubles as your run count and failure count, so you don't need a separate counter. A duration creeping toward the task's own cadence means n8n is about to skip the next occurrence for overlap. |
| `n8n_system_task_last_success_timestamp_seconds` | Gauge     | The Unix timestamp of the task's last successful run on this instance. The clearest "is this task dead" signal, because it answers for a task that never ran at all, which a rate over a counter can't.                                                                              |
| `n8n_system_task_runs_in_flight`                 | Gauge     | How many runs of the task are going right now on this instance, `0` or `1` in the normal case. A value stuck at `1` is a hung run, which also blocks the instance from stepping down or shutting down.                                                                               |

### Schedule health

These series describe the schedule rather than a run, so they exist before the first run happens.

| Metric                                           | Type    | What it tells you                                                                                                                                                                                                                                                                                                                                                                                         |
| ------------------------------------------------ | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `n8n_system_task_info`                           | Gauge   | Always `1`, one series per task this instance can run, with its `mode`. Your inventory of system tasks: join against it to find a task that reports no runs.                                                                                                                                                                                                                                              |
| `n8n_system_task_interval_seconds`               | Gauge   | The task's declared cadence, for tasks on a fixed interval. This turns "late" into a query instead of a list of thresholds you maintain by hand. Tasks on a cron schedule don't report it.                                                                                                                                                                                                                |
| `n8n_system_task_next_run_timestamp_seconds`     | Gauge   | The Unix timestamp of the next occurrence, for interval and cron schedules. For a timer task, it's the occurrence the timer on this instance is armed for. A timestamp in the past means the timer stopped planning. For a durable task, it's the first occurrence the scheduler didn't plan yet, so a planned run can start earlier. Every main instance reports the same value, read from the database. |
| `n8n_system_task_scheduled`                      | Gauge   | `1` while n8n has the task scheduled, `0` once the task lost its schedule, because n8n couldn't plan its timer cadence or no runnable durable job exists for it. A `0` here means the task stopped rather than running late: it takes an instance restart, or a leadership change for a leader timer task, to get it scheduled again. Alert on it.                                                        |
| `n8n_system_task_provision_check_failures_total` | Counter | How many times n8n couldn't check whether a task's durable job exists and ran the task from the leader timer instead. A rising count means database trouble, and a small risk of the same task running twice while both paths are live.                                                                                                                                                                   |

The series for a durable or instance timer task appear as soon as n8n routes the task at startup, so a restart shows up as a reset rather than a gap. The `info`, `scheduled`, `runs_in_flight`, `last_success`, and `next_run_timestamp_seconds` series of a leader timer task exist only while this instance leads, and n8n removes them when the instance steps down: a former leader doesn't keep exporting frozen values for runs it no longer makes. Only `interval_seconds` stays, because the cadence doesn't depend on who leads.

### In-memory scheduling

These series only cover timer runs. The durable path has its own equivalents in the [durable scheduler metrics](/deploy/host-n8n/configure-n8n/durable-scheduler#observability): `n8n_scheduler_task_retries_total` for retries and `n8n_scheduler_dispatch_lag_seconds` for lag.

| Metric                               | Type      | What it tells you                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ------------------------------------ | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `n8n_system_task_runs_skipped_total` | Counter   | How many occurrences didn't run, split by `reason`. `overlap` means the previous run was still going. `provisioned_elsewhere` means the task has a durable job, so the leader timer stood down. `aborted` means the occurrence fired after the instance had already started stepping down. `coalesced` means the process slept through occurrences and the timer fired a single time for the whole batch, so the counter grows by the number of occurrences that fire stood in for. |
| `n8n_system_task_retries_total`      | Counter   | How many retries n8n scheduled after a failed run. Only tasks that declare a retry delay retry at all, so a failing task with a flat count here isn't a bug.                                                                                                                                                                                                                                                                                                                        |
| `n8n_system_task_fire_lag_seconds`   | Histogram | How late each timer fires, in seconds. Small values mean a busy event loop. Large ones mean the process paused or slept, and its buckets reach a day because a coalesced fire is late by at least one full cadence.                                                                                                                                                                                                                                                                 |

## Related resources

* [Configure n8n](/deploy/host-n8n/configure-n8n)




---

[Next Page](https://docs.n8n.io/llms-full.txt/1)

