ServerAvatarDocs
Applications

Environment

Edit an application's .env file with live checks, restart the app when you save, and look at the history or restore an earlier snapshot.

The Environment screen edits the application's .env file, the file that holds its settings and secrets such as database passwords and API keys. Open an application, then select Environment in its sidebar, under Settings.

Not every application has it. The screen is there for Git applications, Node.js applications and a few one-click apps (Craft CMS, Statamic, Mautic and Akaunting). Other types say "This application type doesn't use a .env file."

The Environment screen: the editor for the .env file with its path, the Restart the app after saving switch with Discard and Save and restart, and the Snapshots and History sections

Edit the file

  1. Open Environment. The file loads in the editor. If it does not exist yet the screen says "There is no .env file yet. Saving creates it."
  2. If the file has secrets, their values are shown as dots: "Secret values, such as keys and passwords, are hidden. Choose Show and edit to change the file." Select Show and edit to reveal them and edit. Hide secrets hides them again.
  3. Change the lines, one NAME=value per line, for example APP_ENV=production.
  4. Watch Checks while you type. It lists problems with a level: Danger, Error, Warning or Info, or says "No problems found."
  5. Decide about the restart. On an application that has to restart to read the new values (for example a Node.js app), Restart the app after saving is on by default and the button says Save and restart. Turn it off to keep the app running with the old values: "The app keeps the old values until it restarts."
  6. Select Save (or Save and restart). You see "Environment saved." plus a note when something else was done: "The config cache was cleared." or "The app was restarted."

A Discard button throws away your edits.

If the server finds a blocking problem it refuses the save and says "This file can't be saved:" with the reasons. Fix them and save again.

When the file can be downloaded from the web the screen warns "This file can be downloaded from the web. Set a web root for the application." Fix this in Application settings by setting the Web root to the folder your site serves, such as /public.

If the file cannot be read again after a change you see "The .env couldn't be reloaded. Showing the last loaded version."

A framework that caches its configuration (a Laravel site, for example) keeps the old values until the cache is cleared: "A config cache exists; the save clears it so the new values are used."

Snapshots

A snapshot of the file is taken before every save: "A snapshot is taken before every save. The last 20 are kept." Under Snapshots:

  1. Find the snapshot by its date and select Restore.
  2. Read Restore the snapshot from date**?** "The current file is saved as a snapshot first, so you can undo this." Confirm. You see "Snapshot restored."

"No snapshots yet." shows until the first save.

History

History lists every save and restore of the file: who made it, whether it was Edited or Restored, and how many variables changed ("n variables"). Changes made by the system are marked System. "No changes recorded yet." shows when there are none. Select Load more to see older entries.

To compare, select View changes on an entry. Changes shows each variable as Added, Changed or Removed. Values of secret variables are not shown: they read "changed (hidden)". If the snapshot for an entry has been removed from the server: "The snapshot for this change is no longer on the server."

Limits

  • The file can be up to 262,144 characters (256 KB).
  • The server keeps the last 20 snapshots.
  • A history page lists up to 100 entries at a time.

Who can do this

  • Even opening the file needs Manage on Environment (application.environment): "Only members who can manage the environment can open this file." There is no view-only access.
  • Environment can be given in a server share, with manage.
  • Every save and restore is recorded in the server's activity log. See Application activity.

Common errors

  • This application type doesn't use a .env file. Only some application types have it.
  • We couldn't read the environment file from the server. Select Retry.
  • The server isn't ready yet. The server is offline or still being set up.
  • The server didn't accept the change. The server refused the file. Its own reason is shown with it.
  • Your role can't change the environment. Ask an owner for Manage access.

On this page