# Vaultwarden TLS recovery after certificate change

LLMS index: [llms.txt](/en/llms.txt)

---

Lead paragraph: After changing the TLS certificate, Vaultwarden stops serving HTTPS traffic despite the container still running. Recreating the container isn't necessary — just update the certificate paths in compose and perform manual certificate regeneration inside the running process. This note delivers the minimal command cycle, key-flag table, and verified recovery sequence.

## 1. Preparation and data backup
Before changing certificates, back up the Vaultwarden data directory, typically mounted as `/data` or `/opt/vaultwarden`. Any configuration change is risky, and a backup lets you roll back without losing user records.
Typical backup command: `tar -czf vaultwarden-data-$(date +%F).tar.gz /path/to/vaultwarden/data`
Save the archive to a reliable location before proceeding.

## 2. Changing TLS certificate in compose
Open `docker-compose.yml` (or `.env`) and update the certificate mounts pointing to where new `cert.pem` and `key.pem` files reside on the host, mounted as `/data` inside the container. The paths must reference the new files on the host machine.
Key flags and TLS settings for Vaultwarden compose:

| Flag | Purpose | Example |
|------|---------|--------|
| `-cert-path` | Path to TLS certificate | `/data/cert.pem` |
| `-key-path` | Path to private key | `/data/key.pem` |
| `-regen-certs` | Regenerate certificates inside the process | `docker exec ...` |
| `-check-config` | Verify config correctness before startup | `vaultwarden -check-config` |

After updating the host paths, proceed to manual regeneration inside the container to apply the new files without a restart.

## 3. Manual certificate regeneration inside the container
Certificates can be regenerated directly in the running container without stopping the service. Use the practice-proven command:
`docker exec vaultwarden vaultwarden -cert-path /data/cert.pem -regen-certs`
This overwrites `cert.pem` and `key.pem` in the mounted `/data` directory if the container has write access. Important: avoid using `certbot` inside the container without stopping the service, otherwise file-lock conflicts may arise.
If the mounted volume has `ro` (read-only) mode, first stop the container, replace the files on the host, then start it again, leaving `docker exec` for regeneration when mounting is `rw`.

## 4. Configuration check and restart
After regenerating certificates, verify the configuration before restarting:
`vaultwarden -check-config`
If the check passes, restart the container to apply changes:
`docker restart vaultwarden`
*Caution note:* avoid `docker compose up -d` without `-force` if volume structures changed. Since we're only updating content in existing `/data` files, plain `docker restart` is sufficient and doesn't require recreating volumes.

## 5. Validation of operability
Open a browser or check via `curl`:
`curl -k https://your-domain.com`
Ensure the connection establishes and the certificate displays correctly. Check container logs for any TLS-handshake errors:
`docker logs vaultwarden`
Finally, confirm file validity via `openssl`:
`openssl x509 -in /data/cert.pem -text -noout | head -5`
If no errors and the server responds correctly, the TLS certificate recovery is complete.
