Run Alby Hub with Fly.io

Run your own Alby Hub on Fly.io using the official Alby Hub Docker image and a simple fly.toml configuration.

Prerequisites

Fly.io is a good option if you want to self-host Alby Hub in the cloud without managing a full server manually. This guide walks you through creating a Fly.io app, configuring persistent storage, deploying Alby Hub, opening it in your browser and updating it later.

Before you begin, make sure you have:

Fly.io may require billing details before you can deploy an app. Depending on Fly.io's current pricing and your app usage, charges may apply. See their pricing page for more details.

Let your agent guide you

Ask your AI agent to help you install Alby Hub on Fly.io guide you through the installation with Alby Hub Skill.

Let your agent guide you

Ask your AI agent to help you install Alby Hub on Fly.io guide you through the installation with Alby Hub Skill.

Deploy Alby Hub on Fly.io

01

Sign into your Fly.io via the CLI

Run the following command:

When your browser opens to the Fly.io sign-in screen, enter your user name and password to sign in.
After the login is complete, return to your terminal.

02

Create a folder for your Alby Hub deployment

Create a folder for your Alby Hub

Create a new folder on your computer for this Fly.io deployment. For example:

mkdir alby-hub-fly
cd

mkdir alby-hub-fly
cd

This folder will store your fly.toml configuration file.

03

Create the fly.toml configuration file

Inside the folder, create a file named fly.toml

Paste the following configuration into the file:

# fly.toml app configuration file generated for Alby Hub

app = 'Alby-Hub'
primary_region = 'lax'
swap_size_mb = 2048
# Add a kill timeout longer than LDK node shutdown timeout to ensure Alby Hub gracefully shuts down
kill_timeout = 300

[build]
  image = 'ghcr.io/getalby/hub:latest'

[env]
  DATABASE_URI = '/data/nwc.db'
  LDK_LOG_LEVEL = '3'
  LOG_LEVEL = '4'
  WORK_DIR = '/data'

[[mounts]]
  source = 'nwc_data'
  destination = '/data'
  initial_size = '1'
  auto_extend_size_threshold = 80
  auto_extend_size_increment = "1GB"
  auto_extend_size_limit = "5GB"

[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = false
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']

[[vm]]
  cpu_kind = 'shared'
  cpus = 1
  memory = '512mb'
# fly.toml app configuration file generated for Alby Hub

app = 'Alby-Hub'
primary_region = 'lax'
swap_size_mb = 2048
# Add a kill timeout longer than LDK node shutdown timeout to ensure Alby Hub gracefully shuts down
kill_timeout = 300

[build]
  image = 'ghcr.io/getalby/hub:latest'

[env]
  DATABASE_URI = '/data/nwc.db'
  LDK_LOG_LEVEL = '3'
  LOG_LEVEL = '4'
  WORK_DIR = '/data'

[[mounts]]
  source = 'nwc_data'
  destination = '/data'
  initial_size = '1'
  auto_extend_size_threshold = 80
  auto_extend_size_increment = "1GB"
  auto_extend_size_limit = "5GB"

[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = false
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']

[[vm]]
  cpu_kind = 'shared'
  cpus = 1
  memory = '512mb'

Change the name 'Alby-Hub' to a custom name. For example: 'My-AlbyHub'

You can also change the primary_region value if you want to deploy Alby Hub in a different Fly.io region. Choose a region close to where you will usually access your Hub. Check Fly regions for more information.

04

Create the Fly.io app

Make sure you are still inside the folder where your fly.toml file is saved.

fly launch --no-deploy
fly launch --no-deploy

During setup, the Fly.io CLI may ask a few questions:

Would you like to copy its configuration to the new app? Yes
Do you want to tweak these settings before proceeding? No
Create .dockerignore from 1

Would you like to copy its configuration to the new app? Yes
Do you want to tweak these settings before proceeding? No
Create .dockerignore from 1

Fly.io will create your Alby Hub app and its settings from your fly.toml file, but it wonโ€™t deploy it yet. This gives you a chance to protect the initial setup first.

Fly.io will now create and deploy your Alby Hub app using the Docker image and settings from your fly.toml file.

If you see a message similar to this, your deployment has started successfully:

05

Protect initial setup

Before the first deployment, set a random SETUP_CODE. This requires Alby Hub v1.24.7 or later and prevents anyone without the code from completing initial setup or importing a migration file before you do. Generate a random code:

Make sure you are still inside the folder where your fly.toml file is saved.

openssl rand -hex 16
openssl rand -hex 16

Keep the output private. Save it as a Fly.io secret, replacing YOUR_RANDOM_CODE with the generated value:

During setup, the Fly.io CLI may ask a few questions:

fly secrets set SETUP_CODE=YOUR_RANDOM_CODE --stage
fly secrets set SETUP_CODE=YOUR_RANDOM_CODE --stage

Fly.io stores the secret securely and passes it to Alby Hub as an environment variable when the app is deployed. Donโ€™t add it to fly.toml.

Fly.io will now create and deploy your Alby Hub app using the Docker image and settings from your fly.toml file.

If you see a message similar to this, your deployment has started successfully:

The setup code only protects initial onboarding, including restoring into a new Hub. Itโ€™s not your unlock password or recovery phrase, and itโ€™s no longer needed once setup is complete.

06

Deploy Alby Hub

Deploy Alby Hub from the same folder:

Make sure you are still inside the folder where your fly.toml file is saved.

If you see a message similar to this, your deployment has started successfully:

During setup, the Fly.io CLI may ask a few questions:

07

Open your Alby Hub

After deployment, open your Fly.io dashboard and go to the Apps section.

Click on the app to access it on your browser.

08

Set up Alby Hub

Enter the setup code you saved as a Fly.io secret when prompted, then click Get Started and follow the setup flow in Alby Hub.

Alternatively, open your Hub URL with ?c=YOUR_RANDOM_CODE appended. Keep the code and any link containing it private.

During setup, make sure you save any important recovery or backup information shown by Alby Hub. Your Hub uses persistent storage on Fly.io, but you should still keep your own backups so you can recover or migrate your Hub later.

Click Get Started and follow the setup flow in Alby Hub.

During setup, make sure you save any important recovery or backup information shown by Alby Hub. Your Hub uses persistent storage on Fly.io, but you should still keep your own backups so you can recover or migrate your Hub later.

How to update Alby Hub on Fly.io

In Powershell on Windows, navigate to the directory of your fly.toml with cd [directory path]. Then type fly deploy in Powershell. You'll see further information printed in Powershell.