Problem: Secret Rotation Logs Everyone Out
Symptoms
- After changing
PROXYOS_SECRETin.envand restarting the container, all users are logged out - The login page is shown for all users even though they were previously logged in
- Session cookies are present in the browser but the server rejects them with 401
Why this happens
This is expected behavior, not a bug.
PROXYOS_SECRET is used by better-auth to sign session tokens. When you change the secret, all previously issued session tokens are signed with the old secret and can no longer be verified. The server rejects them as invalid, effectively logging out everyone.
There is no partial migration — all active sessions become invalid the moment the container restarts with a new secret.
When this happens unintentionally
The most common unintentional cause is accidentally changing PROXYOS_SECRET:
- Copy-paste error when editing
.env - Regenerating
.envfrom a template without preserving the existing secret - A deployment tool that overwrites
.envwith a freshly generated value - Volume being lost — if the secret was stored in a volume that was deleted, a new secret is generated
Diagnosis
Confirm the secret changed:
# If you have a backup of the old .env
diff .env.backup .env | grep PROXYOS_SECRET
Check container logs for any authentication errors that started at the restart time:
docker compose logs proxyos --since="restart-time" | grep -i "auth\|session\|invalid"
Fix
If the logout was intentional (you changed the secret deliberately)
All users simply need to log in again. The new sessions will be signed with the new secret and work correctly.
If the logout was accidental (you want to restore the old secret)
-
Retrieve the old secret from:
- Your secrets manager (Vault, LockBoxOS, etc.)
- A backup of
.env - Git history (if
.envwas accidentally committed — you should also rotate the secret if this happened)
-
Restore the old value in
.env:PROXYOS_SECRET=old-value-here -
Restart the container:
docker compose up -d --force-recreate
Existing session cookies will work again.
Prevention
- Store
PROXYOS_SECRETin a secrets manager, not just in.env - Never commit
.envto version control - When updating
.envfor other reasons, explicitly preserve thePROXYOS_SECRETvalue - Keep a secure backup of
PROXYOS_SECRETseparate from the compose file - Document in your runbook that changing this value is a breaking change for active sessions