After deploying a Node.js application on Hostinger, you can edit existing environment variables or add new ones at any time.
Before you start
- If you haven’t deployed your Node.js application yet, see how to deploy a Node.js website in Hostinger.
- You can also add environment variables while deploying the application instead of adding them afterward.
Edit Environment variables
-
Open your Website Dashboard.
-
Navigate to the Environment variables section.
- You can add new or edit existing environment variables there.
Click Apply changes to save the new variables.
Once your environment variables are applied, your Node.js application runs with the updated configuration. If the app still uses the old values, check the type of variable:
- Build-time variables, such as those starting with
NEXT_PUBLIC_orVITE_, are added to your app during the build. Redeploy the application to apply them. - Runtime variables, such as database credentials or API keys, are read when the app starts. Restart the app from the website dashboard to apply them.
If the website still shows old behavior after a redeploy, see how to fix changes not showing after a Node.js deployment at Hostinger.
Troubleshoot environment variables
Most environment variable problems come from four causes: a delayed save confirmation, quoted values, special characters, or a conflicting .env file.
- If a Failed to save deployment settings error appears, refresh the page and check the list before trying again. The variables are often saved even when the error appears.
- Paste values without surrounding quotes.
- Double-check values that contain
$,#, or line breaks after saving. - Remove or update any
.envfile committed to your repository, because it can conflict with the variables set in the Hostinger dashboard.
The Hostinger dashboard doesn’t keep a history or backup of environment variables. Keep your own copy of the values in a secure place.
When to update environment variables
You may need to update environment variables when:
- Adding new configuration values
- Updating database credentials
- Rotating API keys or secrets
- Changing environment-specific settings
Keeping your environment variables up to date ensures your Node.js application always runs with accurate, secure configuration. Runtime variables apply after a restart, and only build-time variables need a full redeployment.
