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 forn8n
pointing to1.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:
- Check the latest version
- Update your Dockerfile
- Change the version, e.g.
FROM n8nio/n8n:1.46.0
- Change the version, e.g.
- Redeploy
- Run:
fly deploy
- Fly will rebuild and restart the app using the new version.
- Run:
- 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
andregion
.