Environments
A project's Env section is where you manage its environment variables — the values your application reads from the .env file at runtime. Open the project and pick Env in the menu beside the page.
How environment variables reach your application #
Depfloy writes your environment variables to shared/.env on the server. The active release symlinks this file in as current/.env, so when your application reads .env, it picks up whatever you set here. Changes apply on the next request without a full deploy — but for variables that are read at startup (queue workers, schedulers, Node.js processes), you’ll need to restart the relevant process for the new value to take effect.
When a deploy fails #
Depfloy writes shared/.env partway through a deploy, before the new release takes over — which
means that one step reaches the release that is serving right now. So if the deploy then fails,
is cancelled, or is rolled back after going live, the file goes back to what it held before the
deploy started. Your running application keeps the values it was already serving with, and a new
set of values becomes permanent only when a deploy completes.
NODE_ENV on Node.js projects
#
Depfloy starts a Node.js process with NODE_ENV=production. Frameworks like Next.js and React
Router pick their build from that variable, and an undefined NODE_ENV makes them load the
development build.
To run a project as something else, set NODE_ENV here as a normal variable — your value is the
one used, and it takes effect on the next deploy.
Edit the file #
The Env section is one editor holding the project’s .env file, one NAME=value per line. Add,
change or delete lines, then press Save. Pasting a whole .env file at once is the quickest way
to set up a new project.
APP_NAME=Laravel
APP_ENV=production
APP_KEY=base64:9aG+...
DATABASE_URL=postgres://...Quote a value that contains spaces (APP_NAME="Labs Office"); an unquoted one stops the next
deployment before the build starts.
Saving an empty editor removes every variable. Depfloy asks first, because the database
credentials and APP_KEY go with them.
History #
Every saved change to the file is kept, under History below the editor. Each entry shows when it was saved, who saved it, and how many variables it held — never the values themselves. Reading an old value means restoring it, and that is recorded.
Restore puts an entry back. Before it does, it tells you what the restore removes: a version saved before you added STRIPE_KEY does not merely lack it, it takes it out of the file. That is the half worth reading twice, so the dialog leads with it and names the variables.
Restoring is itself saved as a new version, so a restore can be undone the same way. The file is written to the server straight away, and your running application keeps its current values until the next deploy.
Depfloy keeps the last 50 versions per project and branch, dropping the oldest past that. An assistant connected over MCP can read this list and restore from it too, which is how a bad automated edit gets undone.
Editing the file manually via SSH #
If you SSH into the server and edit shared/.env directly, your changes do persist — but the next time someone saves the Env section, the entire shared/.env is rewritten from Depfloy’s view of the world. Use Depfloy as the source of truth; direct SSH edits are for emergency fixes only.