Vaultwarden 'Invalid admin token': Fix It and Switch to an Argon2 Hash
A Vaultwarden invalid admin token usually means the login does not match the stored ADMIN_TOKEN, or a plain text token is still in use. Generate an Argon2id hash, store that hash, and sign in with the original password.
In short
The admin page answers Invalid admin token, please try again. when the text you type does not match the stored token. A plain token also prints a startup notice that it is insecure. Generate an Argon2id hash with the official image, store the hash, and sign in with the original password. Plan on a few minutes.
Back up config.json before you edit it. Restoring that copy puts the old token back.
What you need
- Docker and the official image,
vaultwarden/serverorghcr.io/dani-garcia/vaultwarden. - Your Compose service name (
<service>), container name (<container>), and the host folder mounted at/data. - A long admin password. Write it down before you hash it.
Argon2id is a one-way hash. Vaultwarden stores the hash. You type the password that was hashed.
Read the two messages
On startup, a plain ADMIN_TOKEN prints:
[NOTICE] You are using a plain text `ADMIN_TOKEN` which is insecure.
Please generate a secure Argon2 PHC string by using `vaultwarden hash` or `argon2`.
See: https://github.com/dani-garcia/vaultwarden/wiki/Enabling-admin-page#secure-the-admin_token
A failed login writes Invalid admin token. in the log. The page shows Invalid admin token, please try again. A good hash starts with $argon2id$.
Make the hash
- Run the hash command. It asks for the password twice:
docker run --rm -it vaultwarden/server /vaultwarden hash
On a container that is already running:
docker exec -it <container> /vaultwarden hash
- Type the admin password both times. The default uses 64 MiB of memory, 3 iterations, and 4 threads. On a small machine, add
--preset owaspso it uses less memory.
You should see: one line that starts with $argon2id$.
Copy that whole line. Keep the password in a password manager. The next login uses the password, not this line.
Store the hash
Use one place, not both, so the two copies cannot drift.
A .env file uses a single $. Single quotes keep the dollar signs as dollar signs:
VAULTWARDEN_ADMIN_TOKEN='$argon2id$v=19$m=65540,t=3,p=4$...'
Point the Compose file at that name. Use your real service name in place of vaultwarden:
services:
vaultwarden:
image: vaultwarden/server
environment:
- ADMIN_TOKEN=${VAULTWARDEN_ADMIN_TOKEN}
Keep the quotes in .env. Do not also write $$ there. A doubled dollar sign is stored as $$, and Vaultwarden will not treat that as a hash.
Inline in docker-compose.yml, write each $ as $$. Compose treats $ as the start of a variable. $$ is one literal $. An Argon2 string has five dollar signs, so escape all five:
environment:
ADMIN_TOKEN: $$argon2id$$v=19$$m=65540,t=3,p=4$$...$$...
- Check the resolved file:
docker compose config
You should see: each $ printed as $$. That is how Compose prints a dollar sign. It is not a second edit.
If Compose warns The argon2id variable is not set. Defaulting to a blank string., a $ in the Compose file was read as a variable name.
config.json wins over the environment
The first Save on the admin page writes config.json in the data folder. Values in that file override the matching environment variables. An old plain admin_token there still wins after you change ADMIN_TOKEN.
- From the host folder mounted at
/data:
grep admin_token config.json
You should see: no file, or one "admin_token" line. A value that does not start with $argon2 is still plain text.
-
If the old token still opens
/admin, paste the PHC string into Admin token/Argon2 PHC and click Save. Then sign in with the password. -
To edit the file by hand, copy it first:
cp config.json config.json.bak
Change only admin_token. Use a single $ inside the quotes JSON already has. Do not add a second pair of quotes.
Warning: deleting config.json drops every other setting saved from the admin page. Do that only after those settings also exist as environment variables. Undo a bad edit by restoring the backup, then restart:
cp config.json.bak config.json
Check what the container sees
With the container running:
docker compose exec <service> printenv ADMIN_TOKEN
docker exec <container> printenv ADMIN_TOKEN is the same check. printenv shows the environment the container was started with. It does not show config.json.
You should see: one line that starts with $argon2id$, with no quotes and no $$.
Restart
- After an environment change, recreate the container. This does not remove the data volume:
docker compose up -d
- After a
config.jsonedit only, restart the service that already has the file mounted:
docker compose restart <service>
- Open
https://example.com/adminand type the original password.
You should see: the admin page opens, and the startup log no longer prints the plain-text notice.
Put that page on HTTPS. A name mismatch or a proxy pointed at the wrong scheme is covered in the certificate-name guide and the 502 guide.
Stay safe
- Treat the admin password like any other password. Anyone who has it can manage users on this server. Do not commit it or paste it into a chat.
- Turn on HTTPS before you enable the admin page, so the token is not sent in the clear. Keep
/adminbehind HTTPS on your reverse proxy.- Turn the page off when you are not using it. It stays off only when
ADMIN_TOKENis unset,DISABLE_ADMIN_TOKENis unset, andconfig.jsonhas noadmin_tokenkey. Recreate the container after that.- Do not set
DISABLE_ADMIN_TOKENunless a separate login already protects the page. That option removes the token check.- Changing the token does not sign out admins who are already signed in. To sign everyone out, copy
rsa_key.pemfrom the data folder torsa_key.pem.bak, delete the original, and restart. Restoring the backup is the undo. A new key is created on the next start if the file is gone.
If it doesn鈥檛 work
- You typed the hash into the login box. Type the password you gave
vaultwarden hash. printenvshows$$or quote marks. The escape was applied in the wrong file, or the quotes became part of the value. Fix that file, rundocker compose up -d, and check again.printenvshows a good$argon2id$line, but the plain-text notice is still in the log.config.jsonis overriding the variable. Edit that file, or set it from the admin page, then restart.docker compose configwarns thatargon2idis not set. Double each$in the Compose file, or move the value to a single-quoted.envline.- The notice is gone and the password still fails. The password and the hash are not a pair. Generate a new hash and store that string.
Spot something wrong or outdated? Leave a comment below. Every comment is reviewed to keep these posts accurate.
By commenting, you agree to our Terms of use and confirm this is your own work. Short quotes are fine with a credit and link. Copied, unsafe, or abusive comments are removed. See something copied? Say so here.