n8n Self-Hosted: Docker, Security and Hosting
Published Updated
To self-host n8n for production, run it with Docker Compose and PostgreSQL behind an HTTPS reverse proxy. Choose self-hosting when workflows need access to private systems or you need control over where execution data is stored. Assign someone to handle patches and recovery before the workflows go live.
Self-Hosted n8n or n8n Cloud: The Deciding Factors
Self-hosted n8n lets you choose where the database and backups live, reach systems on your private network and install custom nodes you’ve reviewed. For example, a stock reconciliation workflow can query a database that has no public endpoint. Your team takes on patching the host and containers, maintaining backups and monitoring failed workflows.
n8n Cloud is the better fit when your integrations work from a hosted service and you want n8n to manage the infrastructure. Your team still owns the workflows, their credentials and what data each workflow sends. If you’re weighing paid features against the cost of running the stack, see the n8n pricing comparison.
n8n’s Sustainable Use License allows an organisation to run Community edition for its own internal business workflows. Charging customers for access to a hosted copy or selling a white-labelled version requires a separate agreement with n8n. Paid self-hosted plans unlock features such as built-in single sign-on (SSO) and Git-based environments.
What You Need Before You Start
Use a Linux host or container platform with Docker Engine and Docker Compose v2. You need a domain under your control, a reverse proxy with a Transport Layer Security (TLS) certificate and a dedicated PostgreSQL database. Generate a stable secret for n8n’s credential encryption and arrange a Simple Mail Transfer Protocol (SMTP) relay for email invitations and password resets.
SQLite fits a single-instance trial because n8n can start with a local database file and no separate database service. Choose PostgreSQL from the start for production workflows that run around the clock or share load across workers. Switching the database setting on an existing instance starts n8n against a different database. Move the old data separately if you need to keep it.
Name an update owner who reads release notes and runs upgrades and restore tests. Give credential ownership to someone who can approve access to connected systems and rotate integration secrets when staff leave or a credential is exposed.
Running n8n With Docker Step by Step
This setup uses a reverse proxy on the Docker host and a PostgreSQL service reachable from the n8n container on a private network. The n8n port binds to the host’s loopback interface, which gives the proxy a local address to forward to.
- Prepare PostgreSQL. Give n8n its own database and a login with permission to create and update objects in the schema it uses. Start with a supported PostgreSQL version and allow connections from the n8n host. For a database on a separate host, configure TLS with certificate verification.
- Point your editor domain at the HTTPS proxy and forward requests to
127.0.0.1:5678. Install a certificate for the domain. PassX-Forwarded-For,X-Forwarded-HostandX-Forwarded-Protofrom the last proxy to n8n. For the example below, use a private editor hostname and a separate webhook hostname. Forward only the approved webhook paths on that second hostname. - Create the Compose file. Put this example in
compose.yml. It uses the documented n8n image and keeps application files in a named volume.
services:
n8n:
image: n8nio/n8n:${N8N_VERSION}
restart: unless-stopped
ports:
- "127.0.0.1:5678:5678"
env_file:
- n8n.env
volumes:
- n8n_data:/home/node/.n8n
volumes:
n8n_data:
- Set the instance variables. Put
N8N_VERSIONin Compose’s.envfile and set it to a specific stable release. Put the instance settings below inn8n.env. Replace the example hostnames and values in brackets before starting. Keep both files out of source control and restrict access to the secrets.
N8N_HOST=n8n.example.com
N8N_PROTOCOL=https
NODE_ENV=production
N8N_EDITOR_BASE_URL=https://n8n.example.com/
N8N_WEBHOOK_URL=https://hooks.example.com/
N8N_PROXY_HOPS=1
GENERIC_TIMEZONE=Australia/Sydney
TZ=Australia/Sydney
N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
N8N_ENCRYPTION_KEY=[stable encryption secret]
DB_TYPE=postgresdb
DB_POSTGRESDB_HOST=db.internal.example.com
DB_POSTGRESDB_PORT=5432
DB_POSTGRESDB_DATABASE=n8n
DB_POSTGRESDB_USER=n8n
DB_POSTGRESDB_PASSWORD=[database password]
DB_POSTGRESDB_SSL_ENABLED=true
Set N8N_PROXY_HOPS to the number of trusted proxies in the request path. The example assumes one. Use the timezone your team works in, such as Australia/Perth for Perth. For invitation emails, set N8N_EMAIL_MODE=smtp and configure N8N_SMTP_HOST, N8N_SMTP_PORT, N8N_SMTP_USER, N8N_SMTP_PASS and N8N_SMTP_SENDER for your relay.
-
Start the instance. From the directory containing
compose.yml, rundocker compose up -dand thendocker compose ps. After the container starts, open the editor over HTTPS and create the owner account. The browser must show a valid certificate and the editor must load. -
Verify the webhook. Create a temporary workflow with a GET Webhook node. Set it to respond using a Respond to Webhook node, then configure that node to return
{"status":"ok"}as JSON. Allow the test webhook path on the proxy for an authorised network only. Start listening for a test event, then request the test URL and expect HTTP 200 with the configured body.If a production webhook must be public, publish the test workflow and allow its production path. Confirm the same response from outside the private network. Remove the temporary routes and workflow after the check.
See n8n’s webhook URL reference. From n8n 2.35.0, N8N_WEBHOOK_URL replaces the deprecated WEBHOOK_URL. On releases that predate N8N_WEBHOOK_URL, use WEBHOOK_URL. For code execution, use n8n’s documented external task runner configuration where workflows need the Code node.
Add queue mode when concurrent executions regularly wait and the delays breach your workflow targets. The main n8n instance receives triggers and webhooks. Redis holds the jobs until separate n8n worker containers can run them. Give each worker access to the same PostgreSQL database and encryption secret.
Monitor queue wait time and database connections as you add workers. Community edition includes queue mode.
Securing a Self-Hosted n8n Instance
Put the editor behind a virtual private network (VPN) or an access proxy that requires SSO. On the public hostname, allow only production webhook paths that outside systems need. Require webhook authentication where the sender supports it. Keep the editor, its management endpoints and test webhooks off the public hostname.
n8n encrypts stored workflow credentials with N8N_ENCRYPTION_KEY. Back up that secret separately from the database and restrict who can recover it. A database restore needs the original secret to read the stored credentials. Use a dedicated credential for each integration so revoking one leaves unrelated workflows running.
Set N8N_COMMUNITY_PACKAGES_ENABLED=false unless someone owns package review and updates. If only approved packages are needed, manage installed versions through the environment and review the list before enabling it on an existing instance. That mode removes installed packages outside the list. Use NODES_EXCLUDE to block nodes such as Code or Execute Command when workflows don’t need them.
Give users the lowest role that allows their work. Community edition has instance Owner and Member roles. Business includes shared projects and built-in SSO. Enterprise adds custom roles, audit event streaming and external secret store integration. Ordinary application logs are available on Community edition.
An AI agent can mistake instructions in an email or web page for directions it should follow. If it can call a tool with write access, that prompt injection can turn a read-only task into an unapproved change. Limit which tools the agent can call, use scoped credentials and require a person to approve actions such as sending messages or updating a customer record.
Saved executions can hold email contents, customer details and node outputs. Save only the execution data you need to diagnose failures. Use EXECUTIONS_DATA_PRUNE=true with EXECUTIONS_DATA_MAX_AGE in hours and EXECUTIONS_DATA_PRUNE_MAX_COUNT to limit retained history. Waiting and annotated executions need separate attention because routine pruning skips them. Limit access to backups and give them their own retention period.
Updating and Backing Up n8n
Pin the n8n image to a release and assign a regular patch window. Read the release notes for breaking changes and database migrations, then try the new release on staging. Verify a scheduled workflow, an incoming webhook and a workflow that uses a credential. Back up the production database before deploying the new image.
Keep a PostgreSQL backup, a separate protected copy of the encryption secret and JSON workflow exports. Back up the n8n volume and any persistent binary files the installation relies on. Keep the Compose file and proxy configuration so you can recreate the service on another host. The database backup is the recovery copy for instance state. Workflow exports help you review or recover individual workflows.
For a restore drill, restore to an isolated database and start the matching n8n release with the original encryption secret. Before starting, block outbound access from the restored instance to production systems, including live email and API destinations. Keep incoming webhooks private and allow outbound access only to test destinations during the drill.
Open a saved workflow, verify it can read an encrypted credential using a safe test destination and run a test webhook. Record how long the restore takes. If an upgrade migrated the database, plan to restore the matching pre-upgrade database before running the old image.
On Business or Enterprise, use Git-based environments to review changes before promoting them. On Community edition, export workflow JSON to a restricted repository, review diffs and keep the last known-good version. Check exports for pinned data, literal secrets and other sensitive values before committing. Roll back the workflow by restoring the reviewed version and checking its environment-specific credentials before publishing it again.
Australian n8n Hosting Options
Where you host n8n determines who looks after the server and how it reaches internal systems. Check the location of PostgreSQL, backups and logs alongside the n8n host.
- Australian cloud regions. AWS and Google Cloud list regions in Sydney and Melbourne. Microsoft Azure lists Australia East in New South Wales and Australia Southeast in Victoria. Use the cloud you already operate if it has the database, backup and private networking services you need in your chosen region.
- Australian virtual server provider. A single virtual server can run a small instance. Check which party patches the operating system, where backups are copied and how you would recover after a host failure.
- On-premises servers. Run n8n on your own network when workflows need local systems or the hosting policy requires it. Your team also owns hardware recovery, access to work sites and a separate backup location.
An Australian host can keep the workflow database in Australia while a workflow sends a prompt to an overseas AI model endpoint. For AI data sovereignty, trace where the selected model processes requests and where the provider retains logs or copies. Choose in-region processing if those requests must stay in Australia, and check the provider’s support and subprocessors for other paths overseas.
Australian Privacy Principle 8 applies to certain disclosures by entities covered by the Privacy Act 1988. Before disclosing personal information to an overseas recipient, the entity must take reasonable steps to ensure the recipient follows the Australian Privacy Principles when handling that information. This duty excludes APP 1 and does not apply if an APP 8 exception applies. Whether a provider operates within your effective control affects whether the transfer is a disclosure. See the Office of the Australian Information Commissioner’s guidance on APP 8.
Who Should Run It: Your Team or a Partner
Run n8n yourselves if someone can investigate workflow failures during the hours the business depends on them. Set a regular patch window and a faster path for urgent fixes. Route alerts for failing workflows, unavailable webhooks and low disk space to a named responder. Give each credential a rotation owner and a way to verify that the workflow still works afterwards.
A partner running the instance needs a separate staging environment, agreed monitoring and a change process with a rollback decision. Put responsibility for backups, access reviews and incident response in the agreement. Ask for the result of a restore drill as part of handover.
Choose n8n Cloud if the service can reach your integrations within your network and privacy requirements and you lack someone to maintain the host. If your team only needs a few predictable app-to-app workflows, a managed automation platform with those connectors might be enough. See what n8n does if you’re still deciding how the workflows will run.
Fixing Common Self-Hosting Problems
Check the proxy, persistent volume and workflow settings before changing the deployment. Each of these symptoms has a separate recovery check.
| Symptom | Check and fix | What recovery looks like |
|---|---|---|
| Webhooks show the wrong host or an HTTP URL | Check the webhook base variable and proxy hop count. Verify that the proxy forwards the host and protocol. Recreate the n8n service with the corrected settings. Update any external registration that still uses the old URL. | The editor displays the correct HTTPS webhook URL and the sender receives the expected response. |
| Credentials fail after a container rebuild | Confirm the new container points at the original database and mounts the intended n8n volume. Recover the original encryption secret from its separate backup if it changed. | A workflow can read its saved credential and authenticate to a safe test destination. |
| Schedules fire at the wrong hour | Check the workflow timezone first because it overrides the instance default. Correct the workflow setting or GENERIC_TIMEZONE and check the expected local time, including daylight saving where applicable. |
The next scheduled run appears at the intended local hour. |
| Executions fill the database | Check which execution data is saved and review the age and count limits for pruning. Reduce unnecessary saves and shorten retention. Inspect waiting or annotated executions separately. | The count of retained finished executions falls after pruning, then database growth slows. Disk space may take longer to recover. |
If an issue persists, collect the failed execution ID, image tag and relevant logs with credentials and payload data removed. Raise it with the person who owns the instance, including the last time the expected result worked.
Related reading
What is n8n? Workflows, AI and Business Uses
Weighing n8n for your team? See how an n8n workflow connects your systems, where its AI agent nodes fit, and when outside help is worth it.
What Data Sovereignty Means for AI in Australia
Data sovereignty means your data is subject to laws where it’s stored or processed and laws that apply to the provider. In Australia, that also shapes sovereign cloud and sovereign AI choices.
What is Prompt Injection? Risks and Defences
Hidden instructions in an email, web page or file can turn an AI assistant against you. See how prompt injection works and which defences hold up.
Zapier Pricing Compared to n8n and Make (2026)
Zapier counts tasks, Make charges credits and n8n counts executions, so the cheapest tool depends on your workflows. Compare their pricing in like units.
embeddings
Embeddings is an Australian AI consultancy. We design, build and run AI systems inside the software, documents and data organisations already use, from offices in Perth and Melbourne.
About Embeddings