# Self-host n8n without touching a server.

> Self-host n8n without a VPS: one sentence in Claude Code, Codex or Cursor runs the official n8n image on Agent Lab with PostgreSQL. Free to try.

Web page: https://agentlab.cresclab.com/en/deploy/n8n  
繁體中文 (Markdown): https://agentlab.cresclab.com/deploy/n8n.md

n8n hosting · Agent Lab Deploy

Paste one sentence into Claude Code, Codex or Cursor and Agent Lab runs n8n with PostgreSQL, free to try.

[Set up n8n free](https://app.agentlab.cresclab.com/?lang=en&intent=deploy) [Jump to the Dockerfile](https://agentlab.cresclab.com/en/deploy/n8n#recipe)

A Claude Code conversation: the user asks for n8n from this page; the agent creates the app, creates and connects a PostgreSQL database, has the platform generate the encryption key, and reports the preview URL once the build passes.

Why self-host

## Why self-host n8n instead of n8n Cloud

Open-source workflow automation with no execution cap, and your data stays yours.

### No server to run

Builds, runtime, HTTPS and releases are handled by the platform.

### Unlimited executions

Run a workflow as often as you like; no execution cap.

### Keys generated by the platform

N8N_ENCRYPTION_KEY and the database password never pass through the chat.

Choosing

## n8n Cloud vs a VPS vs Agent Lab

Self-hosting n8n compared across n8n Cloud, a VPS you rent, and Agent Lab Deploy

| What matters to you | Agent Lab Deploy | n8n Cloud | Your own VPS |
| --- | --- | --- | --- |
| Cost | **Free to try**; always-on from Pro at US$29/month (US$14 credit included) | Starter about €20/month billed yearly, 2,500 executions a month | About US$5–20/month, plus your own upkeep |
| Executions | Unlimited | 2,500 a month on Starter | Unlimited |
| Who runs the server, updates, HTTPS | The platform | n8n | You |
| Where the data lives | Your Agent Lab organization (Google Cloud) | n8n's cloud | Your VPS |
| Setup | One sentence to an AI tool | Sign up | SSH, Docker, reverse proxy |
| When idle | Free sleeps, Pro stays on | Always on | Always on, always billed |

How

## Connect → one sentence → open the URL → create the owner

1. ### Connect Agent Lab
   One MCP line in your AI tool, one browser sign-in. [How →](https://agentlab.cresclab.com/en/mcp)
2. ### Paste the sentence below
   The agent creates the app, connects PostgreSQL, generates the key and builds.
3. ### Open the preview URL
   On first open, n8n asks you to create the owner account.
4. ### Upgrade when it's for real
   Free sleeps after 15 idle minutes; Pro stays on and takes a custom domain.

Copy and go

## The Dockerfile and the sentence

Workflows and credentials live in PostgreSQL, so a rebuilt container loses nothing.

Dockerfile

### Dockerfile

```
FROM docker.n8n.io/n8nio/n8n:latest
USER node
ENV N8N_USER_FOLDER=/tmp/n8n \
    DB_TYPE=postgresdb \
    N8N_DIAGNOSTICS_ENABLED=false \
    GENERIC_TIMEZONE=Asia/Taipei
EXPOSE 5678
CMD ["sh", "-c", "N8N_PORT=$PORT n8n"]
```

- `DB_POSTGRESDB_HOST / PORT / DATABASE / USER / PASSWORD` written by databases_connect_app
- `N8N_ENCRYPTION_KEY` generated by sites_secrets_generate; a changed key can't read saved credentials
- `WEBHOOK_URL` your address, so webhooks resolve correctly

PROMPT

### Say this to your AI tool

```
Read https://app.agentlab.cresclab.com/agent/deploy.md and deploy n8n to Agent Lab with the Dockerfile at agentlab.cresclab.com/en/deploy/n8n: create an S PostgreSQL and connect it with databases_connect_app, map its connection to the DB_POSTGRESDB_* variables, generate N8N_ENCRYPTION_KEY with sites_secrets_generate, set WEBHOOK_URL to the app's address. Give me the preview URL when the build passes.
```

FAQ

## Before you self-host n8n

**How much does it cost to self-host n8n?**

Free runs one size-S n8n with one S PostgreSQL at no charge, sleeping after 15 idle minutes. Always-on is Pro at US$29 a month before tax with US$14 of usage credit; n8n prefers size M, billed from the credit.

**Self-hosted n8n vs n8n Cloud?**

n8n Cloud is managed by n8n and caps executions per plan. On Agent Lab the platform runs the server, your data stays in your organization, and executions are unlimited.

**Can I self-host n8n for free?**

Yes. n8n is open source under the Sustainable Use License, and Agent Lab's Free plan runs one size-S n8n once a card is on file, which is never charged.

**Do I lose workflows when the container rebuilds or sleeps?**

No. Workflows, credentials and execution history live in PostgreSQL; the container only writes to /tmp, which a rebuild clears.

**Do I need to know Docker to self-host n8n?**

No. Paste the sentence into Claude Code, Codex or Cursor; it builds, connects the database and sets the variables, and you just approve going live.

**Can I connect LINE, ChatGPT or Google Sheets?**

Yes, all are built-in or community n8n nodes. LINE webhooks need WEBHOOK_URL set to your address; AI nodes use your own OpenAI, Anthropic or Gemini keys.

**What's the easiest way to host n8n?**

Connect Agent Lab's MCP server to Claude Code, Codex or Cursor and paste the sentence on this page: it builds the official n8n image, connects PostgreSQL, generates N8N_ENCRYPTION_KEY and returns a URL.

**How do I upgrade n8n?**

Ask your AI tool to change the image tag and deploy again. The new release goes live once it builds and passes the checks.
