2025-11-03 11:34:24 +01:00
---
layout: default
title: Installation
nav_order: 1
---
2025-10-17 13:14:54 +02:00
< a href = "https://lnbits.com" target = "_blank" rel = "noopener noreferrer" >
< picture >
< source media = "(prefers-color-scheme: dark)" srcset = "https://i.imgur.com/QE6SIrs.png" >
< img src = "https://i.imgur.com/fyKPgVT.png" alt = "LNbits" style = "width:300px" >
< / picture >
< / a >
2026-05-01 15:07:49 +01:00
   [](https://extensions.lnbits.com/) [<img src="https://img.shields.io/badge/community_chat-Telegram-24A1DE"> ](https://t.me/lnbits )
2020-09-03 19:53:22 +02:00
2021-07-07 10:58:21 +01:00
# Basic installation
2022-07-13 01:15:48 +02:00
2025-10-17 13:14:54 +02:00
> [!NOTE]
> **Default DB:** LNbits uses SQLite by default (simple & effective). You can switch to PostgreSQL — see the section below.
## Table of contents
2022-07-13 01:15:48 +02:00
2025-10-17 13:14:54 +02:00
- [Option 1: AppImage (Linux) ](#option-1-appimage-linux )
- [Option 2: UV (recommended for developers) ](#option-2-uv-recommended-for-developers )
- [Option 2a (Legacy): Poetry — Replaced by UV ](#option-2a-legacy-poetry--replaced-by-uv )
- [Option 3: Install script (Debian/Ubuntu) ](#option-3-install-script-debianubuntu )
- [Option 4: Nix ](#option-4-nix )
- [Option 5: Docker ](#option-5-docker )
- [Option 6: Fly.io ](#option-6-flyio )
- [Troubleshooting ](#troubleshooting )
- [Optional: PostgreSQL database ](#optional-postgresql-database )
- [Using LNbits ](#using-lnbits )
- [Additional guides ](#additional-guides )
- [Update LNbits (all methods) ](#update-lnbits-all-methods )
- [SQLite → PostgreSQL migration ](#sqlite--postgresql-migration )
- [LNbits as a systemd service ](#lnbits-as-a-systemd-service )
- [Reverse proxy with automatic HTTPS (Caddy) ](#reverse-proxy-with-automatic-https-caddy )
- [Apache2 reverse proxy over HTTPS ](#apache2-reverse-proxy-over-https )
- [Nginx reverse proxy over HTTPS ](#nginx-reverse-proxy-over-https )
- [HTTPS without a reverse proxy (self-signed) ](#https-without-a-reverse-proxy-self-signed )
- [LNbits on Umbrel behind Tor ](#lnbits-on-umbrel-behind-tor )
- [FreeBSD notes ](#freebsd-notes )
2025-02-07 09:17:55 +00:00
2025-10-17 13:14:54 +02:00
## Option 1: AppImage (Linux)
2025-02-07 09:17:55 +00:00
2025-10-17 13:14:54 +02:00
**Quickstart**
1. Download latest AppImage from [releases ](https://github.com/lnbits/lnbits/releases ) **or** run:
2025-02-07 09:17:55 +00:00
```sh
2025-10-10 07:50:41 +01:00
sudo apt-get install jq libfuse2
2025-02-07 09:17:55 +00:00
wget $(curl -s https://api.github.com/repos/lnbits/lnbits/releases/latest | jq -r '.assets[] | select(.name | endswith(".AppImage")) | .browser_download_url') -O LNbits-latest.AppImage
chmod +x LNbits-latest.AppImage
2026-06-30 13:37:13 +01:00
LNBITS_ADMIN_UI=true HOST=0.0.0.0 PORT=5000 AUTH_HTTPS_ONLY=false ./LNbits-latest.AppImage # most system settings are now in the admin UI, but pass additional .env variables here
2025-02-07 09:17:55 +00:00
```
2025-10-17 13:14:54 +02:00
- LNbits will create a folder for DB and extension files **in the same directory** as the AppImage.
2022-07-13 01:15:48 +02:00
2025-10-17 13:14:54 +02:00
> [!NOTE]
2025-11-03 11:34:24 +01:00
> **Next steps**
> Install complete → **[Running LNbits](#run-the-server)**
2025-10-17 13:14:54 +02:00
> Update LNBits → **[Update LNbits (all methods)](#update-lnbits-all-methods)**
2022-09-20 15:08:45 +03:00
2025-10-17 13:14:54 +02:00
## Option 2: UV (recommended for developers)
2025-04-10 12:28:08 +02:00
2025-10-17 13:14:54 +02:00
> [!IMPORTANT]
> **It is recommended to use the latest version of UV & Make sure you have Python version 3.12 installed.**
2025-04-10 12:28:08 +02:00
2025-10-17 13:14:54 +02:00
### Verify Python
2025-04-10 12:28:08 +02:00
2022-07-27 15:01:23 +01:00
```sh
2024-09-12 08:02:47 +02:00
python3 --version
2024-04-03 10:07:30 +02:00
```
2022-08-02 21:59:55 +01:00
2025-08-21 16:17:19 +02:00
### Install UV
```sh
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
```
2025-10-17 13:14:54 +02:00
### Install LNbits
2024-04-25 11:13:08 +02:00
2024-04-03 10:07:30 +02:00
```sh
2025-10-17 13:14:54 +02:00
git clone https://github.com/lnbits/lnbits.git
cd lnbits
git checkout main
uv sync --all-extras
cp .env.example .env
# Optional: set funding source and other options in .env (e.g., `nano .env`)
2024-04-03 10:07:30 +02:00
```
2025-10-17 13:14:54 +02:00
### Run the server
```sh
uv run lnbits
# To change port/host: uv run lnbits --port 9000 --host 0.0.0.0
# Add --debug to the command above and set DEBUG=true in .env for verbose output
```
### LNbits CLI
```sh
# Useful for superuser ID, updating extensions, etc.
uv run lnbits-cli --help
```
### Update LNbits
2024-12-19 09:23:49 +00:00
2024-04-03 10:07:30 +02:00
```sh
cd lnbits
2025-10-17 13:14:54 +02:00
# Stop LNbits with Ctrl + X or your service manager
# sudo systemctl stop lnbits
# Update code
git pull --rebase
2025-08-21 16:17:19 +02:00
uv sync --all-extras
2025-10-17 13:14:54 +02:00
uv run lnbits
```
#### Use Admin UI → Extensions → "Update All" to bring extensions up to the proper level
2025-08-21 16:17:19 +02:00
2025-10-17 13:14:54 +02:00
> [!NOTE]
2025-11-03 11:34:24 +01:00
> **Next steps**
> Install complete → **[Running LNbits](#run-the-server)**
2025-10-17 13:14:54 +02:00
> Update LNBits → **[Update LNbits (all methods)](#update-lnbits-all-methods)**
2025-08-21 16:17:19 +02:00
2025-10-17 13:14:54 +02:00
## Option 2a (Legacy): Poetry — _Replaced by UV_
< details >
< summary > < strong > Poetry install and update (legacy workflow)< / summary >
This legacy section is preserved for older environments.
**UV is the recommended (and faster) tool** for new installs. Use Poetry only if you have personal preferences or must support an older workflow.
> 
> **It is recommended to use the latest version of Poetry & Make sure you have Python version 3.12 installed.**
### Verify Python version
```sh
python3 --version
```
### Install Poetry
```sh
# If path 'export PATH="$HOME/.local/bin:$PATH"' fails, use the path echoed by the install
curl -sSL https://install.python-poetry.org | python3 - & & export PATH="$HOME/.local/bin:$PATH"
```
### Install LNbits
```sh
git clone https://github.com/lnbits/lnbits.git
cd lnbits
poetry env use 3.12
git checkout main
poetry install --only main
2022-08-02 22:00:55 +01:00
cp .env.example .env
2024-12-19 09:23:49 +00:00
# Optional: to set funding source amongst other options via the env `nano .env`
2022-08-04 08:05:51 +02:00
```
2022-07-27 15:01:23 +01:00
#### Running the server
2022-08-03 14:10:32 +02:00
2022-07-27 15:01:23 +01:00
```sh
2025-10-17 13:14:54 +02:00
poetry run lnbits
# To change port/host: poetry run lnbits --port 9000 --host 0.0.0.0
# Add --debug to help troubleshooting (also set DEBUG=true in .env)
2022-07-27 15:01:23 +01:00
```
2024-04-25 11:13:08 +02:00
2025-10-17 13:14:54 +02:00
#### LNbits CLI
2022-12-07 10:26:30 +00:00
2024-12-19 09:23:49 +00:00
```sh
2025-10-17 13:14:54 +02:00
# A very useful terminal client for getting the superuser ID, updating extensions, etc.
poetry run lnbits-cli --help
2022-12-07 10:26:30 +00:00
```
2024-12-19 09:23:49 +00:00
#### Updating the server
```sh
2023-01-14 11:26:17 +00:00
cd lnbits
2025-10-17 13:14:54 +02:00
# Stop LNbits with Ctrl + X or with your service manager
2025-05-04 10:37:03 +03:00
# sudo systemctl stop lnbits
# Update LNbits
git pull --rebase
2025-10-17 13:14:54 +02:00
# Check your Poetry Python version
poetry env list
# If version is less than 3.12, update it:
poetry env use python3.12
poetry env remove python3.X
poetry env list
# Reinstall and start
poetry install --only main
poetry run lnbits
```
2025-05-04 10:37:03 +03:00
2025-10-17 13:14:54 +02:00
#### Use Admin UI → Extensions → "Update All" to bring extensions up to the proper level
2025-08-21 16:17:19 +02:00
2025-10-17 13:14:54 +02:00
> 
2025-11-03 11:34:24 +01:00
> **Next steps**
> Install complete → **[Running LNbits](#run-the-server)**
2025-10-17 13:14:54 +02:00
> Update LNBits → **[Update LNbits (all methods)](#update-lnbits-all-methods)**
2025-05-04 10:37:03 +03:00
2025-10-17 13:14:54 +02:00
< / details >
## Option 3: Install script (Debian/Ubuntu)
2022-07-27 15:01:23 +01:00
2025-10-17 13:14:54 +02:00
< details >
< summary > < strong > Show install script< / strong > (one-line setup)< / summary >
2025-04-10 12:28:08 +02:00
```sh
wget https://raw.githubusercontent.com/lnbits/lnbits/main/lnbits.sh & &
chmod +x lnbits.sh & &
./lnbits.sh
```
2025-10-17 13:14:54 +02:00
- You can use `./lnbits.sh` to run, but for more control: `cd lnbits` and use `uv run lnbits` (see Option 2).
> 
2025-11-03 11:34:24 +01:00
> **Next steps**
> Install complete → **[Running LNbits](#run-the-server)**
2025-10-17 13:14:54 +02:00
> Update LNBits → **[Update LNbits (all methods)](#update-lnbits-all-methods)**
2025-04-10 12:28:08 +02:00
2025-10-17 13:14:54 +02:00
< / details >
2025-04-10 12:28:08 +02:00
2025-10-17 13:14:54 +02:00
## Option 4: Nix
< details >
< summary > < strong > Show Nix instructions< / strong > (flakes, cachix, run)< / summary >
2022-10-28 10:22:59 +01:00
2022-07-13 01:15:48 +02:00
```sh
2023-11-13 14:28:52 +00:00
# Install nix. If you have installed via another manager, remove and use this install (from https://nixos.org/download)
2025-10-10 16:39:08 +01:00
sh < (curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install) --daemon --yes
2023-11-13 14:28:52 +00:00
2024-01-11 01:09:08 +00:00
# Enable nix-command and flakes experimental features for nix:
2025-09-26 07:28:28 +01:00
grep -qxF 'experimental-features = nix-command flakes' /etc/nix/nix.conf || \
echo 'experimental-features = nix-command flakes' | sudo tee -a /etc/nix/nix.conf
# Add user to Nix
grep -qxF "trusted-users = root $USER" /etc/nix/nix.conf || \
echo "trusted-users = root $USER" | sudo tee -a /etc/nix/nix.conf
# Restart daemon so changes apply
sudo systemctl restart nix-daemon
2024-01-11 01:09:08 +00:00
2025-10-10 16:39:08 +01:00
# Clone and build LNbits
git clone https://github.com/lnbits/lnbits.git
cd lnbits
# Make data directory and persist data/extension folders
mkdir data
PROJECT_DIR="$(pwd)"
{
echo "export PYTHONPATH=\"$PROJECT_DIR/ns:\$PYTHONPATH\""
echo "export LNBITS_DATA_FOLDER=\"$PROJECT_DIR/data\""
echo "export LNBITS_EXTENSIONS_PATH=\"$PROJECT_DIR\""
} >> ~/.bashrc
grep -qxF '. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ~/.bashrc || \
echo '. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' >> ~/.bashrc
. ~/.bashrc
2024-01-11 01:09:08 +00:00
# Add cachix for cached binaries
nix-env -iA cachix -f https://cachix.org/api/v1/install
cachix use lnbits
2025-10-10 16:39:08 +01:00
# Build LNbits
2024-01-11 01:09:08 +00:00
nix build
2022-07-13 01:15:48 +02:00
2022-07-28 11:19:30 +01:00
```
2022-07-13 01:15:48 +02:00
#### Running the server
2022-07-28 11:19:30 +01:00
2022-07-13 01:15:48 +02:00
```sh
2024-01-11 01:09:08 +00:00
nix run
```
Ideally you would set the environment via the `.env` file,
but you can also set the env variables or pass command line arguments:
2024-04-25 11:13:08 +02:00
```sh
2023-11-13 14:28:52 +00:00
# .env variables are currently passed when running, but LNbits can be managed with the admin UI.
2026-06-30 14:08:49 +01:00
LNBITS_ADMIN_UI=true AUTH_HTTPS_ONLY=false ./result/bin/lnbits --port 9000 --host 0.0.0.0
2022-07-13 01:15:48 +02:00
```
2025-10-17 13:14:54 +02:00
> 
2025-11-03 11:34:24 +01:00
> **Next steps**
2025-10-17 13:14:54 +02:00
> Update LNBits → **[Update LNbits (all methods)](#update-lnbits-all-methods)**
< / details >
## Option 5: Docker
2022-07-30 17:09:14 +02:00
2025-10-17 13:14:54 +02:00
< details >
< summary > < strong > Show Docker instructions< / strong > (official image, volumes, extensions)< / summary >
**Use latest image**
2024-04-25 11:13:08 +02:00
2023-01-26 11:53:59 +01:00
```sh
2024-02-08 14:24:55 +01:00
docker pull lnbits/lnbits
2023-01-26 11:53:59 +01:00
wget https://raw.githubusercontent.com/lnbits/lnbits/main/.env.example -O .env
mkdir data
2025-10-17 13:14:54 +02:00
docker run --detach --publish 5000:5000 --name lnbits \
--volume ${PWD}/.env:/app/.env \
--volume ${PWD}/data/:/app/data \
lnbits/lnbits
2023-01-26 11:53:59 +01:00
```
2024-04-25 11:13:08 +02:00
2025-10-17 13:14:54 +02:00
- The LNbits Docker image ships **without any extensions** ; by default, any extensions you install are stored **inside the container** and will be **lost** when the container is removed, so you should set `LNBITS_EXTENSIONS_PATH` to a directory that’ s **mapped to a persistent host volume** so extensions **survive rebuilds/recreates** —for example:
2025-06-30 16:27:44 +03:00
```sh
docker run ... -e "LNBITS_EXTENSIONS_PATH='/app/data/extensions'" --volume ${PWD}/data/:/app/data ...
```
2025-10-17 13:14:54 +02:00
**Build image yourself**
2024-04-25 11:13:08 +02:00
2022-07-30 17:09:14 +02:00
```sh
2023-01-14 11:26:17 +00:00
git clone https://github.com/lnbits/lnbits.git
cd lnbits
2024-02-08 14:24:55 +01:00
docker build -t lnbits/lnbits .
2022-07-30 17:09:14 +02:00
cp .env.example .env
mkdir data
2025-10-17 13:14:54 +02:00
docker run --detach --publish 5000:5000 --name lnbits \
--volume ${PWD}/.env:/app/.env \
--volume ${PWD}/data/:/app/data \
lnbits/lnbits
2022-07-30 17:09:14 +02:00
```
2025-10-17 13:14:54 +02:00
You can optionally override the install extras for both **Poetry** and **UV** to include optional features during build or setup:
- with Poetry, pass extras via the `POETRY_INSTALL_ARGS` Docker build-arg (e.g., to enable the **Breez** funding source: `docker build --build-arg POETRY_INSTALL_ARGS="-E breez" -t lnbits/lnbits .` );
- with UV, enable extras during environment sync (e.g., locally run `uv sync --extra breez` or `uv sync --all-extras` ), and—**if your Dockerfile supports it**—you can mirror the same at build time via a build-arg such as `UV_SYNC_ARGS` (example pattern: `docker build --build-arg UV_SYNC_ARGS="--extra breez" -t lnbits/lnbits .` ).
**Enable Breez funding source at build**
2025-05-11 04:47:45 +02:00
```sh
docker build --build-arg POETRY_INSTALL_ARGS="-E breez" -t lnbits/lnbits .
```
2025-10-17 13:14:54 +02:00
> 
2025-11-03 11:34:24 +01:00
> **Next steps**
> Install complete → **[Running LNbits](#run-the-server)**
2025-10-17 13:14:54 +02:00
> Update LNBits → **[Update LNbits (all methods)](#update-lnbits-all-methods)**
2022-08-19 16:29:32 -06:00
2025-10-17 13:14:54 +02:00
< / details >
2022-08-19 16:29:32 -06:00
2025-10-17 13:14:54 +02:00
## Option 6: Fly.io
2022-08-19 16:29:32 -06:00
2025-10-17 13:14:54 +02:00
< details >
< summary > < strong > Deploy LNbits on Fly.io (free tier friendly)< / summary >
2022-08-19 16:29:32 -06:00
2025-10-17 13:14:54 +02:00
**Fly.io is a docker container hosting platform that has a generous free tier. You can host LNbits for free on Fly.io for personal use.**
1. Create an account at [Fly.io ](https://fly.io ).
2. Install the Fly.io CLI ([guide ](https://fly.io/docs/getting-started/installing-flyctl/ )).
2022-08-21 12:57:28 -06:00
```
flyctl was installed successfully to /home/ubuntu/.fly/bin/flyctl
Manually add the directory to your $HOME/.bash_profile (or similar)
export FLYCTL_INSTALL="/home/ubuntu/.fly"
export PATH="$FLYCTL_INSTALL/bin:$PATH"
```
2025-10-17 13:14:54 +02:00
3. You can either run those commands, then `source ~/.bash_profile` or, if you don't, you'll have to call Fly from `~/.fly/bin/flyctl` .
2022-08-21 12:57:28 -06:00
2025-10-17 13:14:54 +02:00
- Once installed, run the following commands.
2022-08-19 16:29:32 -06:00
```
2023-01-14 11:26:17 +00:00
git clone https://github.com/lnbits/lnbits.git
cd lnbits
2022-08-19 16:29:32 -06:00
fly auth login
[complete login process]
2022-08-21 12:57:28 -06:00
fly launch
2022-08-19 16:29:32 -06:00
```
2022-08-21 12:57:28 -06:00
You'll be prompted to enter an app name, region, postgres (choose no), deploy now (choose no).
2023-01-26 11:53:59 +01:00
You'll now find a file in the directory called `fly.toml` . Open that file and modify/add the following settings.
2022-08-19 16:29:32 -06:00
2025-10-17 13:14:54 +02:00
> 
2025-11-03 11:34:24 +01:00
> Be sure to replace `${PUT_YOUR_LNBITS_ENV_VARS_HERE}` with all relevant environment variables in `.env` or `.env.example`.
> Environment variable strings should be quoted here. For example, if `.env` has
> `LNBITS_ENDPOINT=https://demo.lnbits.com`, then in `fly.toml` use
2025-10-17 13:14:54 +02:00
> `LNBITS_ENDPOINT="https://demo.lnbits.com"`.
2022-08-21 11:46:11 -06:00
2025-10-17 13:14:54 +02:00
> 
2025-11-03 11:34:24 +01:00
> Don't enter secret environment variables here. Fly.io offers **secrets** (via `fly secrets`) that are exposed as env vars at runtime.
> Example (LND REST funding source):
2025-10-17 13:14:54 +02:00
> `fly secrets set LND_REST_MACAROON=<hex_macaroon_data>`
2022-08-19 16:29:32 -06:00
```
2022-08-21 12:57:28 -06:00
...
2022-08-19 16:29:32 -06:00
kill_timeout = 30
2022-08-21 12:57:28 -06:00
...
2022-08-19 16:29:32 -06:00
2022-08-21 12:57:28 -06:00
...
2022-08-19 16:29:32 -06:00
[mounts]
2022-08-21 11:46:11 -06:00
source="lnbits_data"
destination="/data"
2022-08-21 12:57:28 -06:00
...
2022-08-19 16:29:32 -06:00
2022-08-21 12:57:28 -06:00
...
2022-08-19 16:29:32 -06:00
[env]
HOST="127.0.0.1"
PORT=5000
2022-10-26 05:02:35 -06:00
FORWARDED_ALLOW_IPS="*"
2023-02-28 13:45:43 +01:00
LNBITS_BASEURL="https://mylnbits.lnbits.org/"
2022-08-21 11:39:34 -06:00
LNBITS_DATA_FOLDER="/data"
2023-01-26 11:53:59 +01:00
2022-08-19 16:29:32 -06:00
${PUT_YOUR_LNBITS_ENV_VARS_HERE}
2022-08-21 12:57:28 -06:00
...
2022-08-19 16:29:32 -06:00
2022-08-21 12:57:28 -06:00
...
2022-08-19 16:29:32 -06:00
[[services]]
internal_port = 5000
2022-08-21 12:57:28 -06:00
...
2022-08-19 16:29:32 -06:00
```
2022-11-30 14:14:31 +00:00
Next, create a volume to store the sqlite database for LNbits. Be sure to choose the same region for the volume that you chose earlier.
2022-08-19 16:29:32 -06:00
```
fly volumes create lnbits_data --size 1
```
2022-08-21 12:57:28 -06:00
You're ready to deploy! Run `fly deploy` and follow the steps to finish deployment. You'll select a `region` (up to you, choose the same as you did for the storage volume previously created), `postgres` (choose no), `deploy` (choose yes).
2022-08-19 16:29:32 -06:00
You can use `fly logs` to view the application logs, or `fly ssh console` to get a ssh shell in the running container.
2022-07-13 01:15:48 +02:00
### Troubleshooting
2022-08-03 14:10:32 +02:00
Problems installing? These commands have helped us install LNbits.
2022-07-13 01:15:48 +02:00
```sh
2022-07-23 10:39:58 +02:00
sudo apt install pkg-config libffi-dev libpq-dev
2022-07-13 01:15:48 +02:00
2022-09-20 15:08:45 +03:00
# build essentials for debian/ubuntu
2025-03-03 12:53:30 +01:00
sudo apt install python3.10-dev gcc build-essential
2022-09-20 15:08:45 +03:00
2022-07-13 01:15:48 +02:00
# if the secp256k1 build fails:
2022-07-28 11:43:31 +01:00
# if you used poetry
2022-08-03 14:10:32 +02:00
poetry add setuptools wheel
2022-07-13 01:15:48 +02:00
```
2025-10-17 13:14:54 +02:00
> 
>
2025-11-03 11:34:24 +01:00
> **Next steps**
> Install complete → **[Running LNbits](#run-the-server)**
2025-10-17 13:14:54 +02:00
> Update LNbits → **[Update LNbits (all methods)](#update-lnbits-all-methods)**
## Troubleshooting
```sh
sudo apt install pkg-config libffi-dev libpq-dev
# build essentials (Debian/Ubuntu)
sudo apt install python3.10-dev gcc build-essential
# if secp256k1 build fails and you used poetry
poetry add setuptools wheel
```
< / details >
< / details >
2022-07-13 01:15:48 +02:00
2025-10-17 13:14:54 +02:00
## Optional: PostgreSQL database
> [!TIP]
> If you want to use LNbits at scale, we recommend using PostgreSQL as the backend database. Install Postgres and set up a database for LNbits.
2022-01-27 21:07:47 +01:00
2021-11-12 11:38:07 +00:00
```sh
2025-10-17 13:14:54 +02:00
# Debian/Ubuntu: sudo apt-get -y install postgresql
# or see https://www.postgresql.org/download/linux/
2021-11-12 11:38:07 +00:00
2025-10-17 13:14:54 +02:00
# Create a password for the postgres user
2021-11-12 11:44:44 +00:00
sudo -i -u postgres
psql
2025-10-17 13:14:54 +02:00
# in psql
ALTER USER postgres PASSWORD 'myPassword';
2021-11-12 11:38:07 +00:00
\q
2025-10-17 13:14:54 +02:00
# back as postgres user
2021-11-12 11:44:44 +00:00
createdb lnbits
2021-11-12 11:38:07 +00:00
exit
```
2020-09-03 19:53:22 +02:00
2025-10-17 13:14:54 +02:00
**Configure LNbits**
2020-09-03 19:53:22 +02:00
```sh
2021-11-12 11:38:07 +00:00
# add the database connection string to .env 'nano .env' LNBITS_DATABASE_URL=
2022-11-07 11:30:18 +01:00
# postgres://<user>:<myPassword>@<host>:<port>/<lnbits> - alter line bellow with your user, password and db name
LNBITS_DATABASE_URL="postgres://postgres:postgres@localhost:5432/lnbits "
2021-11-12 11:38:07 +00:00
# save and exit
2020-09-03 19:53:22 +02:00
```
2022-07-13 01:15:48 +02:00
# Using LNbits
2025-10-17 13:14:54 +02:00
Visit ** [http://localhost:5000/ ](http://localhost:5000/ )** (or `0.0.0.0:5000` ).
### Option A — First-run setup in the Browser (UI)
1. On the **first start** , LNbits will **prompt you to Setup a SuperUser** .
2. After creating it, you’ ll be **redirected to the Admin UI as SuperUser** .
3. In the Admin UI, **set your funding source** (backend wallet) and other preferences.
4. **Restart LNbits** if prompted or after changing critical settings.
2020-09-03 19:53:22 +02:00
2025-10-17 13:14:54 +02:00
> [!IMPORTANT]
> Use the **SuperUser only** for initial setup and instance settings (funding source, configuration, Topup).
> For maintenance, create a separate **Admin** account. For everyday usage (payments, wallets, etc.), **do not use the SuperUser** — use admin or regular user accounts instead. Its a bad behaviour.
> Read more about [SuperUser](./super_user.md) and [Admin UI](./admin_ui.md)
2020-09-03 19:53:22 +02:00
2025-10-17 13:14:54 +02:00
### Option B — Configure via `.env`
2020-09-03 19:53:22 +02:00
2025-10-17 13:14:54 +02:00
1. Edit your `.env` with preferred settings (funding, base URL, etc.).
2. Set a funding source by configuring:
- `LNBITS_BACKEND_WALLET_CLASS`
- plus the required credentials for your chosen backend (see ** [wallets.md ](./wallets.md )**).
3. **Restart LNbits** to apply changes.
---
2022-07-13 01:15:48 +02:00
2025-10-17 13:14:54 +02:00
> [!NOTE]
> **Paths overview**
>
2025-11-03 11:34:24 +01:00
> - **SuperUser file:** `<lnbits_root>/data/.super_user`
2025-10-17 13:14:54 +02:00
> Example: `~/lnbits/data/.super_user` • View: `cat ~/lnbits/data/.super_user`
> - **Environment file:** `<lnbits_root>/.env` (for bare-metal installs)
2025-11-03 11:34:24 +01:00
> - **Docker:** bind a host directory to `/app/data`.
> On the host the SuperUser file is at `<host_data_dir>/.super_user`.
2025-10-17 13:14:54 +02:00
> The container reads `/app/.env` (usually bind-mounted from your project root).
> [!TIP]
2025-11-03 11:34:24 +01:00
> **Local Lightning test network**
> Use **Polar** to spin up a safe local Lightning environment and test LNbits without touching your live setup.
2025-10-17 13:14:54 +02:00
> https://lightningpolar.com/
> [!TIP]
2025-11-03 11:34:24 +01:00
> **API comparison before updates**
> Use **TableTown** to diff your LNbits instance against another (dev vs prod) or the upstream dev branch. Spot endpoint changes before updating.
> Crafted by [Arbadacarbayk](https://github.com/arbadacarbaYK) - a standout contribution that makes pre-release reviews fast and reliable.
2025-10-17 13:14:54 +02:00
> https://arbadacarbayk.github.io/LNbits_TableTown/
2021-03-19 12:27:41 +01:00
2022-07-13 01:15:48 +02:00
# Additional guides
2025-10-17 13:14:54 +02:00
## Update LNbits (all methods)
> After updating, open **Admin UI → Extensions → “Update All”** to make sure extensions match the core version.
< details >
< summary > < strong > UV (recommended)< / strong > < / summary >
```sh
cd lnbits
git pull --rebase
uv sync --all-extras
# restart (dev)
uv run lnbits
```
< / details >
< details >
< summary > < strong > Poetry (legacy)< / strong > < / summary >
```sh
cd lnbits
git pull --rebase
# Optional: ensure Python 3.12
poetry env list
poetry env use python3.12
poetry install --only main
# restart (dev)
poetry run lnbits
```
< / details >
< details >
< summary > < strong > AppImage< / strong > < / summary >
Download the latest AppImage from Releases and replace your old file **in the same directory** to keep the `./data` folder (DB, extensions).
2024-04-25 11:13:08 +02:00
2025-10-17 13:14:54 +02:00
< / details >
2022-07-13 01:15:48 +02:00
2025-10-17 13:14:54 +02:00
< details >
< summary > < strong > Install script (Debian/Ubuntu)< / strong > < / summary >
```sh
# If you installed via lnbits.sh:
cd lnbits
git pull --rebase
# then use your chosen runner (UV recommended)
uv sync --all-extras
uv run lnbits
```
< / details >
< details >
< summary > < strong > Nix< / strong > < / summary >
```sh
cd lnbits
git pull --rebase
nix build
# restart
nix run
```
< / details >
< details >
< summary > < strong > Docker (official image)< / strong > < / summary >
```sh
docker pull lnbits/lnbits
docker stop lnbits & & docker rm lnbits
docker run --detach --publish 5000:5000 --name lnbits \
--volume ${PWD}/.env:/app/.env \
--volume ${PWD}/data/:/app/data \
lnbits/lnbits
```
< / details >
< details >
< summary > < strong > Docker (build yourself)< / strong > < / summary >
```sh
cd lnbits
git pull --rebase
docker build -t lnbits/lnbits .
docker stop lnbits & & docker rm lnbits
docker run --detach --publish 5000:5000 --name lnbits \
--volume ${PWD}/.env:/app/.env \
--volume ${PWD}/data/:/app/data \
lnbits/lnbits
```
< / details >
< details >
< summary > < strong > Fly.io< / strong > < / summary >
```sh
# If using Dockerfile in repo (recommended)
cd lnbits
git pull --rebase
fly deploy
# Logs & shell if needed
fly logs
fly ssh console
```
< / details >
## SQLite → PostgreSQL migration
> [!TIP]
> If you run on SQLite and plan to scale, migrate to Postgres.
2022-01-27 21:07:47 +01:00
2021-11-18 11:33:26 +00:00
```sh
# STOP LNbits
2025-10-17 13:14:54 +02:00
# Edit .env with Postgres URL
2021-11-18 11:33:26 +00:00
LNBITS_DATABASE_URL="postgres://postgres:postgres@localhost/lnbits "
# save and exit
2022-06-02 08:51:02 +02:00
2025-10-17 13:14:54 +02:00
# START then STOP LNbits once to apply schema
2025-08-21 16:17:19 +02:00
uv run python tools/conv.py
2022-08-17 15:42:01 +02:00
# or
make migration
2021-11-18 11:33:26 +00:00
```
2025-10-17 13:14:54 +02:00
- Launch LNbits again and verify.
2021-11-18 11:33:26 +00:00
2022-07-21 14:01:16 +02:00
## LNbits as a systemd service
2022-01-27 21:07:47 +01:00
2025-10-17 13:14:54 +02:00
Create `/etc/systemd/system/lnbits.service` :
2022-01-27 21:07:47 +01:00
```
# Systemd unit for lnbits
# /etc/systemd/system/lnbits.service
[Unit]
Description=LNbits
2025-10-17 13:14:54 +02:00
# Optional: start after your backend
2022-08-03 14:10:32 +02:00
#Wants=lnd.service
#After=lnd.service
2022-01-27 21:07:47 +01:00
[Service]
2023-03-07 20:14:15 -08:00
WorkingDirectory=/home/lnbits/lnbits
2025-10-17 13:14:54 +02:00
# Find uv path via `which uv`
2025-08-21 16:17:19 +02:00
ExecStart=/home/lnbits/.local/bin/uv run lnbits
2022-08-17 14:25:19 +02:00
User=lnbits
2022-01-27 21:07:47 +01:00
Restart=always
TimeoutSec=120
RestartSec=30
2022-08-03 14:10:32 +02:00
Environment=PYTHONUNBUFFERED=1
2022-01-27 21:07:47 +01:00
[Install]
WantedBy=multi-user.target
```
2025-10-17 13:14:54 +02:00
Enable & start:
2022-01-27 21:07:47 +01:00
```sh
sudo systemctl enable lnbits.service
sudo systemctl start lnbits.service
```
2023-03-17 15:13:25 +01:00
2025-10-17 13:14:54 +02:00
## Reverse proxy with automatic HTTPS (Caddy)
2022-09-29 10:34:03 +01:00
2025-10-17 13:14:54 +02:00
Point your domain A-record to your server IP. Install Caddy: [Caddy install guide ](https://caddyserver.com/docs/install#debian-ubuntu-raspbian )
2022-09-29 10:31:10 +01:00
2025-10-17 13:14:54 +02:00
```sh
2022-09-29 10:31:10 +01:00
sudo caddy stop
sudo nano Caddyfile
```
2023-03-17 15:13:25 +01:00
2025-10-17 13:14:54 +02:00
Add:
2023-03-17 15:13:25 +01:00
2022-09-29 10:31:10 +01:00
```
yourdomain.com {
reverse_proxy 0.0.0.0:5000 {
2022-09-29 10:45:09 +01:00
header_up X-Forwarded-Host yourdomain.com
2022-09-29 10:31:10 +01:00
}
}
```
2023-03-17 15:13:25 +01:00
2025-10-17 13:14:54 +02:00
Save (Ctrl+X) and start:
2023-03-17 15:13:25 +01:00
2025-10-17 13:14:54 +02:00
```sh
2022-09-29 10:31:10 +01:00
sudo caddy start
```
2022-01-27 21:07:47 +01:00
2025-10-17 13:14:54 +02:00
## Apache2 reverse proxy over HTTPS
2023-03-17 15:13:25 +01:00
2022-08-13 14:41:23 +02:00
```sh
apt-get install apache2 certbot
2024-10-10 21:22:15 +02:00
a2enmod headers ssl proxy proxy_http
2023-03-17 15:13:25 +01:00
certbot certonly --webroot --agree-tos --non-interactive --webroot-path /var/www/html -d lnbits.org
2022-08-13 14:41:23 +02:00
```
2023-03-17 15:13:25 +01:00
2025-10-17 13:14:54 +02:00
Create `/etc/apache2/sites-enabled/lnbits.conf` :
2023-03-17 15:13:25 +01:00
2022-08-13 14:41:23 +02:00
```sh
cat < < EOF > /etc/apache2/sites-enabled/lnbits.conf
< VirtualHost * :443 >
ServerName lnbits.org
SSLEngine On
SSLProxyEngine On
SSLCertificateFile /etc/letsencrypt/live/lnbits.org/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/lnbits.org/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
LogLevel info
ErrorLog /var/log/apache2/lnbits.log
CustomLog /var/log/apache2/lnbits-access.log combined
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
RequestHeader set "X-Forwarded-SSL" expr=%{HTTPS}
ProxyPreserveHost On
ProxyPass / http://localhost:5000/
ProxyPassReverse / http://localhost:5000/
< Proxy * >
Order deny,allow
Allow from all
< / Proxy >
< / VirtualHost >
EOF
```
2023-03-17 15:13:25 +01:00
2025-10-17 13:14:54 +02:00
Restart:
2023-03-17 15:13:25 +01:00
2022-08-13 14:41:23 +02:00
```sh
2024-10-10 21:22:15 +02:00
service apache2 restart
2022-08-13 14:41:23 +02:00
```
2025-10-17 13:14:54 +02:00
## Nginx reverse proxy over HTTPS
2023-03-17 15:10:15 +01:00
```sh
apt-get install nginx certbot
certbot certonly --nginx --agree-tos -d lnbits.org
```
2025-10-17 13:14:54 +02:00
Create `/etc/nginx/sites-enabled/lnbits.org` :
2023-03-17 15:10:15 +01:00
```sh
cat < < EOF > /etc/nginx/sites-enabled/lnbits.org
server {
server_name lnbits.org;
location / {
proxy_pass http://127.0.0.1:5000;
}
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
2024-07-09 14:56:31 +02:00
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_request_headers on;
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
2023-03-17 15:10:15 +01:00
listen [::]:443 ssl;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/lnbits.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/lnbits.org/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
EOF
```
2025-10-17 13:14:54 +02:00
Restart:
2023-03-17 15:10:15 +01:00
```sh
2024-10-10 21:22:15 +02:00
service nginx restart
2023-03-17 15:10:15 +01:00
```
2022-08-13 14:41:23 +02:00
2025-10-17 13:14:54 +02:00
---
2022-07-21 14:01:16 +02:00
2025-10-17 13:14:54 +02:00
## HTTPS without a reverse proxy (self-signed)
2022-07-21 14:01:16 +02:00
2025-10-17 13:14:54 +02:00
Create a self-signed cert (useful for local/dev). Browsers won’ t trust it by default.
2024-04-25 11:13:08 +02:00
2025-10-17 13:14:54 +02:00
### Install mkcert
2022-07-21 14:01:16 +02:00
2025-10-17 13:14:54 +02:00
- Install instructions: [mkcert README ](https://github.com/FiloSottile/mkcert )
- Ubuntu example:
2024-04-25 11:13:08 +02:00
2022-07-21 14:01:16 +02:00
```sh
sudo apt install libnss3-tools
curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64"
chmod +x mkcert-v*-linux-amd64
sudo cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert
```
2024-04-25 11:13:08 +02:00
2025-10-17 13:14:54 +02:00
### Create certificate
2024-04-25 11:13:08 +02:00
2025-10-17 13:14:54 +02:00
**OpenSSL**
2024-04-25 11:13:08 +02:00
2022-08-10 10:32:43 +02:00
```sh
openssl req -new -newkey rsa:4096 -x509 -sha256 -days 3650 -nodes -out cert.pem -keyout key.pem
```
2024-04-25 11:13:08 +02:00
2025-10-17 13:14:54 +02:00
**mkcert** (alternative)
2024-04-25 11:13:08 +02:00
2022-07-21 14:01:16 +02:00
```sh
2025-10-17 13:14:54 +02:00
# include your local IP (e.g., 192.x.x.x) if needed
2022-08-03 14:10:32 +02:00
mkcert localhost 127.0.0.1 ::1
2022-07-21 14:01:16 +02:00
```
2025-10-17 13:14:54 +02:00
**Run with certs**
2022-07-21 14:01:16 +02:00
```sh
2023-03-16 16:45:23 +01:00
poetry run uvicorn lnbits.__main__:app --host 0.0.0.0 --port 5000 --ssl-keyfile ./key.pem --ssl-certfile ./cert.pem
2022-07-21 14:01:16 +02:00
```
2025-10-17 13:14:54 +02:00
## LNbits on Umbrel behind Tor
2021-07-07 10:58:21 +01:00
2025-10-17 13:14:54 +02:00
See this community [guide ](https://community.getumbrel.com/t/guide-lnbits-without-tor/604 ).
2021-03-19 12:27:41 +01:00
2025-10-17 13:14:54 +02:00
## FreeBSD notes
2024-04-25 11:13:08 +02:00
2025-10-17 13:14:54 +02:00
Issue with secp256k1 0.14.0 on FreeBSD (thanks @GitKalle ):
2021-03-19 12:27:41 +01:00
2025-10-17 13:14:54 +02:00
1. Install `py311-secp256k1` with `pkg install py311-secp256k1` .
2. Change version in `pyproject.toml` from `0.14.0` to `0.13.2` .
3. Rewrite `poetry.lock` with `poetry lock` .
4. Follow install instructions with Poetry.
2021-07-07 10:58:21 +01:00
2025-10-17 13:14:54 +02:00
---
2021-07-07 10:58:21 +01:00
2025-10-17 13:14:54 +02:00
## Powered by LNbits
2025-04-29 12:55:07 +02:00
2025-10-17 13:14:54 +02:00
LNbits empowers everyone with modular, open-source tools for building Bitcoin-based systems — fast, free, and extendable.
2025-04-29 12:55:07 +02:00
2025-10-17 13:14:54 +02:00
If you like this project [send some tip love ](https://demo.lnbits.com/tipjar/DwaUiE4kBX6mUW6pj3X5Kg ) or visiting our [Shop ](https://shop.lnbits.com )
2025-04-29 12:55:07 +02:00
2025-11-03 11:34:24 +01:00
[](https://shop.lnbits.com/)
2025-10-17 13:14:54 +02:00
[](https://shop.lnbits.com/) [](https://my.lnbits.com/login) [](https://news.lnbits.com/) [](https://extensions.lnbits.com/)