Skip to main content

How Work Gets Done

Environment Variable

Environment variables hold settings and credentials outside the code, so passwords never end up in your repository. Where they are stored is the whole question.

Definition

An environment variable is a setting supplied to an application from outside it, rather than written into the code.

What It Actually Means

The same application then behaves differently depending on where it is running. On a developer’s machine it connects to a local database; in production it connects to the real one; and the code is identical in both. What changes is the configuration around it.

Why This Exists

Two reasons, and the second is the one that matters commercially.

The same code runs everywhere. No separate versions for testing and live, which removes an entire category of “it worked in testing” problems.

Credentials stay out of the codebase. Database passwords, API keys, payment provider secrets. These must not be written into code, because code goes into a repository, repositories get cloned, shared, and occasionally made public by accident.

Credentials committed into a repository persist in its history even after being removed from the current files, and automated scanners search public repositories for exactly this, continuously, so an exposed key can be found very quickly.

Where They Actually Live

In practice, in a file, usually named .env, sitting on the server and excluded from version control. That works and it has a few well-known failure modes worth asking about.

It is excluded but the exclusion was added late. The file is not in the current version and is still in the history. Removal from the repository is not enough; the credential has to be rotated.

It ends up backed up or copied. Server backups, deployment archives and machine images all pick it up, and those are protected less carefully than the server.

Nobody knows what the values are. The file exists on the server, was configured once, and there is no other record. If the server is lost, so are the settings, and reconstructing them means going to each provider in turn.

It gets shared over chat. Someone needs to run the system locally, the file is pasted into a message, and it remains in that chat history permanently.

What To Ask

  • Are any credentials in the code repository, now or in the history? If yes, rotate them rather than only deleting them.
  • Where is the authoritative record of production configuration? There should be one, in a password manager or a secrets service, not only on the server.
  • Do development and production share any credentials? They should not. A leak from a developer’s machine should not reach live data.
  • How do we rotate a credential? If nobody knows which systems use it, it will never be changed, including after somebody leaves.

The Step Up

For a small system, a file on the server with a copy of the values in a password manager is reasonable and is more than most businesses have.

Beyond that, hosting providers and cloud platforms offer secrets management: values stored centrally, encrypted, access controlled and logged, rotated without touching the server. Worth moving to when there are several environments, several people, or anything with a regulatory dimension.

The failure to avoid is the middle state, where credentials exist in several places and nobody is certain which copy is current.

More terms are in the glossary.

Portrait of Alexander De Sousa, founder of Digital Royalty
Founder-led
“I’ve put everything I know into how this company works — the standards, the method, the care on every project. It runs through the whole team, and I hold us all to it.”

Alexander De Sousa · Founder LinkedIn

Featured on BBC Radio Solent

Get started

Tell us what you need

A few quick questions, then a straight answer from a real person — usually within a few hours.

What happens next

  1. 1 We reply A real person reads your answers and gets back to you, usually within a few hours.
  2. 2 Questions or a short call If anything isn't clear, we ask by email or book a short call. Before any call we audit your website and make the quick fixes it finds, free.
  3. 3 Your fixed quote A clear, fixed price in writing, within 48 hours of any call. There is no obligation to go ahead.

Tell us what you're working on

Whether it's a new site, a platform, or a process that shouldn't be manual any more — we'll tell you honestly if we can help.