Skip to content

    Environment variable

    Reading time: 2 min.Editorially reviewed on:

    Definition

    An environment variable passes named settings from its execution environment to a program.

    An environment variable is a name-value pair in the environment of a process. Programs can read settings such as directories or connection addresses from it. Whether and when changes take effect depends on the runtime and the start of the program.

    Simply explained

    You give a program a note with settings at startup instead of rewriting its actual code for that purpose.

    Why it matters in practice

    Separating code and configuration makes it easier to have different settings for development, testing, and production operation.

    Example from business

    Possible example: An application reads the address of its test database from an environment variable and uses a different address in production.

    Limits and pitfalls

    • An environment variable is not an encrypted secret store. Values can become visible through logs, process accesses, or accidental output; running processes do not always automatically adopt changes.

    Origin & history

    Process environments are part of the operating system configuration. Programming languages provide interfaces to read these named values or to set them for further processes.

    Use in mid-sized companies

    • Organizations can document mandatory variable names, check required values at startup, and manage sensitive settings through appropriate provisioning processes.

    Frequently asked questions

    Is a .env file the same thing?

    No. It is a possible file for loading values; the environment variable itself belongs to the process environment.

    Sources

    Editorially reviewed on:

    On this page

    Next step

    Put knowledge into practice