My API keys didn't reach the server. Why?

Your keys stayed behind. Keys you typed into your builder, or saved in a .env file on your computer, do not travel with your code: the .env file is normally kept out of Git, and many builders keep editor secrets apart from the published app. You have to add each key again where the live app runs, using the exact same name, and then publish or deploy again.

Last checked 3 December 2026

Fix it in four steps

  1. Find the exact names your code expects.

    Search your code for the key names (for example OPENAI_API_KEY). The name on the server must match letter for letter, including capitals.

  2. Add the keys where the live app runs.
    • In a builder: look in the publishing settings, not the editor. In Replit they are under Publishing, then "Adjust settings", then "Production app secrets".

      Source: Replit Docs, "Secrets"

    • On your own server with Docker Compose: a container gets no settings unless the Compose file says so. Docker's documentation: "A container's environment is not set until there's an explicit entry in the service configuration to make this happen." Point the service to your file with env_file: .env, or list the values under environment:. The Docker Compose Generator writes an .env.example that lists every value to fill in.

      Source: Docker Docs, "Set environment variables within your container's environment"

  3. Publish or deploy again.

    A running app does not pick up a key you add later. Start a new deploy so the app starts with the new values.

  4. Keep secret keys out of the browser.

    Some names are made public on purpose. In Vite, variables that start with VITE_ "will be exposed in client-side source code", and Vite warns they "should not contain sensitive information such as API keys". In Next.js, variables that start with NEXT_PUBLIC_ are "inlined into the JavaScript bundle during next build". Both are fixed when the app is built, so changing them later means building again. Keep secret keys without these prefixes and use them only in server code. If a secret key ever had one of these prefixes, treat it as public and create a new one.

    Source: Vite, "Env Variables and Modes"

    Source: Next.js, "How to self-host your Next.js application"

Check that it worked

Open the live app and use the feature that needs the key. Then read the live app's logs. An empty or "undefined" key means the name or the place is still wrong. The "Secrets" part of the Production readiness checklist covers the rest: no secret in the Compose file, .env readable by its owner only, and no secret baked into an image.

Common mistakes

  • Uploading the .env file to GitHub to "bring the keys along". Anyone who can see the repository can see the keys. Vite's documentation advises adding local env files (*.local) to .gitignore so they are not checked in.
  • Adding the key in the editor only. The live app reads its own settings (the second step).
  • A public prefix on a secret key. VITE_ and NEXT_PUBLIC_ values reach every visitor's browser (the fourth step).
  • Not deploying again. The app keeps running with the old values (the third step).

Limits

  • Builder examples come from Replit's documentation; other builders name these screens differently.
  • This guide does not cover secret managers or rotating keys on a schedule.
  • Never paste a secret key into a tool or chat you don't control. ANAROQ does not host your app.

Related pages