n8n 2.40.7 Automation
Free credit available Limited time

n8n Postgres, wired before n8n wakes up.

n8n 2.40.7, the workflow automation tool, deploys here with its own PostgreSQL 16 onto a dedicated server Selfhost.dev provisions, secures and runs, across six locations on three continents. A European 4 GB server is $0.02/hr, about $15 a month, with n8n connected to its database before it first starts.

See the monthly figure for your region before you sign up.

The template deploys in about five minutes.

+$5.00 added at signup · deployment choice preserved · no card

What the one click sets up, before n8n boots.
Trigger

What is n8n Postgres?

What it is

n8n, the open source automation tool, storing its workflows and execution history in PostgreSQL instead of a SQLite file. Not to be confused with the Postgres node, which queries your own databases from a workflow.

Who it is for

Teams whose workflows run all day, keep long execution history or will need queue mode later. Postgres takes many writers at once, where SQLite writes one at a time.

When to use it

Pick it at deploy time when volume is already heavy or growing. For one person running a handful of workflows, the SQLite template does the same job with one fewer container.

Execute Workflow

What's in the n8n Postgres deployment

Three containers on one project server, each pinned to a version and started together.

Connected before n8n starts

The template sets DB_TYPE=postgresdb and the connection settings before the first boot. n8n builds its own tables the first time it starts. There is no database to create and no seed to run.

Your encryption key is not in Postgres

Postgres holds your credential records, but the key that decrypts them sits in n8n's own volume. We pin that key as a platform secret, so every redeploy starts with the same key and your saved API keys keep working.

Execution history lands in Postgres

Every run n8n records goes into the database. n8n prunes old runs by default and keeps up to 10,000. Postgres reuses the space those deletions free, where a SQLite file keeps its size until it is vacuumed.

The stack, end to end

Callers

Webhooks, APIs, your browser

Edge

TLS and routing

Your project server
Container 1

n8n

Container 2

Task runner

Container 3

PostgreSQL 16

Platform secret

Encryption key

Component manifest
ComponentVersionWhat it does
n8n n8nio/n8n:2.40.7Editor, workflow engine and webhook endpoints, behind HTTPS
Task runner n8nio/runners:2.40.7Runs Code node JavaScript and Python, five at a time
PostgreSQL postgres:16-alpineWorkflows, execution history and credential records
Volumes n8n-data, postgresql-datan8n's own files and the database files
Your workflows go here. Deploy the stack
Code

What we set up for you

Every n8n and Postgres tutorial ends in the same compose file. Here it is already running, with the parts copied versions leave out already set.

If you set it up yourselfOn Selfhost.dev, already done
Write a compose file for n8n and PostgresThree containers, declared and started together
Set DB_TYPE and the DB_POSTGRESDB_* variablesSet before the first boot
Point n8n at the database container, not localhostAlready wired to the database container
Choose a database passwordGenerated for this deployment
Generate N8N_ENCRYPTION_KEY and never lose itPinned as a platform secret
Swap :latest for a real versionn8n 2.40.7 and Postgres 16, pinned
Keep port 5432 off the internetThe server firewall opens only 22, 80 and 443
Put HTTPS and a proxy in frontA Let's Encrypt certificate, with N8N_PROXY_HOPS=1 set
Make webhook URLs match your domainWEBHOOK_URL, N8N_EDITOR_BASE_URL and N8N_HOST follow the live domain
Stop Code nodes reading server secretsN8N_BLOCK_ENV_ACCESS_IN_NODE=true

The example most guides copy publishes Postgres on port 5432 and sets no encryption key. On a server of your own, those are the first two things to fix.

Edit Fields

n8n Postgres requirements

What n8n Postgres needs

n8n
2.40.7, pinned, with its task runner
Database
PostgreSQL 16 in its own container
Containers
3
Memory
4 GB, the smallest server we offer
Disk
40 GB on the 4 GB size, shared by n8n and Postgres
Not configured
SMTP, queue mode, community nodes, external secrets

What we provide

Locations
Falkenstein, Nuremberg, Helsinki, Ashburn, Hillsboro, Singapore
Metrics
Host CPU and memory in the console
Access
Root SSH with your own key
AI control
MCP tools to deploy and manage it from an AI assistant

Specifications current as of September 2026.

Server size: 4 GB, enough for n8n with Postgres. Deploy on a 4 GB server
Split

What a 4 GB server handles

The whole template counts as one light workload. The task runner executes five Code steps at once. The server size, not a plan, sets the ceiling.

On one 4 GB servern8n Postgres on its ownFits: Yes, with room for more light apps
On one 4 GB servern8n Postgres plus one heavy appFits: Yes
On one 4 GB serverLight apps onlyFits: Up to 5 workloads

Need more room? An 8 GB server takes three heavy apps plus one light or any lighter mix.

Run

How to run n8n with Postgres in 4 steps

Four steps. None of them is a compose file.

  1. Open the template

    The Launch button opens the console on this exact template. Choose a server size and one of six locations.

  2. Launch it

    The console shows each provisioning stage. The template deploys in about five minutes onto a generated HTTPS address.

  3. Claim the owner account

    Open the address and create the owner account straight away. That first account runs the instance.

  4. Build or import

    Create your first workflow or import one as JSON. Every run it records from now on lands in Postgres.

Deploy n8n with PostgresStep 1 starts in the console.
Launch n8n with Postgres
Output

What n8n Postgres costs to run

You pay for the server by the hour. The rate depends on where it runs.

$15
a month at 730 hours, rounded
European 4 GB server (cx23), $0.02/hr Deploy n8n with Postgres
What else you pay for
ItemCost
n8n, the task runner and the Postgres container$0
HTTPS and a custom domain$0
Users and seats$0
Bandwidth$0, no traffic metering on a template project
BackupsOptional, +20% of the server rate
ServerRAM, cores, diskWhereRateAbout a month
cx23 (recommended)4 GB, 2 cores, 40 GBEurope$0.02/hr$15
cpx21 (twice the disk)4 GB, 3 cores, 80 GBEurope$0.04/hr$26
cpx214 GB, 3 cores, 80 GBSingapore$0.07/hr$51
cpx214 GB, 3 cores, 80 GBUS$0.12/hr$88
cx33 (one size up)8 GB, 4 cores, 80 GBEurope$0.03/hr$23

Monthly figures assume 730 hours. Hourly rates as displayed in the console, September 2026.

If your balance reaches zero

A server with a card on file or a past top-up is powered off first and held for 24 hours. Adding credit in that window starts it again. Welcome-credit-only servers are deleted at zero. Backups go with the server.

Price another size or region in the calculator, no signup.

Switch

When the SQLite template is the better choice

For one person running a few workflows a day with short history, self hosted n8n on SQLite is the simpler machine: two containers, one volume, the same server price. Postgres earns its extra container when several workflows write at once, history runs long or queue mode is on the roadmap.

Merge

What we run and what you run

We run

  • The server, its firewall and its HTTPS certificates
  • The three containers, on the versions they were pinned to
  • Daily whole-server backups, if you switch them on
  • Host CPU and memory metrics in the console
  • Root SSH for the key you add

You run

  • n8n itself: workflows, credentials and users
  • When to move to a newer n8n or Postgres
  • Your own pg_dump copies, kept off the server
  • Postgres tuning, indexes and pruning settings
  • A mail provider for n8n's invites and resets
Wait

What every n8n Postgres deployment gets

  • Every service is health-checked every 60 seconds.
  • A stalled deploy is retried automatically, not abandoned.
  • A deploy is never reported done until the URL actually answers.
  • Retrying a create never leaves you paying for two copies.
  • Your version never moves on its own.
~5 min to deploy

The n8n Postgres template deploys in about five minutes. That is the platform's own budget, not an estimate.

Sticky notes

n8n Postgres limitations

  1. Postgres, but no queue mode. Postgres is the database queue mode needs, yet spreading work across machines also takes Redis and worker containers, which this template does not run.
  2. One disk for both. n8n and Postgres share the server's fixed disk, 40 GB on the 4 GB size. It does not grow. The 80 GB cpx21 doubles it.
  3. Not a Managed Database. The bundled Postgres has no point in time recovery, pooling or Multi-AZ. Those come with Selfhost.dev Managed PostgreSQL, a separate product.

None of these a dealbreaker? The template deploys in about five minutes.

Launch n8n with Postgres
Postgres

n8n Postgres backup and restore

Two ways to keep n8n and its database safe: a daily image of the whole server plus your own Postgres dumps over SSH.

MethodWhat it coversWhere it lives
Daily server backup (optional, +20%)n8n, Postgres and both volumes in one image, last 7 keptWith the server
pg_dump over root SSHWorkflows, execution history and credential recordsWherever you copy it
n8n's CLI exportWorkflows and credentials as filesWherever you copy it

Dump the database

Add your SSH key to the project, then run docker exec <db-container> pg_dump -U <user> <database> > n8n.sql on the server.

One thing to know about dumps

A dump restores cleanly into this deployment. Restored anywhere else, its credentials need this deployment's encryption key, so export credentials with n8n's CLI as well.

Import

Moving n8n from SQLite to Postgres

Start fresh on this template.

  1. Export your workflows as JSON from the n8n editor.

  2. Import them into the new instance.

  3. Add your credentials again.

Credentials are encrypted with the old instance's key, which is why workflow files leave them behind.

Send Email

Not sure you need Postgres yet?

Tell us how many executions you run a day and how long you keep history. We reply with the database we would pick, the server size and the monthly cost.

Q&A

Frequently asked questions

Which database does n8n use, SQLite or Postgres?

Self hosted n8n uses SQLite unless you configure Postgres. n8n Cloud runs SQLite on its Starter and Pro plans too, keeping Postgres for Enterprise Scaling. Our n8n pricing guide shows what each n8n Cloud plan costs. This template configures Postgres from the start, so workflows, executions and credential records go into PostgreSQL 16 rather than a single file on disk.

Is this the same as the n8n Postgres node?

No. The Postgres node is a step inside a workflow that reads from or writes to a database you point it at. This page is about where n8n keeps its own data. The two work together: an instance running on Postgres can still use the node against any other Postgres database you own.

Do I need to create the n8n database and user myself?

No. The Postgres container starts with n8n's database, user and password already in place, all generated for this deployment. On a server of your own, n8n's docs have you create the database, grant the user its privileges and write the password into n8n's settings before the first start.

Which Postgres schema does n8n use?

n8n uses the public schema unless DB_POSTGRESDB_SCHEMA says otherwise; this template leaves it at public. You never create the tables yourself: n8n runs its migrations against that schema every time it starts, adding whatever tables and columns a new version needs.

Where does n8n keep credentials when it runs on Postgres?

The credential records sit in Postgres, encrypted. The key that decrypts them does not: n8n keeps it in its own data volume. We pin it as a platform secret on this template. That is why a redeploy keeps every saved API key and OAuth token working.

What does the n8n error SQLITE_FULL, database or disk is full, mean?

The disk holding n8n's SQLite file has run out of space, usually because execution history grew. n8n prunes old runs by default, but a SQLite file keeps its size until it is vacuumed. Clearing space fixes the error. On Postgres, the space pruned runs leave behind is reused for new ones.

How much disk does n8n with Postgres get?

The 4 GB server comes with 40 GB of fixed disk, shared by n8n, Postgres and anything else in the project. It does not grow, so if you keep long execution history, the 4 GB cpx21 with 80 GB is the better start. n8n's default pruning keeps the newest 10,000 runs.

Can I move my SQLite n8n to Postgres?

Start fresh on this template: export your workflows as JSON from the n8n editor, import them into the new instance and add your credentials again. Credentials are encrypted with the old instance's key, which is why they do not travel inside workflow files. Delete the SQLite service once everything runs.

n8n Postgres, minus the compose file.

  • PostgreSQL 16 connected before the first boot
  • The encryption key pinned across redeploys
  • One server bill, nothing extra for the template
Launch n8n with Postgres

About Selfhost.dev

Selfhost.dev is a managed self hosting platform for developers and small teams. Open-source apps and databases on dedicated servers you control, billed by the hour with no subscription tiers.

Best for: n8n, Twenty CRM, Supabase and managed PostgreSQL, MySQL, Redis, ClickHouse, OpenSearch and Kafka.