Skip to main content
Environment variables hold API keys, database URLs, and settings. Pxxl gives them to your build and to your running app.

Add a variable

1

Open Secrets

Open the project and select Secrets.
2

Add it

Choose New Variable, enter the name and value, and pick a scope.
3

Redeploy

Running apps only read variables when they start. Redeploy to apply the change.
Use Bulk Edit to paste a whole .env file. History shows past changes.

Scopes

Vault

The workspace Vault stores a secret once for all your projects (paid plans). Open Vault in the sidebar and add a secret. Then reference it in any project variable:
Pxxl fills in the value at deploy time. Change it in the Vault and redeploy to update every project that uses it. You can put a reference inside a longer value, such as postgres://app:{{vault.DB_PASSWORD}}@host/db. Pxxl first looks for the secret in the project’s environment, then in All environments. If the secret doesn’t exist, the deploy fails and names it. Vault names use capital letters, numbers, and _, up to 128 characters. Values can be up to 32 KB.

Use another project’s value

Reference a variable from another project in the same group (the main project and its services):
The form is ${<project name or id>.<KEY>}. Pxxl copies the value at deploy time. A reference it can’t resolve stays as plain text, so check the spelling. A plain ${KEY} with no dot is not expanded. The value field on Secrets has a picker for Vault secrets and other services’ values, so you don’t have to type these.

Names and limits

  • Names start with a letter or _, then letters, numbers, and _. Up to 256 characters.
  • Values can be up to 32,768 characters.
  • Bulk Edit strips one pair of quotes around a value.
  • No names are reserved. You can override PORT and most variables Pxxl sets (see below).

From the CLI

See CLI commands for every pxxl env command.

Build and runtime

Which value wins

From lowest to highest:
  1. [env] in pxxl.toml (build only).
  2. Global variables.
  3. Project variables.
  4. References are filled in: ${service.KEY}, then {{vault.KEY}}.
At runtime your variables always beat the defaults built into the image.

Variables Pxxl sets

Every project

These are saved as normal variables when the project is created. You can see and edit them in Secrets.

Defaults in the running app

Set only if you haven’t set them yourself:

Framework defaults at build time

When you attach a database

Choosing Add DATABASE_URL saves DATABASE_URL as a secret global variable, for example postgresql://user:pass@host:5432/db. A project-level DATABASE_URL overrides it.

Functions

Functions deploys get these. They always replace a variable with the same name.

Multiple services in one container

Each service process gets its own PORT, EXPOSE_PORT, LISTEN_PORT, SERVER_PORT, and HOST=0.0.0.0. These can’t be overridden for that process.

WordPress

WordPress projects get WORDPRESS_DB_HOST, WORDPRESS_DB_NAME, WORDPRESS_DB_USER, WORDPRESS_DB_PASSWORD, and WORDPRESS_CONFIG_EXTRA set for you. Your own values for these, and MYSQL_* or MARIADB_*, are ignored.

pxxl dev

pxxl dev runs your app with the project’s variables, plus: Your shell’s variables beat the project’s.

What Pxxl doesn’t set

There’s no NODE_ENV, CI, commit SHA, branch name, project id, region, or public URL variable. Set the ones you need yourself, for example:

Good habits

  • Never commit .env files. Add them to .gitignore and .pxxlignore.
  • Frontend frameworks put some variables into browser code (for example VITE_*, NEXT_PUBLIC_*). Only use those prefixes for values that are safe to show the public.
  • Don’t put secrets in pxxl.toml. It’s committed with your code.