Get a free website with any plan

See how
APPLICATIONS

Node.js environment variables

Last updated

IN SHORT

Node.js applications on Flashcloud read environment variables through the Setup Node.js App tool in cPanel rather than a project .env file. The system injects these name and value pairs into process.env when the process starts. You must restart the application after saving changes for new values to take effect.

Node.js apps on Flashcloud read their environment variables from the Setup Node.js App tool in cPanel, not from a .env file sitting in your project folder. If your app reads process.env.SOMETHING and it's coming back undefined, check the app's configuration screen in cPanel first.

This is different from how most local Node.js tutorials set things up. Here's how it works on a Flashcloud account.

Setting variables in Setup Node.js App

Log into your account and open cPanel, then find Setup Node.js App under the Software section. Click into your application (or create one if you haven't yet), and add your environment variables there as name/value pairs.

Add each variable as a name/value pair: things like DATABASE_URL, API_KEY, NODE_ENV, or any config value your app expects. There's no limit on how many you add beyond what's reasonable for an app config.

Node.js reads environment variables once, at process start, into process.env. On most hosting accounts, editing them updates the stored configuration but doesn't touch a process that's already running - the app keeps using the old values until it's restarted.

Why not use a .env file

You can still ship a .env file in your project and load it with a package like dotenv if your app is built that way. But treat the cPanel environment variables panel as the source of truth for anything that changes between deploys or that you don't want committed to your repository: database credentials, API keys, secrets. A .env file sitting in your app directory is also a file that could get served or backed up alongside your code, which is a bad place for a secret to live. The cPanel panel keeps those values out of your files entirely.

If you use both cPanel's variables and a loaded .env file, decide which one wins in your app's startup code. Most setups let process.env values that are already set (from cPanel) take priority, since dotenv by default won't overwrite a variable that's already defined.

Common symptoms of a missing variable

  • App crashes on startup with something like TypeError: Cannot read properties of undefined when your code does process.env.DATABASE_URL.something.
  • App starts fine but silently falls back to defaults, connecting to the wrong database or running in the wrong mode.
  • Changes you made in cPanel don't seem to take effect, because the app wasn't restarted after the edit.

Check the variable name for typos first. Node.js does exact, case-sensitive matching on process.env keys, so Database_URL and DATABASE_URL are two different, unrelated things as far as your app is concerned.

Restarting after changes

On most hosting accounts, you'll need to restart your Node.js app after you:

  1. Add, remove, or edit an environment variable.
  2. Change the Node.js version for the app.
  3. Update the application's startup file or entry point.
  4. Pull new code that reads a variable you haven't set yet.

If you deploy through cPanel's Git Version Control tool, restart the Node.js app as a separate step after the pull completes.

When to contact support

If you've set the variable, restarted the app, and it's still not showing up in process.env, open a ticket from Support in the portal. Include the app's domain, the variable name you're expecting, and what your startup logs show. A real person will check the underlying Node.js app configuration with you rather than guessing from the outside.

Common questions

Why is my environment variable returning undefined?

You likely need to restart your application or fix a typo. Node.js only loads environment variables at startup, and variable names are strictly case-sensitive. Check your configuration in cPanel to confirm the key matches your code.

Can I still use a .env file on Flashcloud?

Yes, you can load a local file using a package like dotenv. Store sensitive credentials in cPanel instead so they remain excluded from your repository and backups. By default, variables defined in cPanel take priority over .env files.

Do I have to restart my app after updating a variable?

Yes, a restart is required. Node.js reads variables into memory only when the process launches. The running application will continue using the old values until you restart it.

Why did my changes fail to apply after pulling new Git code?

Deploying code through Git Version Control does not restart your application. If your new commit references updated variables or startup files, restart the app in cPanel as an independent step.

CAN'T FIND IT?

Real humans answer fast.

Hosting with us? Open a ticket and a real person replies - no scripts, no upsells. Still choosing a host? The same team is included with every plan, from day one.