{"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-01-08T11:02:52","modified_gmt":"2026-01-08T11:02:52","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 deploying a Node.js application 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=\"357\" data-local-id=\"cbabc2e5-e631-4a8b-bab7-9e9369223f50\">During deployment, you have <strong data-renderer-mark=\"true\">two ways<\/strong> to add environment variables:<\/p><ul class=\"ak-ul\" data-local-id=\"a06b975f-d03f-4bc9-bf0a-3556d8cdf2ee\" data-indent-level=\"1\">\n<li>\n<p data-renderer-start-pos=\"427\" data-local-id=\"3e536743-edd2-4982-8986-63a175c59dc3\">Import them from a .env file (<strong data-renderer-mark=\"true\">recommended<\/strong>)<\/p>\n<\/li>\n<li>\n<p data-renderer-start-pos=\"473\" data-local-id=\"f06b6e92-f1c9-4385-8eaa-1503078398cf\">Add environment variables manually, one by one<\/p>\n<\/li>\n<\/ul><p data-renderer-start-pos=\"523\" data-local-id=\"db2dc719-86d3-4617-ab15-d0069e0b5dbc\">Once all environment variables are added, you can confirm them and continue with building your application.<\/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><h3 id=\"option-1-import-evironment-variables\" class=\"text-text-100 mt-2 -mb-1 text-base font-bold\">Option 1 &mdash; Import environment variables from a .env file<\/h3><p class=\"font-claude-response-body break-words whitespace-normal leading-[1.7]\">Importing variables from a .env file is the fastest option, especially if you already use environment variables locally.<\/p><p class=\"font-claude-response-body break-words whitespace-normal leading-[1.7]\"><strong>To import from a .env file:<\/strong><\/p><ol 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-decimal flex flex-col gap-2 pl-8 mb-3\">\n<li class=\"whitespace-normal break-words pl-2\">Start the Node.js application deployment process<br>\n<img loading=\"lazy\" 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=\"\" width=\"1507\" height=\"551\" 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=\"auto, (max-width: 1507px) 100vw, 1507px\" \/><\/li>\n<li class=\"whitespace-normal break-words pl-2\">At the <strong>Environment variables<\/strong> step, select <strong>Import from .env file<br>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7252\" src=\"https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/Screenshot-2026-01-07-at-14.14.07.png\" alt=\"\" width=\"1666\" height=\"1283\" srcset=\"https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/Screenshot-2026-01-07-at-14.14.07.png 1666w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/Screenshot-2026-01-07-at-14.14.07-300x231.png 300w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/Screenshot-2026-01-07-at-14.14.07-1024x789.png 1024w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/Screenshot-2026-01-07-at-14.14.07-768x591.png 768w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/Screenshot-2026-01-07-at-14.14.07-1536x1183.png 1536w\" sizes=\"auto, (max-width: 1666px) 100vw, 1666px\" \/><br>\n<\/strong><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7253\" src=\"https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/Screenshot-2026-01-07-at-14.14.30.png\" alt=\"\" width=\"1666\" height=\"1283\" srcset=\"https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/Screenshot-2026-01-07-at-14.14.30.png 1666w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/Screenshot-2026-01-07-at-14.14.30-300x231.png 300w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/Screenshot-2026-01-07-at-14.14.30-1024x789.png 1024w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/Screenshot-2026-01-07-at-14.14.30-768x591.png 768w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/Screenshot-2026-01-07-at-14.14.30-1536x1183.png 1536w\" sizes=\"auto, (max-width: 1666px) 100vw, 1666px\" \/><\/li>\n<li class=\"whitespace-normal break-words pl-2\">Upload your .env file or paste its contents into the input field<\/li>\n<\/ol><p class=\"font-claude-response-body break-words whitespace-normal leading-[1.7]\">Your .env file should follow this format:<\/p><div class=\"relative group\/copy bg-bg-000\/50 border-0.5 border-border-400 rounded-lg\">\n<div>\n<pre class=\"code-block__code !my-0 !rounded-lg !text-sm !leading-relaxed\"><code>DATABASE_URL=mysql:\/\/user:password@host:port\/database\r\nAPI_KEY=your_api_key_here\r\nNODE_ENV=production<\/code><\/pre>\n<\/div>\n<\/div><ol 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-decimal flex flex-col gap-2 pl-8 mb-3\" start=\"4\">\n<li class=\"whitespace-normal break-words pl-2\">Review the imported variables to ensure all required variables are present and there are no typos<br>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7255\" src=\"https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/image-20260107-121640.png\" alt=\"\" width=\"1666\" height=\"1283\" srcset=\"https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/image-20260107-121640.png 1666w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/image-20260107-121640-300x231.png 300w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/image-20260107-121640-1024x789.png 1024w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/image-20260107-121640-768x591.png 768w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/image-20260107-121640-1536x1183.png 1536w\" sizes=\"auto, (max-width: 1666px) 100vw, 1666px\" \/><\/li>\n<li class=\"whitespace-normal break-words pl-2\">Click <strong>Confirm<\/strong> to save the environment variables<\/li>\n<\/ol><h3 id=\"option-2-add-environment-variables-manually\" class=\"text-text-100 mt-2 -mb-1 text-base font-bold\">Option 2 &mdash; Add environment variables manually<\/h3><p class=\"font-claude-response-body break-words whitespace-normal leading-[1.7]\">If you only have a few variables or don&rsquo;t use a .env file, you can add them manually.<\/p><p class=\"font-claude-response-body break-words whitespace-normal leading-[1.7]\"><strong>To add environment variables manually:<\/strong><\/p><ol 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-decimal flex flex-col gap-2 pl-8 mb-3\">\n<li class=\"whitespace-normal break-words pl-2\">Start the Node.js application deployment process<\/li>\n<li class=\"whitespace-normal break-words pl-2\">At the <strong>Environment variables<\/strong> step, click <strong>Add<br>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7256\" src=\"https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/Screenshot-2026-01-07-at-14.14.07-1.png\" alt=\"\" width=\"1666\" height=\"1283\" srcset=\"https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/Screenshot-2026-01-07-at-14.14.07-1.png 1666w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/Screenshot-2026-01-07-at-14.14.07-1-300x231.png 300w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/Screenshot-2026-01-07-at-14.14.07-1-1024x789.png 1024w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/Screenshot-2026-01-07-at-14.14.07-1-768x591.png 768w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/Screenshot-2026-01-07-at-14.14.07-1-1536x1183.png 1536w\" sizes=\"auto, (max-width: 1666px) 100vw, 1666px\" \/><br>\n<\/strong><\/li>\n<li class=\"whitespace-normal break-words pl-2\">Enter the variable name (for example, <strong>DATABASE_URL<\/strong>)<\/li>\n<li class=\"whitespace-normal break-words pl-2\">Enter the variable value<br>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7257\" src=\"https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/image-20260107-121808.png\" alt=\"\" width=\"1666\" height=\"1283\" srcset=\"https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/image-20260107-121808.png 1666w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/image-20260107-121808-300x231.png 300w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/image-20260107-121808-1024x789.png 1024w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/image-20260107-121808-768x591.png 768w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/01\/image-20260107-121808-1536x1183.png 1536w\" sizes=\"auto, (max-width: 1666px) 100vw, 1666px\" \/><\/li>\n<li class=\"whitespace-normal break-words pl-2\">Repeat the process for each environment variable<\/li>\n<li class=\"whitespace-normal break-words pl-2\">Review the list of environment variables<\/li>\n<li class=\"whitespace-normal break-words pl-2\">Click <strong>Confirm<\/strong> to save them<\/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\">Environment variables added during deployment are not stored in your repository.<\/li>\n<li class=\"whitespace-normal break-words pl-2\">If you update environment variables later, 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":2,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/7251\/revisions"}],"predecessor-version":[{"id":7259,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/7251\/revisions\/7259"}],"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}]}}