Migrate n8n from SQLite or MySQL to PostgreSQL

Moving n8n onto PostgreSQL is required for MySQL and MariaDB users since n8n 2.0 and is the base for queue mode. This page covers what maps cleanly, the documented export and import path, encryption key handling and the cutover sequence.

On this page

Why teams migrate n8n from SQLite or MySQL to PostgreSQL

If your n8n instance runs on SQLite, MySQL or MariaDB and you plan to move it to PostgreSQL, the effort is a data move plus encryption key handling, not a rebuild of your workflows. The work scales with the size of the instance, the number of credentials and the number of integrations it connects to, so confirm those counts before you ask for a quote. Teams usually make the move for one of two reasons: MySQL and MariaDB are no longer a supported database path since n8n 2.0, or they plan to run queue mode, which relies on PostgreSQL for workflow data shared by the main instance and its workers.

The move uses n8n's own export:entities and import:entities commands, which carry workflows, credentials, projects and related entities from the old database into a fresh PostgreSQL-backed instance. Credentials are encrypted with the instance's encryption key, so the key must travel with the data. Confirm before you start that the key on the target matches the source, that you know where it is stored (for example, in the N8N_ENCRYPTION_KEY environment variable or the configuration file), and that you have a tested copy of it outside the server. A missing or changed key leaves imported credentials unreadable, and that failure often shows up only after cutover.

Ask any partner to inventory the source before quoting: database engine and version, n8n version, number of workflows that are active, number of credentials by type, custom nodes or external hooks, and the webhook URLs that clients call. Those items decide how much testing and re-pointing the work needs. Confirm also whether your PostgreSQL version is still within its support window, since the PostgreSQL versioning policy lists the end date for each major release.

Which starting point changes the work

A single-host install that stores data in SQLite is usually the simplest move. There is one database file, one n8n process and often one team that knows where everything lives. The move still needs a planned cutover, because the export and import run against an instance that has stopped taking new work, and the encryption key must travel with the data.

  • Export entities: Run export:entities to write workflows, credentials and related entities to files that import:entities reads on the new PostgreSQL-backed instance.
  • Encryption key: Copy the existing encryption key before anything else. Stored credentials cannot be decrypted without it. Check whether N8N_ENCRYPTION_KEY is set in the environment or whether the key sits in the config file under the n8n data folder.
  • Pause triggers: Stop schedules and webhook traffic during the export so no new executions change data after the snapshot is taken.
  • Keep a fallback: Keep a copy of the SQLite file and the data folder until the imported instance has run real workflows successfully.
  • What can wait: Queue mode, worker sizing and high availability can be decided after the database is on PostgreSQL.

Confirm the database file path, whether N8N_ENCRYPTION_KEY is set, and where the data folder sits, because those three answers determine the migration steps.

What maps cleanly from SQLite or MySQL and what does not

This table compares each part of an n8n instance across the source database and PostgreSQL, with notes on what moves through n8n's export and import commands and what you must re-enter or reconfigure. Read the migration notes as a checklist for the cutover, and confirm the exact behavior for your n8n version in n8n's own documentation before you run anything.

ItemSource capabilityPostgreSQL target and migration notes
WorkflowsStored in the source database with node settings, connections and pinned dataExported and imported as entities with export:entities and import:entities. Confirm which workflow fields the command carries for your version, and check active states after import.
Execution historyStored as rows in the source database, which can grow largeOften not worth carrying over. Decide whether to keep history, archive it, or prune before export to shorten the migration window. Confirm the export flags for your version.
CredentialsEncrypted in the source database using the instance encryption keyCarried over only if the same encryption key is set on the new instance. If the key is lost, credentials must be re-entered by hand in each workflow's connection.
Users and projectsAccounts, roles and project membership stored in the source databaseImported with entities, but user invitations, password resets and SSO links may need review. Verify account and role mapping in your version's documentation.
TagsStored as database rows linked to workflowsExpected to carry over with workflows. Check that tag assignments match after import.
VariablesStored as database rows, and some may be sensitiveConfirm whether variables are included in the entity export for your version. Re-create any that do not move and review values that were encrypted.
Webhooks and their pathsWebhook paths are stored with workflows and resolve against the instance URLPaths move with workflows, but the public URL changes when the host or domain changes. Update every external caller, OAuth redirect and form that points at the old address.
Custom nodes folderInstalled in the local n8n user folder on the filesystem, outside the databaseNot moved by the database export. Copy the custom node directory and its dependencies separately, then restart and confirm each node loads.
Encryption keyStored in the n8n user folder and used to decrypt credentialsMust be set identically on the new instance and on all queue mode workers and webhook processors before credentials will decrypt. Back up the key with the database dump.

How the export and import path moves data between databases

The path starts on the source n8n instance running on SQLite or MySQL, where export:entities writes workflows, credentials and related entities into an export that is kept apart from the encryption key. The key is held by the operator and supplied to the new PostgreSQL-backed instance, where import:entities restores the data. Check that imported credentials decrypt before the new instance runs alongside the old one, and only move DNS and webhook URLs after that parallel run passes.

Export, key handling, import and parallel run before cutover.

Which documented n8n tools carry the data across

A move from SQLite or MySQL to PostgreSQL depends on a small set of documented pieces working together: the CLI export and import commands, the encryption key, a full backup of the data folder, the PostgreSQL target settings and post-import checks. Each one moves a different part of the instance, so none of them replaces the others.

Export entities with the CLI

The export:entities command writes workflows and credentials from the source instance to files that import:entities can read. It is the documented route for moving workflow definitions and stored credential records between databases. Confirm the exact flags and output format in the CLI reference for your n8n version before you run it on production data, and test the export on a copy first.

Queue mode docs

Import entities into PostgreSQL

The import:entities command loads the exported workflows and credentials into the PostgreSQL database that the new instance uses. Run it after the target database is configured and the schema is initialized, so the import writes into the correct structure. Check the row counts and workflow list in the new instance before you switch any traffic to it.

Source encryption key

Stored credentials are encrypted with the instance encryption key, so the import only works if the new instance uses the same key. Copy the key from the source instance's configuration before you change anything, and store it in your secrets manager. Losing or mistyping this key leaves imported credentials unreadable, and queue mode workers need the same key as the main instance.

Full backup of the data folder

The n8n data folder holds files the export commands do not move, including the encryption key file, settings and any local binary data. Take a complete copy of this folder from the source instance before the migration starts, and keep it until the new instance has run for a period you have agreed. Confirm in the docs which files the export covers, since this varies by version and setup.

PostgreSQL target database settings

The new instance is pointed at PostgreSQL through n8n's database configuration, including the database type, host, port, database name, user, password and schema. Set these before the import so that the instance writes to the intended server. Confirm the supported PostgreSQL major versions for your n8n release, and plan which version you will run, since the PostgreSQL support window determines how long that version receives fixes.

Oldest supported major
14

Post-import checks with the CLI

After import, use n8n's command-line tooling to confirm the instance starts cleanly, the database connection is healthy and the migrated workflows and credentials are present. Check that a sample credential decrypts and that a test workflow runs. Record the results, because auditors and change reviewers will ask how you verified the move.

How the encryption key keeps credentials readable after the move

The encryption key is the one input the migration cannot regenerate. n8n encrypts the credentials it stores, and the export and import commands move the encrypted values without decrypting them. The new PostgreSQL-backed instance can only read those credentials if it is started with the same key the source instance used. Before you run export:entities, record the key the source instance is actually using, from its configuration or environment, and store it outside the server that holds the database. Confirm where your current installation keeps it, because the location depends on how n8n was installed and configured, and do not assume a default path. If the key is lost or differs after import, the workflows still arrive, but every stored credential becomes unreadable and must be re-entered by hand.

The same key must reach every process that touches credentials on the new platform. In queue mode, the main instance's key has to be shared with all worker and webhook processor nodes, so the key goes into the configuration of the main instance, each worker and each webhook processor before any of them start against the new PostgreSQL database. Load it from a secrets manager or your orchestrator's secret store rather than typing it into compose files or shell history, and restrict who can read it. Ask your platform team to confirm how the secret is injected into each container or pod, since a single process started with the wrong value is enough to break executions that use credentials.

Verify the key before you cut over traffic. Pick a credential that represents each important type, such as an HTTP header credential and a database or SaaS login, then run a test workflow on the new instance that uses it from the main instance and, if you run queue mode, from a worker. Confirm that each run succeeds and that the credential opens for editing in the UI. Keep this check in your cutover runbook so that a mismatch surfaces while the old instance is still available for rollback.

The sequence from inventory to decommissioning the old database

This sequence moves a working n8n instance from SQLite or MySQL onto PostgreSQL in stages, so each stage proves a piece of the migration before live traffic depends on it. The client ends with a verified PostgreSQL instance, a documented cutover and a dated decommissioning record for the old data.

  1. Inventory workflows, credentials, nodes and webhooks

    DeployOpen works with the client's n8n owners to list every active and inactive workflow, each credential and its owner, every custom node or npm package in use, the community nodes, external hooks, and every production webhook path and the systems that call it. The current encryption key and the location of the n8n data folder are recorded in the same inventory. The client receives a migration inventory document and a signed-off list of workflows in scope. The step is done when the owners confirm the list matches what runs in production.

  2. Provision PostgreSQL with backups and tested restore

    DeployOpen helps the client's platform team provision PostgreSQL in infrastructure they control, with a version chosen from the currently supported releases, storage sized for the existing data, and a backup method such as base backups with WAL archiving. A test restore runs into a separate database to prove the backup can be recovered before any n8n data is moved. The client receives the PostgreSQL build record, the backup configuration and a restore test log. The step closes when a restored copy starts and passes a basic query check.

  3. Rehearse export and import on a copy

    Using a copy of the current instance, the team runs n8n's export:entities command to write workflows, credentials and other entities out, then runs import:entities against the new PostgreSQL database. The encryption key is confirmed to be the same on the copy, so imported credentials decrypt. Row counts, workflow lists and a sample of credential tests are compared with the source. The client receives a rehearsal report listing every mismatch and its fix. The step is done when a full rehearsal produces no unexplained differences.

  4. Pilot a limited set of workflows

    A small group of low-risk workflows is moved to the PostgreSQL-backed instance and run alongside the old system for a set period agreed with the client. Owners check executions, error logs, credential behavior and any outbound calls. Problems found here are fixed in the rehearsal procedure, not patched by hand. The client receives a pilot results record with each workflow's status and the changes made. The step is done when the pilot owners sign off on each workflow.

  5. Run both instances in parallel without duplicate effects

    Both instances run during a parallel period, and the team confirms which side owns each trigger before anything is enabled. Schedule triggers, polling triggers and webhooks can each fire on both instances, so polling and schedule triggers on the old instance are deactivated for workflows already moved, and the trigger source is checked for duplicate messages, records or emails. Execution logs on both sides are compared for each moved workflow. The client receives a parallel run log and a trigger ownership table. The step is done when no duplicate side effect has appeared for the agreed period.

  6. Cut over DNS and webhook URLs

    The team lowers DNS time-to-live ahead of the change where the network allows it, points the n8n hostname to the new instance, and updates webhook URLs in external systems that call n8n directly. The old instance is kept reachable for a rollback path until the cutover checks pass. Test webhooks, a credential test and a scheduled workflow run are checked after the switch. The client receives a cutover record with the old and new addresses, the changed external endpoints and the rollback steps used. The step is done when production webhooks and scheduled runs succeed on the new instance.

  7. Decommission old data after the agreed retention period

    After the retention period the client agrees in writing, the SQLite file or MySQL schema is archived with a checksum, then removed from the live environment according to the client's data retention rules. Access to the archive is restricted and its location is recorded. The client receives a decommissioning record with the archive location, checksum, removal date and the approver. The step is done when the record is signed and the old database no longer serves n8n.

What drives the cost and duration of the migration

This table lists the factors that change how much work the move takes and who does it. Read each row as a question to answer about your own instance before requesting a quote, and note which costs happen once and which recur after cutover.

DriverWhy it mattersHow to reduce it
Number of workflows and credential dependenceEach workflow must be exported, imported and checked, and workflows that reference many credentials need more verification after the move.Inventory workflows and their credentials first, retire unused workflows, and group the rest by owner and business impact.
Count of credentialsCredentials are re-entered or verified against the new database, and the encryption key must match across every process that reads them.Confirm the encryption key is carried over intact, then test a sample of each credential type before cutover.
External systems that must accept new connectionsSource IP addresses, allow lists and service accounts at third parties may need updating before n8n can connect again.List every external system per workflow and ask owners to confirm allow list and account changes ahead of the window.
Custom nodes and external codeCommunity or private nodes, Code node modules and external hooks may depend on file paths or runtime versions that differ after the move.Record installed nodes and their versions, and test each custom component on the target before cutover.
Webhook count and external callersEvery webhook URL that other systems call must keep working, and callers that cannot be changed force a planned redirect or a dual running period.Identify callers that cannot be updated quickly and schedule their switch separately from internal workflows.
Queue mode or a parallel runQueue mode adds Redis, workers and a shared encryption key, and a parallel run doubles the systems to watch during testing.Decide on queue mode before the database move so the rehearsal covers the final topology, not a single process.
PostgreSQL platform readinessBackups, restore testing and high availability are needed before production data arrives, and PostgreSQL does not detect failures or fail over on its own.Confirm backup schedules, a tested restore procedure and the failover tooling your team will operate before the rehearsal.
Compliance evidence neededChange records, data flow notes and proof of testing may be required by your assessors, which adds documentation work to each phase.Ask your compliance team which evidence they need and collect it during the rehearsal, not after cutover.
Client staffing for approvals and testingBusiness owners must approve workflow tests and external changes, and delays in approvals often set the schedule more than technical work.Name approvers and testers in advance and book their time for the rehearsal and cutover windows.

What usually goes wrong during the move and how to prevent it

Most failed n8n moves to PostgreSQL trace back to a few handoff points: the encryption key, the cutover of triggers and webhooks, and the backup that is supposed to make the move reversible. Each card below names the failure, the prevention step, and the check that confirms the step worked.

Encryption key lost or mismatched

Credentials in n8n are stored encrypted, and the database alone cannot decrypt them. If the target instance starts with a different N8N_ENCRYPTION_KEY than the source, imported credentials appear in the UI but fail at execution time. Copy the key from the source configuration before the export starts and store it with your secrets tooling. Check it by opening one imported credential and running a test execution that calls its service.

Queue mode docs

Webhooks firing twice in parallel

During a parallel run, both the old and new instances may be registered to receive the same production webhook traffic, so one event triggers two workflow runs. This is especially risky for workflows that send messages, create records or charge customers. Keep only one instance active for production webhooks and use a staging hostname for the new instance while testing. Check it by sending a single test event and confirming that exactly one execution appears across both instances.

Schedules running on both instances

Scheduled triggers and polling workflows keep running on every instance that has them activated, and the source instance keeps its schedules until someone disables them. Customers can see duplicate emails, reports or API calls within minutes of cutover. Deactivate all scheduled and polling workflows on the source before starting the new instance, and record which ones were active. Check it by listing active workflows on both instances and confirming that each trigger runs on one side only.

Webhook URLs still pointing at the old host

External systems such as forms, payment providers and chat apps store the full webhook URL, including the host name. After the move, calls to the old address fail or reach a stopped instance unless the old host keeps forwarding them. Inventory every external caller and the WEBHOOK_URL setting before cutover, then change each caller or set up a redirect from the old host. Check it by sending a live test from each external system and confirming the execution appears on the new instance.

Incomplete backups that cannot be restored

A database dump without the .n8n folder, or a dump taken while the source was still writing, can produce an instance that starts but is missing binary files or recent executions. Teams often discover this only when they need to roll back. Take a full backup of the database and configuration immediately before the final export, and label it with the time taken. Check it by restoring the backup into a scratch environment and confirming that workflows, credentials and a sample execution are present.

PostgreSQL without a tested restore plan

A new PostgreSQL server with no backup schedule, no point-in-time recovery and no written restore procedure leaves the migrated n8n data exposed from the first day. Confirm the backup approach before cutover, because a database that only exists in one place is the single point of failure. Set up scheduled backups and archiving on PostgreSQL before go-live, and rehearse one full restore. Check it by timing the restore from the latest backup and confirming that n8n starts against the restored database.

Continuous archiving docs

Questions buyers ask before hiring help with the migration

What does a migration from SQLite or MySQL to PostgreSQL cost?

The cost follows from the written scope, which lists the work, the deliverables and the timeline before anything starts. The main cost components are planning, a rehearsal of the export and import on a copy of your instance, the cutover window, post-migration verification and documentation. Each component is work someone is paid for, so ask the quote to show who does each task. Most of the cost is one-time. Recurring costs appear only if you add an ongoing support or upgrade retainer. Costs rise with the number of workflows and credentials, the size of the execution history, custom nodes, the number of webhooks and whether you also plan queue mode. Ask for each cost line to name its scope item, so you can compare quotes from other providers on the same basis.

How long does it take to move n8n onto PostgreSQL?

The duration depends on scope, so the honest answer comes from an inventory of your instance. The factors that matter most are the number of workflows and credentials, the volume of stored execution data, binary data, custom node packages, the number of active webhooks, your tolerance for downtime and whether queue mode is planned in the same change. A rehearsal on a copy of your instance is the most reliable way to size the cutover, because it shows how long the export and import take on your data. Ask the provider to base the timeline on that rehearsal and to state which items are excluded. Timelines should be agreed in writing with the scope, not estimated from a generic template.

What does our team need to provide for the migration?

Your team provides the access and decisions that only your organization can give. Those include administrative access to the n8n host, the existing database and the new PostgreSQL server, along with a maintenance window that workflow owners accept. You also need named credential owners who can confirm or re-enter secrets, and approvers who sign off that migrated workflows behave as expected before and after cutover. Custody of the encryption key must be assigned to a specific person or team, and that team must be available during the window. Confirm these responsibilities in the written scope, including who holds the decision to roll back and how long the rollback option stays open.

Can our in-house team run this migration without a partner?

An in-house team can run the migration if it has hands-on experience with the n8n command-line tools, the way your n8n instance is hosted, PostgreSQL administration and a tested rollback path. The deciding factors are skills, available time for a full rehearsal and whether the people doing the work can also cover the cutover and the days after it. Your team should check the official n8n documentation for the export and import steps, then write a runbook that covers backup, export, import, key handling, webhook checks and rollback. A partner is most useful when the team lacks one of these skills or when the change must be completed inside a fixed window with written deliverables.

Do MySQL and MariaDB users have to migrate to PostgreSQL?

For MySQL and MariaDB users, moving to PostgreSQL is required as part of n8n 2.0 and later, so the question is about timing rather than whether the change is needed. Confirm the exact requirement and supported versions in the n8n release notes before you plan the window, because the requirement determines the order of your upgrades. If you plan to run queue mode, PostgreSQL is needed for that design as well, so the same migration can serve both goals. Build the plan so the database change, the n8n version change and the encryption key check are tested separately, which makes any failure easier to isolate.

What happens to our credentials if we lose the encryption key?

Credentials stored in n8n are encrypted with the instance encryption key, so without that key the stored credentials cannot be decrypted and must be created again by their owners. This is the most serious risk in the migration. Before any export, record the key in a secrets store that is separate from the database and the n8n host, and confirm that two authorized people can retrieve it. After the import, run a test that opens a sample of credentials and runs a workflow that uses them. In queue mode, the same key must also be available to every worker and webhook processor, so check those services as well. Ask the provider to show how key handling appears in the runbook and in the handover documents.

Does PostgreSQL need its own high availability setup after the move?

PostgreSQL supports hot standby servers and both synchronous and asynchronous replication, but it does not detect a failed primary or promote a standby by itself. Automatic failover therefore needs external tooling, plus a decision on how clients reconnect. Whether you need this depends on how much downtime your workflows can accept and whether queue mode will run on the same database. Multi-main n8n, which runs several main instances for high availability, is available only on Enterprise self-hosted deployments, so confirm the plan that applies to your license before you design around it. Your team should test failover and recovery on a non-production copy and record the results before relying on them.

What does DeployOpen deliver at the end of a migration?

DeployOpen delivers the outcomes listed in the written scope. Typically that includes an n8n instance running on PostgreSQL in your own infrastructure, the results of verification tests, a cutover and rollback runbook, documentation of the configuration and encryption key handling, and a handover to your operations team. DeployOpen plans, implements, backs up, documents and supports self-hosted open-source platforms inside your cloud accounts, data centers or air-gapped networks. It does not issue audit reports or certifications, so if your compliance team needs formal assurance, an independent auditor provides that. Ongoing support, upgrades and testing are available as retainers and are priced separately from the migration itself.

How DeployOpen works on this

DeployOpen plans and carries out the move from SQLite or MySQL to PostgreSQL inside your own infrastructure, with the export, import and encryption key steps written down before any change is made. The work is delivered under a written, fixed scope and can be followed by ongoing support as a retainer.

How we scope

  • Inventory the current n8n version, database type, encryption key location, custom nodes and webhook URLs before quoting.
  • Agree in writing whether the move includes queue mode with Redis, worker and webhook processors, or a single main instance.
  • Confirm the target PostgreSQL major version, hosting location, backup retention and the cutover window with your team.

How we build

  • Run export:entities on a copy of the live instance, then import:entities into a PostgreSQL staging database and compare results.
  • Carry the existing encryption key into the new environment unchanged so stored credentials remain readable after import.
  • Test workflow activation, credential access, scheduled triggers and webhook paths on staging before any production switch.

How we hand over

  • Deliver a runbook covering export, import, key handling, rollback steps and the order of cutover tasks.
  • Document the PostgreSQL connection settings, backup job and restore test, with a record of the checks performed.
  • Walk your operations and security staff through the environment so they can run and review it without DeployOpen present.

How we support

  • Offer ongoing support, n8n upgrades and PostgreSQL minor and major upgrade planning as a retainer after handover.
  • Retest workflows and credentials after each n8n or PostgreSQL upgrade, and update the runbook to match.
  • Confirm with your team which support tier, response expectations and maintenance windows apply before the engagement starts.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.