How to Self-Host Your n8n Easily with Fly.io
The Benefits of Self-Hosting n8n
Self-hosting n8n offers significant cost advantages. In today's tech landscape, hosting on your own server is both easy and economical. By self-hosting, you eliminate subscription fees associated with managed services, allowing you to deploy powerful automation workflows at a fraction of the cost.
This approach provides financial flexibility without compromising on performance or capabilities.
Why Fly.io is a Perfect Fit for Deploying n8n
Fly.io excels in providing a containerized infrastructure that simplifies the deployment and maintenance of applications like n8n. Its support for Docker images ensures that updates are seamless, making it effortless to keep your n8n instance current.
Fly.io's edge computing platform brings your application closer to users globally, reducing latency and improving responsiveness. With low prices and extensive documentation, Fly.io empowers developers to deploy, scale, and manage applications with ease.
You can check their complete documentation here.
Preparing to Deploy n8n on Fly.io
Setting Up the Basics: What You Need to Start
Before starting, ensure you have:
A Fly.io account
The flyctl command-line tool installed
Basic command-line proficiency
(Optional) Docker installed for local testing
Fly.io Account Creation and Initial Setup
Visit Fly.io and sign up for a new account. After verifying your email, log in to access the dashboard where you can manage applications, monitor logs, and configure settings.
Installing Flyctl: Your Command-Line Companion
Install flyctl using the appropriate command for your operating system:
macOS:
Linux:
Windows (using Chocolatey):
Authenticate flyctl with your Fly.io account:
Step-by-Step Guide: Deploying n8n on Fly.io
Configuring Your fly.toml
with n8n Docker Image.
Initialize a new Fly.io application:
Respond to the prompts:
App Name: Enter a unique name, e.g.,
n8n-mycompany
.Select Organization: Choose your personal organization.
Select Region: Pick a region closest to your user base.
Would you like to deploy now?: Select No.
Replace the content of the generated fly.toml
file with the following configuration:
Understanding the fly.toml Configuration
app: Specifies the application name on Fly.io, set to
"n8n-mycompany"
.kill_signal and kill_timeout: Define the termination signal and timeout period, using
"SIGINT"
and5
seconds, respectively.processes: An array to define custom processes; left empty for default behavior.
[build]: Indicates the Docker image to deploy, here
"n8nio/n8n:latest"
ensures the latest n8n version.[env]: Environment variables for n8n:
N8N_USER_FOLDER
: Sets the user folder to"/home/node"
for data persistence.N8N_HOST
: The hostname for your n8n instance, matching your Fly.io app name.N8N_EDITOR_BASE_URL
: The base URL for accessing the n8n editor interface.WEBHOOK_URL
: The public URL where n8n listens for incoming webhooks.EXECUTIONS_DATA_PRUNE
: Enables automatic pruning of execution data.EXECUTIONS_DATA_MAX_AGE
: Sets the maximum age (in minutes) for execution data retention.
[experimental]:
auto_rollback
: Automatically reverts to the previous deployment if the current one fails.
[services]]: Configures network services for the app.
internal_port
: The internal port n8n listens on, set to5678
.processes
: Specifies which processes to route, using["app"]
.protocol
: Communication protocol, set to"tcp"
.
[services.concurrency]:
type
: Manages concurrency based on"connections"
.hard_limit
andsoft_limit
: Define thresholds for scaling.
[[services.ports]]:
port
: Externally exposed port443
for HTTPS traffic.handlers
: Include"tls"
and"http"
to handle secure connections.tls_options
: Specifies supported TLS versions for encryption.
[[services.tcp_checks]]:
Configures health checks to monitor service availability.
[mounts]:
source
: Names the volume for persistent storage,"n8n_mycompany_data"
.destination
: Mount point inside the container,"/home/node"
.
Creating Your First Fly.io App for n8n
Deploy the application:
Allocate a public IPv4 address:
Your n8n instance is now accessible at https://n8n-mycompany.fly.dev
.
Upgrading Your Fly.io Machine via Command Line
As your application's demands grow, scale your resources accordingly:
This command upgrades your virtual machine to a plan that offers enhanced CPU and memory resources.
Conclusion
Deploying n8n on Fly.io is a streamlined process that combines ease of use with cost efficiency. (You should spend around US$5 per month)
The containerized environment simplifies installation and configuration, allowing you to deploy and update your n8n application seamlessly.
With Fly.io's edge computing capabilities and competitive pricing, you can launch and monitor your n8n instance in just a few minutes, all while keeping operational costs to a minimum.
Try for free
7-day free trial