{"id":7251,"date":"2026-01-08T11:02:52","date_gmt":"2026-01-08T11:02:52","guid":{"rendered":"https:\/\/www.hostinger.com\/support\/?p=7251"},"modified":"2026-09-29T03:41:04","modified_gmt":"2026-09-29T03:41:04","slug":"how-to-add-environment-variables-during-node-js-application-deployment","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/how-to-add-environment-variables-during-node-js-application-deployment\/","title":{"rendered":"How to add environment variables during Node.js application deployment"},"content":{"rendered":"<p data-renderer-start-pos=\"75\" data-local-id=\"cab7cf17-39cc-4a94-be29-434bb27e7825\">When <a data-click-id=\"hgr-post-content-link-deploying-a-node-js-application\" href=\"https:\/\/www.hostinger.com\/support\/how-to-deploy-a-nodejs-website-in-hostinger\/\">deploying a Node.js application<\/a> on Hostinger, you can configure <strong data-renderer-mark=\"true\">environment variables<\/strong> as part of the deployment process. Environment variables are commonly used to store sensitive data and configuration values such as database credentials, API keys, and application settings.<\/p><p data-renderer-start-pos=\"75\" data-local-id=\"cab7cf17-39cc-4a94-be29-434bb27e7825\">Hostinger detects the environment variable names your application requires directly from your source code and prompts you to enter their values during deployment. You can also add variables manually or import them from a .env file in the same step.<\/p><h3 id=\"before-you-start\" class=\"text-text-100 mt-2 -mb-1 text-base font-bold\">Before you start<\/h3><p class=\"font-claude-response-body break-words whitespace-normal leading-[1.7]\">Make sure you know which environment variables your application requires. If using a .env file, ensure it follows the correct format (for example: KEY=value).<\/p><h2 id=\"h-add-environment-variables-during-deployment\">Add environment variables during deployment<\/h2><ol>\n<li>Start the Node.js application deployment process.<br>\n<img decoding=\"async\" class=\"alignnone size-full wp-image-7254\" src=\"https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/image-20260107-121247.png\" alt=\"Hostinger panel with the Add website menu open and Node.js Web App highlighted\" width=\"1507\" height=\"551\" data-media-id=\"7254\" srcset=\"https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/image-20260107-121247.png 1507w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/image-20260107-121247-300x110.png 300w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/image-20260107-121247-1024x374.png 1024w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/image-20260107-121247-768x281.png 768w\" sizes=\"(max-width: 1507px) 100vw, 1507px\" \/><\/li>\n<li>At the <strong>Review build settings<\/strong> step, check the <strong>Environment variables<\/strong> card. If Hostinger detected variables your application requires, the card shows <strong>Action required<\/strong> and the number of keys needing values.<\/li>\n<li>Click <strong>Edit<\/strong> to open <strong>Set environment variables<\/strong>.<br>\n<img decoding=\"async\" class=\"alignnone size-full wp-image-19177\" src=\"https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/09\/2026-09-29_10-39.png\" alt=\"\" width=\"866\" height=\"712\" srcset=\"https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/09\/2026-09-29_10-39.png 866w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/09\/2026-09-29_10-39-300x247.png 300w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/09\/2026-09-29_10-39-768x631.png 768w\" sizes=\"(max-width: 866px) 100vw, 866px\" \/><\/li>\n<li>Enter a value for each detected key.<\/li>\n<li>To add a variable Hostinger didn&rsquo;t detect, click <strong>Add more<\/strong>. To bring in values from a .env file instead, click <strong>Import .env<\/strong>.<br>\n<img decoding=\"async\" class=\"alignnone size-full wp-image-19178\" src=\"https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/09\/2026-09-29_10-40.png\" alt=\"\" width=\"706\" height=\"533\" srcset=\"https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/09\/2026-09-29_10-40.png 706w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/09\/2026-09-29_10-40-300x226.png 300w\" sizes=\"(max-width: 706px) 100vw, 706px\" \/><br>\nYour .env file should follow this format:<br>\nDATABASE_URL=mysql:\/\/user:password@host:port\/database<br>\nAPI_KEY=your_api_key_here<br>\nNODE_ENV=production<\/li>\n<li>Review the key-value pairs, then click <strong>Finish<\/strong> to save them.<\/li>\n<li>Click <strong>Deploy<\/strong> to continue.<\/li>\n<\/ol><p class=\"font-claude-response-body break-words whitespace-normal leading-[1.7]\"><strong>NOTES<\/strong><\/p><ul class=\"[li_&amp;]:mb-0 [li_&amp;]:mt-1.5 [li_&amp;]:gap-1.5 [&amp;:not(:last-child)_ul]:pb-1 [&amp;:not(:last-child)_ol]:pb-1 list-disc flex flex-col gap-2 pl-8 mb-3\">\n<li class=\"whitespace-normal break-words pl-2\">Hostinger detects variable names from your application&rsquo;s source code, not their values &mdash; you still need to enter each value yourself.<\/li>\n<li class=\"whitespace-normal break-words pl-2\">If Hostinger doesn&rsquo;t detect any variables, or your application needs ones it missed, add them with <strong>Add more<\/strong> or<strong> Import .env<\/strong> in the same screen.<\/li>\n<li class=\"whitespace-normal break-words pl-2\">Environment variables added during deployment are not stored in your repository.<\/li>\n<li class=\"whitespace-normal break-words pl-2\">If you <a data-click-id=\"hgr-post-content-link-update-environment-variables-later\" href=\"https:\/\/www.hostinger.com\/support\/how-to-edit-or-add-environment-variables-after-deployment\/\">update environment variables later<\/a>, you may need to redeploy your application for changes to take effect.<\/li>\n<li class=\"whitespace-normal break-words pl-2\">Never commit sensitive data such as API keys or passwords directly into your GitHub repository.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Add environment variables when deploying your Node.js application on Hostinger<\/p>\n","protected":false},"author":594,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"include_on_kodee":true,"footnotes":""},"categories":[301],"tags":[],"class_list":["post-7251","post","type-post","status-publish","format-standard","hentry","category-node-js"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/support\/how-to-add-environment-variables-during-node-js-application-deployment","default":1}],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/7251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/users\/594"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/comments?post=7251"}],"version-history":[{"count":5,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/7251\/revisions"}],"predecessor-version":[{"id":19179,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/7251\/revisions\/19179"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=7251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=7251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=7251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}