Administering n8n from the command line: when the server CLI is the right tool
An operator who runs n8n on their own servers and needs to export workflows, back up or restore an instance, or recover access after a lost password will reach for the n8n Server CLI. It runs on the same host as the instance, so it reads the local configuration and database connection directly rather than calling the running service over its API. The tasks it covers include exports and imports of workflows and credentials, credential and workflow backups, license-related commands and emergency password resets. Those are the moments when a team needs a command that works even when the web editor is unavailable.
This page explains when the Server CLI is the right tool, how it differs from the remote n8n CLI that works against a running instance, and what to check before running commands that touch encrypted credentials or user accounts. It also covers the risks that come with working on the host, such as who can reach the shell, where output files land and how exported data is handled. Command-level procedures for backup and restore belong to the backup topic, and migration between databases or servers belongs to the migration group, so this page focuses on the administrative decisions around them. Treat command-line administration as one part of day-two operations, alongside monitoring, logging, alerting and tested backups. Confirm the exact command names and flags for your installed version in the n8n documentation before you rely on them in a runbook, because the CLI changes between releases.
How the Server CLI differs from the remote n8n CLI
When n8n runs directly on a server under Node.js, the Server CLI is the tool you run from that same machine. It works with the files, database connection and settings the instance uses, so the operator needs a shell on the host and permission to read the data folder and the encryption key. Use it for tasks that act on the instance itself, such as full exports, imports, backups and emergency password resets.
- Access: A shell login on the host, ideally under the same service account that runs n8n so file ownership matches.
- What it reaches: The data folder, the configured database and the encryption key that the instance depends on.
- Typical tasks: Full exports and imports, credential and workflow backups, and emergency password resets.
- Timing: Confirm in the documentation whether a given command requires the instance to be stopped first.
Before you write a runbook, check the command list for your exact version in the n8n release notes, because options can change between releases.
In containers and Kubernetes, the Server CLI runs inside the container or pod that holds the n8n process. That means the operator enters the running container through the container runtime or kubectl exec, and the data location is whatever volume the pod mounts. Files written to a container's writable layer or an ephemeral path are lost when the pod is replaced, so the export or backup destination must sit on a mounted volume or be copied out.
- Access: Exec rights on the workload, which your cluster role-based access control should restrict to named administrators.
- Storage: Confirm that the data folder and any export directory are on persistent volumes.
- Secrets: The encryption key comes from the same Kubernetes secret or environment setting the pods use. A mismatched key makes stored credentials unreadable.
- Versions: Run the CLI from the same image tag as the running instance so command behavior matches.
The remote CLI is usually run from a jump host or admin workstation that can reach the instance service, so keep the two paths documented separately in your deployment runbook.
In queue mode, the main instance handles triggers and webhooks and passes executions through Redis to workers, which read and write workflow data in PostgreSQL. Workers and webhook processors must share the main instance's encryption key so they can use stored credentials. Administration therefore depends on which process you reach, and running a command on a worker does not automatically give you the same view as running it on the main instance.
- Main instance: The usual place for Server CLI tasks that need the encryption key and the configured database.
- Workers: Hold the shared key, but confirm with the documentation whether any administration command should run there at all.
- Shared database: Changes made through either path are stored in PostgreSQL, so verify results on the main instance afterward.
- Multi-main setups: Restricted to Enterprise self-hosted deployments, so confirm which instances your plan lets you use for administration.
Before running an export or restore in a queue deployment, check which process holds the state you expect, and confirm the behavior for your version against the queue mode documentation.
On locked-down or air-gapped networks, the two CLIs differ mainly in the access path they need. The remote CLI requires a reachable network route to the running instance and an account with permissions for the task. The Server CLI requires a login to the host itself, which is a stronger form of access. Choose the path that matches your change-control process, and limit who can use each one.
- Remote path: Needs a reachable endpoint from the admin workstation and an account whose permissions cover the command. Confirm the permission requirements for each task.
- Host path: Needs console, jump host or SSH access to the server. Keep the list of holders short and reviewed.
- Records: Log which path, which operator and which instance was used for each administrative task.
- Licensing: Files with
.eein their name require a valid Enterprise License, so confirm your license status before running license-related tasks.
Before you depend on either path, confirm command availability and required permissions for your version with your own environment tests, and record the result in your change records.
Which CLI task fits which administration need
This table matches each common administration task to the n8n CLI mode that usually fits it and the trade-off of using that mode. Read each row as a starting point, then confirm exact command names and flags against the documentation for your n8n version before you run anything in production.
| Task | Likely CLI mode | Trade-off to plan for |
|---|---|---|
| Workflow export as a secondary copy | Server CLI, run on the host or container with access to the instance | Captures workflow definitions but not the full set of database, binary and key material, so it complements rather than replaces a full backup |
| Workflow or credential import into a rebuilt instance | Server CLI, against the target instance and its encryption key | Credentials only decrypt if the target uses the same encryption key, so confirm key handling before you import |
| Credential backup | Server CLI, with an exported copy stored under your own access controls | Exported credentials are sensitive, so the copy needs the same protection as the encryption key and database |
| License activation or renewal tasks | Server CLI on the instance that holds the license | Needs a valid license for licensed features, and the commands may differ by edition, so confirm applicability first |
| Emergency owner password reset | Server CLI with direct access to the instance host or container | Requires shell access to the server, so it depends on your host access controls and should be logged and reviewed afterward |
| Routine remote administration of a running instance | Remote n8n CLI, which talks to the instance through its API | Depends on the instance being reachable and on API access being configured, and it does not replace server-side recovery tasks |
| Scripted maintenance in CI or on a schedule | Server CLI in a job with restricted credentials | Scripts can run destructive commands, so pin the version, test in a non-production instance and confirm each flag first |
Running a safe CLI backup and restore sequence
This sequence produces a verified CLI export of workflows and credentials, stored with the encryption key that can decrypt it, and proves that the export imports on a separate instance. It gives you a secondary copy that complements a full backup of the database, the data folder and binary storage.
Confirm the version and encryption key location
The operator who runs the instance records the installed n8n version and where the encryption key is kept, either in the N8N_ENCRYPTION_KEY environment variable or in the config file inside the .n8n folder, depending on how the instance was installed. Check the version against the release notes for the instance you are about to export, because the CLI should match the running version. The step is done when you can name the version and show the key location, and when you have confirmed that the key is backed up somewhere separate from the server.
Run the server CLI where the instance runs
Open a shell in the same container or on the same host as the running n8n main instance, so the Server CLI reads the same database connection and encryption key. Run the CLI from the same n8n version as the instance. Confirm the environment first with a read-only command, such as listing workflows, to check that the CLI reaches the expected database. The step is done when the read-only command returns your workflows and no connection or key error appears. Check the exact subcommands and flags against the help output for your version, because they can change between releases.
Export workflows and credentials as a copy
Run the export commands for workflows and credentials to write them to files in a directory you control. Keep this export as a secondary copy alongside your primary backup of the database and data folder, not as a replacement for it. Use the export commands documented for your version and write output to a path outside the n8n data folder so the files are not overwritten. The step is done when the command exits without errors and the output files exist with non-zero sizes and the expected modification time.
Verify the exported files are complete
Open the workflow export and count the workflows, then compare the count with the number shown in the editor or the database. Confirm that the credential export contains the entries you expect and that the file is well-formed JSON. Check the file checksum and store it with the export so later copies can be compared. The step is done when the counts match, the files parse, and the checksum is recorded. A mismatch means the export is incomplete and should be repeated before you rely on it.
Store the encryption key with the credential export
Credentials in the export are encrypted with the instance's encryption key, so the key must be kept with the credential export and in the same protected location. A credential export without the matching key cannot be used to recover secrets. Restrict who can read the storage location, and record which key version belongs to which export. The step is done when the key and the credential export are stored together in an access-controlled location and the record names the n8n version, the export date and the key location.
Test an import on a separate instance
Import the export into a separate n8n instance on the same version, using a test database and the same encryption key, so the credentials can decrypt. Do not import into the production instance during the test. Open a sample of the imported workflows and confirm that their nodes, settings and credential references load without errors. Run one non-production execution of a workflow that uses a credential. The step is done when the imported workflows load, the credentials resolve, and the test execution completes. Document any failures before you treat the export as a usable restore path.
Why exported credentials are unusable without the encryption key
An export of credentials is only useful together with the encryption key that protects them. n8n stores credentials in its database in encrypted form, and the key that decrypts them lives in the instance configuration, not in the export. A credentials export from the Server CLI therefore gives you records that cannot be read on another instance unless that instance holds the same key. Before you rely on a credentials export as a backup, restore it into a test environment with the matching key and confirm that the workflows authenticate. Do not assume a successful import means the credentials work.
The key is not a detail you can regenerate. Queue mode makes this concrete: the main instance's encryption key must be shared with every worker and webhook processor so they can read credentials from the database. Any new worker, replacement container or restored instance that receives a different key will fail to run workflows that use credentials, even though the database and export look intact. Record which key belongs to which instance, store it in a secrets manager or sealed vault, and include it in your restore runbook alongside the database dump. Confirm the exact configuration setting for your version in n8n's documentation before writing the runbook.
Storing an export and its key file together defeats the protection. Anyone who can read both gets every credential in cleartext, including API tokens and database passwords that the workflows use. Separate them by location and by access: the export should sit in a backup store with restricted read access, and the key should sit in a different system with its own approval path, audit logging and rotation record. Limit access to named administrators, review those lists when people change roles, and treat any copy of the key on a laptop or in a ticket as a compromise to be handled through your incident process. Our n8n queue mode documentation is the reference for how workers depend on the shared key.
Security and operational risks of command-line administration
The Server CLI runs with the same authority as the host it sits on, so anyone who can reach that host can often reach the data behind it. The risks below connect through one question: who can run administrative commands, what do those commands expose or change, and can you prove afterward what happened.
Host access implies data access
Anyone with a shell on the n8n host or container can read the instance's configuration and database connection, and can run administrative commands without going through the web interface or its role checks. Treat shell access to the n8n host as equivalent to administrator access to the instance. Confirm who holds root or container exec rights, restrict them to named operators, and check that the instance's database credentials are not readable by general host users.
Exports carry sensitive material
A workflow or credential export is a copy of your automation logic, endpoints and, depending on the export options, secrets or encrypted credential data. Copies left in temporary folders, shared drives or CI logs become a second data store with weaker controls than the production database. Before any export, confirm with the n8n documentation what each export option includes, write files only to a restricted location, and set a deletion step once the transfer is complete.
Password reset as an emergency lever
A password reset from the command line restores access when every administrator is locked out, but it also lets an operator take over any owner account without the user's knowledge. Limit the procedure to a documented break-glass runbook with two people present, record the reason and the account changed, and rotate the password again after the incident. Review each reset against the ticket that justified it.
License tasks tied to license terms
n8n is licensed under the Sustainable Use License, and files with .ee in their name or directory need a valid n8n Enterprise License. License-related CLI tasks therefore change what your organization is entitled to run, not only how the instance behaves. Before using license commands, confirm your edition and terms against the license file, keep the license key in your secrets store, and record who approved each change.
Version mismatch between CLI and instance
n8n uses semantic versioning and ships minor releases roughly weekly, so the CLI binary you run from a shell can drift from the version serving production. A mismatched CLI can read or write data in a format the running instance does not expect. Run administrative commands from the same image tag as the running instance, pin that tag in your deployment files, and check the version before each maintenance window.
n8n release notesLogging of administrative actions
Shell commands usually leave no record inside n8n itself, so an export, import or reset can happen without an entry in the workflow history or user activity views. Capture shell sessions and command history for the host, forward them to a central log store, and tie each entry to a named operator. Ask your team to confirm which administrative actions produce any n8n-side record in your version, and cover the gaps with host-level logging.
Questions buyers ask about n8n CLI administration
Can our internal team run n8n CLI administration without outside help?
Yes, a team with Linux, container and database skills can run the Server CLI for exports, imports and backups, provided someone owns the work and the runbook. The harder parts are not the commands themselves but knowing which data they cover, where the N8N_ENCRYPTION_KEY is stored, and how a restore is verified. Ask whether your engineers have restored an n8n instance into a separate environment at least once. If not, the first restore test is usually where gaps appear, so plan for a supervised first run even if the team later works alone. Outside help is most useful for writing the runbook and testing it, not for routine exports.
What drives the effort of a backup and restore runbook?
The effort depends on how many components the instance uses and how much of each must be captured together. A runbook for a simple single-instance setup covers the .n8n folder, the encryption key, a PostgreSQL dump and any binary data store. Effort grows with queue mode (workers and webhook processors that must share the key), custom nodes, external file storage, multiple environments and compliance evidence requirements. Ask for the components in scope, the restore target, the number of environments tested, and whether the runbook includes a documented verification step. Cost is one-time for design and testing, then recurs as your instance changes and the runbook needs updating after upgrades.
What access does CLI administration work need from our environment?
The work needs shell access to the host or container where n8n runs, read access to the database backups or a dedicated database account with dump rights, and access to the storage holding binary data. For restore tests, it also needs a separate non-production environment with its own database and network isolation. Access should be scoped to named accounts, with the encryption key handled through your secrets process rather than copied into tickets or chat. Confirm with your security team how privileged sessions are logged and who can approve access to exported credentials, since exports contain sensitive material.
How long does a restore test take as data volume grows?
Restore time is driven mainly by database size, the volume of binary data, and how much of that data must be reloaded and checked before you call the test complete. Small instances with modest execution history restore quickly, while large execution histories and file-heavy workflows take longer to load and verify. n8n does not publish a restore duration, so measure it yourself: run a timed restore of a recent backup into a clean environment, record each step, and repeat it with a copy of production-sized data. Ask any partner to report measured times from your own data rather than a generic estimate.
Is the n8n Server CLI covered by the Community edition?
The Server CLI is part of the self-hosted software, so it is available to teams running the free Community edition for the commands that operate on the instance itself. The license, however, governs what you may do with the software. n8n is licensed under the Sustainable Use License, which permits use only for your own internal business purposes or non-commercial use, and files with .ee in their name or directory require a valid Enterprise License. Confirm with n8n which commands touch licensed features before relying on them in production, and check the license terms for your intended use.
When is a partner worth the cost for n8n CLI administration?
A partner is worth considering when the instance is business-critical, the team lacks time to build and test a runbook, or compliance evidence for backups and change control is required. Cost is driven by the written scope: the number of environments, how many components are covered, whether restore tests are repeated, and whether knowledge transfer is included. Ask for a fixed-scope quote with deliverables and timelines in writing, what the runbook will contain, how restore tests are measured, and what is handed over at the end. DeployOpen plans, documents and tests these runbooks inside your own infrastructure, and most engagements are fixed-scope.
What is the difference between the Server CLI and the remote n8n CLI?
The Server CLI runs on the host where n8n is installed and works directly with the instance's database and files, which is why it suits exports, imports, credential and workflow backups and emergency password resets. The remote CLI connects to a running instance through its API and is aimed at operating it from another machine. Confirm the exact commands and flags for your version in the n8n documentation before scripting them, because behavior can change between releases.
The Server CLI works on the database directly, while the remote CLI goes through the running instance
The operator on the host runs the Server CLI against the instance database, and the encryption key on that host is needed to read stored credentials. The remote CLI takes a different path, connecting through the running instance. Check that the Server CLI runs on the same host and with the same encryption key as the instance it changes, and that any export leaves the host only through the external backup store, where access should be controlled separately.
Server CLI reaches the database on the host, remote CLI reaches the running instance.
What DeployOpen delivers for CLI administration work
The core deliverable for CLI administration work is a written runbook that tells your operators exactly how to export workflows and credentials, import them into a target instance, and reset a user password when no one can sign in. DeployOpen writes the runbook against your own deployment: the install method, the database, where the encryption key is stored, and which account holds administrative rights. A generic command reference does not cover those specifics. Before work starts, confirm with your team which environments the runbook must cover (production, staging, and any air-gapped copy) and who will own it after handover.
Export and import procedures are tested before they are handed over. DeployOpen runs each documented command against a non-production copy of your instance, records the exact output, and checks that a restored workflow and its credentials decrypt correctly with the encryption key in use. The test run also shows where a procedure depends on a particular n8n version, which matters because the Server CLI and the remote CLI are separate tools with different command sets. Ask for the test results in writing, including any command that behaved differently from the documentation on your version. The runbook should state which n8n version was tested and which steps must be repeated after an upgrade.
The emergency password reset process is documented as its own procedure, with access controls around it. DeployOpen describes who may trigger a reset, how the request is approved and logged, where the command runs (for example, on the host itself with restricted shell access), and how the new credential is delivered and then changed by the user. The process also covers how to confirm that the reset was the only change made. Agree these access rules with your security team before the first test, since the reset path is one of the most sensitive routes into the instance. A handover session walks your operators through the runbook, the test evidence and the escalation contacts, and the written handover document is delivered to your team as the record of what was built.
How DeployOpen scopes and supports n8n administration
DeployOpen treats n8n command-line administration as part of the running platform, not a one-off task. We scope which CLI jobs your team needs, build the runbooks and access controls around them inside your infrastructure, and hand over documented procedures your operators can repeat.
How we scope
- Engagements are fixed-scope, with CLI tasks, owners and deliverables agreed in writing before work starts.
- We confirm which tasks run on the server CLI and which need the remote CLI, based on your deployment.
- We confirm your n8n edition and license status, since some license tasks depend on the installed Enterprise License.
How we build
- We write runbooks for exports, imports, credential and workflow backups, and emergency password resets.
- We restrict who can run server CLI commands on hosts, and log those actions in your existing audit tooling.
- We test each runbook against a non-production copy of your instance, including restore and encryption key checks.
How we hand over
- You receive documented procedures, scheduled job definitions and a restore checklist written for your operators.
- We walk your team through each runbook and record the verification steps they should repeat after a change.
- Configuration and encryption key handling are documented so the backup and restore process stays with your team.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers after handover.
- Retainers can cover CLI runbook updates when n8n releases change command behavior or license handling.
- We can retest backup and restore procedures on a schedule you agree, and report the findings in writing.

