{
  "id": 11350300,
  "title": "DEBUG=false but my app still runs in debug mode: why an environment variable \"false\" is true",
  "url": "https://urgent.news/2026/10/02/debug-false-but-my-app-still-runs-in-debug-mode-why-an-environment",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-02T03:47:39.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/jaytank/debugfalse-but-my-app-still-runs-in-debug-mode-why-an-environment-variable-false-is-true-575l"
  },
  "original_language": "en",
  "account": "Despite setting the DEBUG variable to false in a .env file and restarting the application, it still operates in debug mode. This perplexing issue is due to the nature of environment variables, which always consist of string values. In programming languages like Python, Node, and Vite, environment variables are returned as text, not as booleans or numbers. Consequently, the false value, being a non-empty string, is considered truthy. When you attempt to convert an environment variable to a boolean using os.getenv or process.env in Node, the result is always true for any variable set to \"false\". Similarly, using int(os.getenv) or JSON.parse(process.env.X) leads to errors when the variable is missing. To resolve this, read the environment variable as a string and explicitly convert it to the desired type when needed. For instance, setting DEBUG = os.getenv('DEBUG', '').strip().lower() in ('1', 'true', 'yes', 'on') ensures that the variable is treated as a string and only converted to a boolean if explicitly set to one of the specified truthy values. Similarly, converting WORKERS to an integer with int(os.getenv('WORKERS', '4')) provides a default value of 4 when the variable is unset. By following these guidelines and treating only flags as parsed values, you can avoid the common pitfalls associated with environment variables.",
  "summary": "You put DEBUG=false in .env , restart, and the app is still in debug mode. If you have searched \"environment variable false is true\" or \"os.getenv boolean\", here is the whole explanation: an environment variable is always a string, and \"false\" is a non-empty string, so it is truthy. Python's os.getenv , Node's process.env and Vite's import.meta.env all hand you text, never a bool or a number.…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}