3 min read

Deploy n8n to Fly.io

Self-hosted n8n with Docker, secure secrets, automatic HTTPS, and zero VPS maintenance
Deploy n8n to Fly.io

🌟 Why Fly.io?

Fly.io is a great platform for hosting self-managed apps like n8n. Here’s why:

  • 🧠 No VPS maintenance – No need to patch, update, or secure an entire virtual machine.
  • 🌍 Global regions – Run your app close to your users with worldwide data centers.
  • πŸ” Automatic HTTPS – Fly provides TLS via Let's Encrypt with no config required.
  • πŸ’Ύ Persistent volumes – Store workflows and credentials securely and reliably.
  • ⚑️ Fast and efficient – Fly’s β€œMachines” model allows quick restarts and minimal idle costs.

It’s like the developer experience of Heroku, but with the power of Docker and infrastructure-as-code.


🧰 Prerequisites

  • βœ… A Fly.io account
  • βœ… flyctl installed
  • βœ… Docker installed
  • 🌐 (Optional) A custom domain for your n8n instance

πŸ—‚ Project Structure

Your folder should contain:

n8n-fly/
β”œβ”€β”€ Dockerfile  
β”œβ”€β”€ fly.toml  
└── config.json (optional)

🐳 Dockerfile

Use the official n8n Docker image, pinned to a stable version:

FROM n8nio/n8n:1.44.0

COPY config.json /home/node/.n8n/config.json

Filename: Dockerfile

πŸ“Œ Why pin the version?
To prevent unexpected changes when latest updates.


βš™οΈ fly.toml Configuration

Example configuration:

app = "n8n"
primary_region = "fra"

[build]
  dockerfile = "Dockerfile"

[env]
  PORT = "5678"
  N8N_RUNNERS_ENABLED = true
  N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS = true
  N8N_HOST = "n8n.xqus.com"
  N8N_PORT = 5678
  N8N_PROTOCOL = "https"
  N8N_EDITOR_BASE_URL = "https://n8n.xqus.com"

[http_service]
  internal_port = 5678
  force_https = true
  auto_stop_machines = "stop"
  auto_start_machines = true
  min_machines_running = 1
  processes = ["app"]

[mounts]
  source = "n8n_data"
  destination = "/home/node/.n8n"

[[vm]]
  memory = "1gb"
  cpu_kind = "shared"
  cpus = 1

fly.toml

🌍 Region Tip
The primary_region should be closest to your users (e.g. fra for Frankfurt, ord for Chicago).
View the full list of regions here: https://fly.io/docs/reference/regions/


πŸ” Set Secrets with fly secrets

No need for a .env file β€” just store secrets securely:

fly secrets set \
  N8N_ENCRYPTION_KEY=e9Fzr!nT&0tjBYDn6gv \
  N8N_BASIC_AUTH_ACTIVE=true \
  N8N_BASIC_AUTH_USER=yourusername \
  N8N_BASIC_AUTH_PASSWORD=yourpassword

πŸ”‘ Never commit secrets to your codebase!


πŸ’Ύ Create Persistent Volume

Create a volume to store credentials and workflow data:

fly volumes create n8n_data --size 1 --region fra

πŸ“Œ The region must match your app’s primary_region.


πŸš€ Deploy Your App

Use either of these:

πŸ”§ Run the guided setup:

fly launch

⬆️ Or deploy manually:

fly deploy


🌐 Custom Domain + HTTPS

If you want to use your own domain (e.g. n8n.yourdomain.com) instead of the default your-app.fly.dev, follow these steps:

1. πŸ”§ Add your domain in Fly.io

Tell Fly which domain you’re using:

fly certs add n8n.yourdomain.com
This sets up automatic TLS (HTTPS) using Let's Encrypt.

2. 🌐 Update your DNS

Create a DNS A record pointing to your Fly app’s IPv4 address:

  • Run fly ips list to get your app’s public IP.
  • In your DNS provider, add:

Type: A
Host: n8n
Value: [YOUR_FLY_PUBLIC_IPV4]
TTL: Automatic or 300

Example: If you’re using Cloudflare, add a DNS A record for n8n pointing to 1.2.3.4 (your Fly IP).

Optional: If your DNS provider supports CNAME flattening or ANAME/ALIAS records, you can also point the root domain (@) to your Fly app.

3. βœ… Done!

Once DNS is propagated (usually within minutes), Fly.io will automatically issue and renew an HTTPS certificate for your domain.

You can verify with:

fly certs show n8n.yourdomain.com


βœ… You're Live!

Your n8n instance is now deployed with:

  • HTTPS
  • Docker
  • Persistent storage
  • Fly.io’s global platform
  • Zero VPS overhead

πŸŽ‰ Open your custom domain or https://n8n.fly.dev to start using n8n.


πŸ”„ How to Update n8n to the Latest Version

Want the newest features or security patches? Here’s how to update:

  1. Check the latest version
  2. Update your Dockerfile
    • Change the version, e.g.
      FROM n8nio/n8n:1.46.0
  3. Redeploy
    • Run: fly deploy
    • Fly will rebuild and restart the app using the new version.
  4. Verify
    • Open your instance β†’ Settings β†’ About β†’ Confirm the version number

That’s it! All workflows and credentials will stay intact.


πŸ“Œ Final Reminders

  • πŸ” Back up your N8N_ENCRYPTION_KEY β€” losing it means losing access to stored credentials.
  • πŸ§ͺ Test everything after deploying updates or new secrets.
  • πŸ“¦ You can clone this setup for multiple environments by changing app and region.