Guideschevron_rightServers

Servers · 8 min read · Updated

How to Self-Host Vaultwarden (Bitwarden) on a VPS

To self-host Vaultwarden, the lightweight Bitwarden-compatible password server, run the vaultwarden/server image with Docker Compose behind Caddy, which serves it over HTTPS with an automatic certificate. Point a domain at the VPS, set DOMAIN to its https address, create your account, then turn sign-ups off, protect the admin page with a hashed token and back up the data folder off the server every night. It runs comfortably on the smallest VPS (6 GB, $37.50 a month).

1. Prepare the Server and Domain

Order a VPS with Ubuntu 24.04, secure it, and install Docker. Create an A record such as vault.example.com pointing at the server, and allow ports 80 and 443 in the firewall; Caddy needs both to get its certificate.

2. Write the Compose File

In a folder such as ~/vaultwarden, create compose.yaml:

services:
  vaultwarden:
    image: vaultwarden/server:latest
    container_name: vaultwarden
    restart: always
    environment:
      DOMAIN: "https://vault.example.com"
      SIGNUPS_ALLOWED: "true"        # set to "false" after creating your account
    volumes:
      - ./vw-data:/data

  caddy:
    image: caddy:2
    container_name: caddy
    restart: always
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - ./caddy-data:/data
      - ./caddy-config:/config

And a Caddyfile beside it:

vault.example.com {
    reverse_proxy vaultwarden:80
}

Only Caddy publishes ports; Vaultwarden is reachable only through it. Start both and watch Caddy fetch the certificate:

docker compose up -d
docker compose logs -f caddy

3. Create Your Account, Then Close Sign-ups

Open https://vault.example.com, create your account with a strong master password, and log in from the Bitwarden apps by choosing the self-hosted option and entering the same address. Then stop anyone else from registering:

# compose.yaml
      SIGNUPS_ALLOWED: "false"

docker compose up -d

4. Protect the Admin Page

The admin page at /admin stays off until you set ADMIN_TOKEN. Store a hash, not the password itself. Generate one with Vaultwarden's own command:

docker run --rm -it vaultwarden/server /vaultwarden hash

It prints a string starting with $argon2id$. In compose.yaml, every $ must be doubled to $$, or Compose treats it as a variable:

      ADMIN_TOKEN: "$$argon2id$$v=19$$m=65540,t=3,p=4$$...rest of the hash..."

Run docker compose config to check it came through intact, then docker compose up -d. Settings saved on the admin page go into config.json in the data folder and take priority over the compose file.

5. Back It Up Every Night

Everything is in vw-data: the database, attachments, sends, the key that signs logins and the config. Copy the database safely while it runs, then send the folder off the server:

sudo apt install -y sqlite3
sudo mkdir -p /var/backups/vaultwarden
sudo sqlite3 ~/vaultwarden/vw-data/db.sqlite3 ".backup '/var/backups/vaultwarden/db.sqlite3'"
sudo rsync -a --exclude 'db.sqlite3*' ~/vaultwarden/vw-data/ /var/backups/vaultwarden/

Then copy /var/backups/vaultwarden to a storage box or object storage, for example with Borg, from a nightly timer. Test a restore on a spare server once, so you know it works before you need it.

Keeping It Safe

  • Update regularly: docker compose pull && docker compose up -d.
  • Turn on two-step login for your account in the web vault.
  • Keep SSH to keys only, and nothing else open besides 80 and 443.
  • To keep the vault off the public internet entirely, reach it over WireGuard and give Caddy a certificate through a DNS challenge instead.

Common Questions

  • Is Vaultwarden the same as Bitwarden?

    No. Vaultwarden is an independent, open-source server written in Rust that speaks the same protocol as Bitwarden's, so the official Bitwarden apps and browser extensions work with it. It is not made or supported by Bitwarden, and it is far lighter than Bitwarden's own self-hosted server.

  • Why does Vaultwarden need HTTPS?

    The web vault uses the browser's Web Crypto functions, which browsers only allow on HTTPS pages. Without a certificate the web vault will not work, and passwords would cross the network unprotected. Caddy, used here, gets and renews a certificate by itself.

  • How much does it need to run?

    Very little: Vaultwarden itself uses tens of megabytes of memory for a family or a small team, so it fits on the smallest VPS alongside other services.

  • What happens if the server is lost?

    Apps keep a copy of your vault offline, but you cannot sync or add devices until the server is back. That is why the backup step matters: with a copy of the data folder you can rebuild on a new server in minutes.

Plans and prices

VPS Plans

KVM servers with full root access and a fixed IPv4 address: your passwords on a server only you run.

See all plans
  • Bronze

    3 vCPU · 6 GB RAM · 75 GB NVMe

    2 TB transfer

    $37.50/mo

    Configure inAshburnDallas
  • Silver

    4 vCPU · 8 GB RAM · 100 GB NVMe

    4 TB transfer

    $46.50/mo

    Configure inAshburnDallas
  • Gold

    6 vCPU · 12 GB RAM · 150 GB NVMe

    6 TB transfer

    $60.00/mo

    Configure inAshburnDallas
  • Diamond

    8 vCPU · 16 GB RAM · 200 GB NVMe

    8 TB transfer

    $73.50/mo

    Configure inAshburnDallas

Network port: 10 Gbps in Ashburn, VA, 50 Gbps in Dallas, TX. Pick the location when you configure.

Keep Reading

All guides