Homelab

How to Self-Host Vaultwarden on a VPS (Docker, Step by Step)

11 min read

How to Self-Host Vaultwarden on a VPS (Docker, Step by Step)

The Short Answer

Vaultwarden is a lightweight, open-source reimplementation of the Bitwarden server API, written in Rust, that works with the official Bitwarden browser extensions, desktop apps and mobile apps. To self-host Vaultwarden on a VPS you need four things: a small server (1 vCPU and 1–2 GB of RAM is enough for a personal or family instance), Docker with Compose, a domain name pointed at the server, and HTTPS in front of it. The recommended setup is one Docker Compose file running Vaultwarden behind Caddy, which obtains Let’s Encrypt certificates automatically. Create your account, then immediately close public signups, protect the admin panel with an Argon2-hashed token, and back up the data folder daily. The install takes under an hour; the discipline afterwards — backups, updates and a strong master password — is what makes it safe.

What Vaultwarden Is, and Why People Run It

The official self-hosted Bitwarden server is built for organizations: multiple containers, a real database server, and a heavier operational footprint. Vaultwarden fills the gap for individuals, families and small teams. It implements the same client API, so every official client connects unchanged — you just set the server URL in the app to your own domain instead of bitwarden.com. It ships as a single container, stores everything in one data folder, and uses a fraction of the memory.

There are honest trade-offs. Vaultwarden is not affiliated with Bitwarden, Inc., and asks users to report problems to Vaultwarden rather than Bitwarden support. A few enterprise features are missing or behave differently, and you take on full responsibility for updates, backups and uptime. In exchange you get premium-style features such as organizations, attachments and two-factor options without a subscription, and your encrypted vault never leaves hardware you control.

Option What you run Resource footprint Best for
Vaultwarden (self-hosted) One container + reverse proxy Very light; small VPS Individuals, families, small teams
Official Bitwarden server Multiple containers + SQL database Heavier; more moving parts Larger organizations wanting official support
Bitwarden cloud Nothing; vendor hosts it None People who don’t want to run a server at all

Before You Start: Prerequisites

You will need a VPS running a current Linux distribution with root or sudo access. Vaultwarden is famously light — a few dozen megabytes of RAM at idle — so 1 vCPU and 1–2 GB of RAM is comfortable, with room for the reverse proxy and other small services. If you are still choosing hardware, our guide to the best VPS for self-hosting walks through what to look for.

You also need a domain or subdomain, for example vault.example.com, with a DNS A record (and AAAA if you use IPv6) pointing at your server: Let’s Encrypt needs a name to issue a certificate for, and Vaultwarden needs to know its own public URL. If DNS is new to you, see how to point a domain to your VPS first.

Finally, install Docker Engine and the Compose plugin — our walkthrough on how to install Docker on a VPS covers it — and harden the box before putting passwords on it: SSH keys only, a firewall, automatic security updates. Our guide to securing your VPS covers that baseline. Ports 80 and 443 must be reachable from the internet for the certificate challenge below.

Why HTTPS Is Mandatory, Not Optional

Many self-hosted apps will grudgingly run over plain HTTP. Vaultwarden effectively will not. The Bitwarden web vault performs encryption in your browser using the Web Crypto API, and browsers only expose that API in secure contexts — meaning HTTPS (or localhost). Without a valid certificate the web vault cannot do its job, and the mobile apps additionally expect proper certificate chains and OCSP stapling. And the security argument is obvious: you are putting the keys to your digital life on this server.

The project recommends a reverse proxy that terminates TLS, rather than the TLS support built into its Rocket web framework, which it describes as not ready for production. The friendliest proxy for beginners is Caddy, because it speaks the ACME protocol natively: give it a domain and an email address and it obtains and renews Let’s Encrypt certificates on its own. Nginx with Certbot works too, but Caddy removes an entire category of renewal mistakes.

Step 1: Create the Project Folder and Compose File

Create a directory such as /opt/vaultwarden with a compose.yaml, based on the wiki’s Caddy example:

services:
  vaultwarden:
    image: vaultwarden/server:latest
    container_name: vaultwarden
    restart: unless-stopped
    environment:
      DOMAIN: "https://vault.example.com"
      SIGNUPS_ALLOWED: "true"
    volumes:
      - ./vw-data:/data

  caddy:
    image: caddy:2
    container_name: caddy
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
      - 443:443/udp
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - ./caddy-config:/config
      - ./caddy-data:/data
    environment:
      DOMAIN: "https://vault.example.com"
      EMAIL: "[email protected]"
      LOG_FILE: "/data/access.log"

A few details matter. DOMAIN must be the exact public HTTPS URL of your instance; Vaultwarden uses it for email links, attachments and WebAuthn/passkey flows, so a mismatch breaks features in confusing ways. The ./vw-data:/data volume holds everything — database, attachments, keys, configuration — so keep it on a local disk; the wiki warns against SQLite on CIFS/Samba shares, which lack the file locking SQLite needs. Note that Vaultwarden publishes no host ports: only Caddy is exposed, and Vaultwarden is reachable solely through the proxy on the internal Docker network. That is exactly what you want.

Step 2: Add the Caddyfile and Start the Stack

In the same folder, create the Caddyfile from the official example (no edits needed):

{$DOMAIN} {
  log {
    level INFO
    output file {$LOG_FILE} {
      roll_size 10MB
      roll_keep 10
    }
  }
  tls {$EMAIL}
  encode zstd gzip
  reverse_proxy vaultwarden:80 {
    header_up X-Real-IP {remote_host}
  }
}

The X-Real-IP header lets Vaultwarden log the real client address, which fail2ban needs if you later add brute-force protection. Then start everything:

docker compose up -d
docker compose logs -f

Watch the logs until Caddy reports it has obtained a certificate. If the ACME challenge fails, the usual culprits are DNS not yet propagated, port 80 blocked, or the domain pointing at a different machine. Then open https://vault.example.com — you should see the Bitwarden web vault login screen, served by your own server.

Prefer Nginx? The pattern is the same: bind Vaultwarden to localhost only (for example 127.0.0.1:8000:80), proxy to it with the standard X-Forwarded-* and WebSocket upgrade headers, then let Certbot (certbot --nginx) install the certificate. It works, but you own the renewal plumbing.

Step 3: Create Your Account, Then Close Signups

With SIGNUPS_ALLOWED: "true" anyone who finds the URL can create an account — fine for the next five minutes, dangerous after that. Create your own account now, with a long, unique master password. This password is the one secret Vaultwarden cannot recover for you: the vault is end-to-end encrypted, and if you forget it, your data is gone. Write it down somewhere safe and offline.

Then close the door: set SIGNUPS_ALLOWED: "false" and recreate the container with docker compose up -d. New users can now only join through an organization invitation. Also set SHOW_PASSWORD_HINT: "false" — by default Vaultwarden shows password hints on the login page, and the hardening guide recommends disabling that so hints cannot aid password guessing.

Step 4: Enable the Admin Panel — with a Hashed Token

The admin panel at /admin lets you manage users and organizations, invite people even when signups are closed, and view diagnostics. It is protected by one secret, the ADMIN_TOKEN. Rather than storing it in plaintext, store an Argon2id hash of it, so the secret never sits in your config files. The image includes a helper:

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

Type your chosen admin password twice and it prints a PHC string beginning $argon2id$.... Put that string in the Compose file as ADMIN_TOKEN. One Compose gotcha: dollar signs trigger variable interpolation, so in the environment: section you must double every $ to $$. (In a separate .env file, use single dollar signs in single quotes instead, and verify with docker compose config.) Log in at /admin with the original password, not the hash. Two notes from the wiki: admin sessions are JWTs with a default 20-minute lifetime, and saving settings from the panel writes a config.json that overrides environment variables from then on. Decide early whether you configure via environment variables (recommended) or via the panel, and stick to one.

Step 5: Configure SMTP So Email Features Work

Vaultwarden runs without email, but several features depend on it: organization invitations, email verification, password-hint emails and emergency-access notifications. If you will share the instance, configure SMTP now via the standard variables — SMTP_HOST, SMTP_PORT, SMTP_SECURITY (for example starttls), SMTP_USERNAME, SMTP_PASSWORD, SMTP_FROM, SMTP_FROM_NAME — in the Compose environment or the admin panel. Use a real mailbox or transactional mail provider rather than sending from the VPS directly; VPS IP ranges have poor mail reputation and invites will land in spam. Use the panel’s test-email button to confirm delivery (click Save first — unsaved changes are not applied to the test).

Step 6: Connect the Official Clients

Install the Bitwarden browser extension, desktop app or mobile app as usual, but before logging in, change the server URL in the login screen’s self-hosted option to https://vault.example.com, then sign in. Everything — sync, autofill, attachments, Sends — works as on the cloud service. Enable two-factor authentication immediately (an authenticator app at minimum), and export your vault once now, storing the encrypted export somewhere safe as a last-resort copy.

Step 7: Back Up the Data Folder Properly

Everything that matters lives in the data folder (./vw-data):

  • db.sqlite3 — accounts, vault items, metadata. Backup required.
  • attachments/ — file attachments as separate files. Backup required.
  • sends/ — Send attachments; optional.
  • config.json — admin-panel settings; recommended, but it can hold plaintext secrets, so encrypt backups containing it.
  • rsa_key* — login-token signing keys; recommended. Losing them logs everyone out and kills pending invitations; encrypt the private key in backups.
  • icon_cache/ — favicons; skippable.

Do not cp a live SQLite database. Use SQLite’s online backup (.backup or VACUUM INTO) or Vaultwarden’s built-in command (since 1.32.1):

docker exec vaultwarden /vaultwarden backup

A practical routine: run that backup daily from a cron job on the host (the container has no cron daemon), archive the data folder with restic or rclone, encrypt it, and copy it off the server — a backup that only exists on the same VPS is not a backup. The wiki also warns against relying on filesystem or VM snapshots alone. Finally, test a restore: stop the container, replace the data folder with your backup (deleting any stale db.sqlite3-wal when restoring a .backup-style copy), start it and confirm you can log in. An untested backup is a hope, not a plan.

Step 8: Keep It Updated and Hardened

Updates are simple: docker compose pull && docker compose up -d fetches the newest image and recreates the container. Do this regularly — a password manager is the last service you want running stale code — and back up first.

For extra hardening: run the container as a non-root user (user: 1000:1000, with the data folder owned accordingly) if you are comfortable managing permissions; mount only what Vaultwarden needs, never the Docker socket; consider fail2ban against the Vaultwarden log to throttle password-guessing (the X-Real-IP header from Step 2 makes this accurate); and serve the instance only under its proper hostname, not by raw IP, since IP-scanning services make IP-exposed instances easy to find. None of this replaces the fundamentals: a strong, unique master password and two-factor authentication on every account.

FAQ

Is Vaultwarden really compatible with the official Bitwarden apps?

Yes. Vaultwarden implements the Bitwarden client API, so the official extensions, desktop and mobile apps connect unchanged once you set your server URL. It is an independent project, not affiliated with Bitwarden, Inc., so report problems to Vaultwarden, not Bitwarden support.

How big a VPS do I need?

Very small. For a personal or family instance, 1 vCPU and 1–2 GB of RAM is plenty, with a few gigabytes of disk. Vaultwarden runs comfortably where the official multi-container server would feel cramped.

Can I run it without a public domain?

You still need a name for the certificate. For a private instance, use a DNS challenge (for example Duck DNS) to get a Let’s Encrypt certificate without exposing the server, as the wiki’s example shows. A self-signed private CA is possible but brings pitfalls, especially with mobile apps.

What happens if I forget my master password?

Your vault cannot be recovered — that is the point of end-to-end encryption. Neither Vaultwarden nor the admin panel can reset it. Keep the master password long, unique and written down offline, and maintain tested backups.

Should I use the admin panel or environment variables for settings?

Either works, but not both carelessly: once you save from the panel, config.json overrides environment variables. The wiki recommends environment variables as the primary method; use the panel mainly for user management and diagnostics.

The Bottom Line

Self-hosting Vaultwarden is one of the highest-value projects you can run on a small VPS: one container, automatic HTTPS through Caddy, and the full official Bitwarden client experience on your own hardware. The install is the easy part. What makes it trustworthy is the follow-through — signups closed, a hashed admin token, SMTP configured before you invite anyone, daily encrypted backups stored off-server and test-restored, updates applied promptly. Do those things and a modest server becomes a password manager you genuinely own.

Sources: Vaultwarden project wiki — Using Docker Compose, Enabling HTTPS, Enabling admin page, Configuration overview, Backing up your vault, Hardening Guide (github.com/dani-garcia/vaultwarden/wiki), checked November 28, 2026.

One response to “How to Self-Host Vaultwarden on a VPS (Docker, Step by Step)”

Leave a Reply

Your email address will not be published. Required fields are marked *