Skip to main content
Environment variables are the standard way to pass configuration and secrets (database credentials, API keys, feature flags) to your app without hardcoding them.
Running a 1-Click App? Use instapods env set - it writes to the app’s own config file and restarts the app automatically. The .env-in-app-directory approach below is for custom-code pods (Static, PHP, Node.js, Python).

Setting Environment Variables

Set one or more variables straight from the CLI:
List or remove them later (values are masked unless you pass --show-values):
For custom-code pods this writes to your app’s .env file - run instapods pods reload afterward to restart. For 1-Click Apps it targets the app’s own config file and restarts the app for you.

Option 2: Create a .env File

The manual approach — create a .env file in your app directory via the CLI:
Then reload to pick up changes:

Option 3: Set at Pod Creation (API)

Pass environment variables when creating a pod via the API:
Variables set this way are written to /etc/environment and automatically available to all processes.

How Each Preset Reads Environment Variables

Node.js

The systemd service sets NODE_ENV=production by default. Variables from /etc/environment are inherited automatically. For .env files, use the dotenv package:

Python

Variables from /etc/environment are inherited by the systemd service automatically. For .env files, use python-dotenv:

PHP

PHP-FPM provides access to system environment variables via getenv(). For .env files, parse them manually or use a library:
For Laravel, the framework handles .env files automatically — just create the file and it works.

Static

Static sites don’t run server-side code. For JavaScript apps that need configuration, use a config.js file:

Common Pattern: Database Credentials

After installing a database service, get the credentials and set them as env vars:

Updating Variables

To update environment variables after pod creation:
The .env file is stored inside your pod. If you delete the pod, the file is lost. Keep a copy of your environment variables in a secure location.

Best Practices

  • Never commit secrets to git — always use .env files or environment variables
  • Use defaults in code — Always provide fallback values (process.env.PORT || 3000)
  • Reload after changes — Run instapods pods reload after updating .env to restart the app
  • Separate configs — Use different .env files for development vs production