> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.hodi.host/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How do I deploy a Node.js application manually?

Two methods: from a Git repository with Hodifly, or by hand in cPanel.

## Recommended: deploy with Hodifly

[Hodifly](https://help.hodi.host/en/article/what-is-hodifly-1b7f6tw/) deploys your Node.js application from GitHub or GitLab on every `git push`. It creates the Passenger application, installs the dependencies and puts the new release live: there is nothing to configure in cPanel.

* **Automatic detection**: Hodifly recognises your framework and pre-fills the build command and output folder (including Express, Fastify, NestJS, Next).js, Nuxt, Astro, SvelteKit and Remix.
* **Startup file**: `server.js` by default, changeable in the project settings. It must listen on `process.env.PORT`.
* **Dependencies**: installed from your lockfile (npm, yarn, pnpm or bun), frozen for reproducibility.
* **Immutable releases**: the last 5 deploys are kept, and rolling back is instant with no rebuild.
* **Environment variables**, encrypted, passed to both the build and the running application.

Open **cPanel > Hodifly**, connect your repository, pick the branch and domain, then deploy. Full details in [What can I deploy on Hodifly?](https://help.hodi.host/en/article/what-can-i-deploy-on-hodifly-czlbyz/).

||| ⚠️ Note: like the manual method below, a Node.js application runs permanently behind Passenger and therefore requires **SITE PRO** hosting or above.

## Manual: "Setup Node.js App" in cPanel

### What's the difference between "Setup Node.JS App" and the ".bashrc" method?

* "**Setup Node.JS App**": This tool is only for setting up a Node.JS application accessible over the web (such as an API or an Express.js site). It automatically sets up an environment and manages the web server's execution.
* **The ".bashrc" method**: It gives you full control over Node.JS. You can run any Node.JS script, whether it's a [cron job](https://help.hodi.host/en/article/how-do-i-add-a-scheduled-task-cron-16qwojg/), a command-line tool, or a build script. [See the dedicated FAQ on this topic](https://help.hodi.host/en/article/how-do-i-use-nodejs-over-ssh-or-via-the-terminal-1rqdttr/).

### How do I deploy my Node.JS web app with "Setup Node.JS App"?
We let you deploy a Node.JS application directly on your hosting account, without needing to worry about supervising your **node** process. Technically, deployment is based on [Phusion Passenger](https://www.phusionpassenger.com/docs/tutorials/what_is_passenger/) (further down this page you'll find more technical information on how it works).

Also, feel free to check out the [list of frequently asked questions about Node.JS](https://help.hodi.host/en/article/how-do-i-modify-the-php-options-of-my-hosting-c0ut39/).

* [Log in to your cPanel](https://help.hodi.host/en/article/how-do-i-access-cpanel-en4rsm/)
* In the "**Software**" section, choose "**Setup Node.JS App**"
* Click " **Create Application**"
* Fill in your application's details:
  ![](https://hodi.host/images/kb/87_Screenshot-2023-05-07-at-10.03.35.png)
* `Create`: click here once you've filled in the form to create your application

* `Node.js version`: choose the Node.JS version to use (if the version you want is missing, don't worry, our [technical support](https://hodi.host/submitticket.php?step=2&deptid=2) will install it for you)
* `Application mode`: choose between development and production mode, this sets the `NODE_ENV` environment variable.
* `Application root`: specify the folder where your application's code is located (preferably use a folder other than the one for the domain where you're going to deploy your application)
* `Application URL`: specify the URL where you want to deploy your application, the directory after the domain name is optional (cPanel will create a .htaccess file there)
* `Application startup file`: specify the name of the JavaScript file used to start your application, it must be present in the `Application Root` folder (this is usually `server.js`)
* `Passenger log file`: specify where you want to create the log file (optional but useful for debugging)
* `Environment variables - Add Variable`: add the environment variables required by your application

* Even though you can install dependencies via cPanel, **we recommend doing it over** [**SSH**](https://help.hodi.host/en/article/how-do-i-access-my-hosting-via-ssh-143pq07/) **to better see any errors** if they occur.
* To do this, log in via SSH, copy the line shown at the top of your application's page in cPanel, and run it once you're connected via SSH:
![](https://hodi.host/images/kb/85_Screenshot-2023-05-07-at-09.19.53.png)
* You can then run `npm install` or `yarn install`.
* If you get a "`RangeError: WebAssembly.instantiate(): Out of memory: wasm memory`" error, try [connecting via SSH](https://help.hodi.host/en/article/how-do-i-access-my-hosting-via-ssh-143pq07/) instead of using the cPanel Terminal app, as the latter doesn't allocate enough memory for these commands.

#### How does this work technically?
Phusion Passenger works differently from what you might be used to (e.g. `node server.js`), and you didn't need to specify a listening port for your application. In fact, Phusion Passenger handles all of that transparently; it's the Setup Node.JS App tool that starts your application, and restarts it if it stops unexpectedly.

For this reason, **you must not start your application manually**, as it would then listen on port 3000 (for example), which isn't accessible from outside (blocked by our firewall).

Phusion Passenger starts your application, and as soon as it encounters the `listen()` instruction, it connects a Unix socket to it (instead of the specified port) and links it to the web server via this Unix socket. This is known as [reverse-port binding](https://www.phusionpassenger.com/library/indepth/nodejs/reverse_port_binding.html).