deploys
Never move a Python virtualenv
Its scripts hard code the interpreter path, so gunicorn exits 203 and the API answers 502 for as long as it takes you to read the unit file.
The deploy built a release directory, created the virtualenv inside it, then moved the venv into place beside the application. Gunicorn failed with status=203/EXEC and the API returned 502 for about two minutes.
The shebang is absolute
Every executable in a virtualenv's bin/ carries a shebang pointing at the interpreter by absolute path. bin/gunicorn starts with the full path to the python that created it. pyvenv.cfg records absolute paths too.
Move the directory and none of that follows. The shebang points at a path that no longer exists, the kernel cannot exec it, and systemd reports 203. There is no warning at move time because mv has no idea it is breaking anything.
$ systemctl status app
* app.service - app gunicorn
Active: failed (Result: exit-code)
Process: 2114 ExecStart=/opt/app/backend/.venv/bin/gunicorn (code=exited, status=203/EXEC)Build it where it will live
The fix is not a repair step, it is an ordering change. Build each release's venv at its final path and switch a current symlink when it is ready:
rev=2026-11-29-a1b2c3
python -m venv /opt/app/releases/$rev/.venv
/opt/app/releases/$rev/.venv/bin/pip install -r requirements.txt
ln -sfn /opt/app/releases/$rev /opt/app/currentThe venv is never moved. The symlink moves instead, which is atomic, and rolling back is pointing it at the previous release.
If you have already moved one
Delete it and rebuild. --relocatable existed once, it was never reliable, and it is gone. Rebuilding from a lockfile takes less time than reasoning about which paths got rewritten.
※