A Gen2 server runs Node.js applications as well as PHP ones. Each Node.js application runs as its own service under its own Linux user, restarts by itself if it stops, and gets the domain's traffic over HTTPS through nginx.
Create one
- Open Applications on the server
In New application, choose the platform Node.js and a Node.js version (22 is the long-term support release).
- Create it
If that Node.js version is not on the server yet, it is installed first (under a minute). The application starts at once with a welcome page and gets its SSL certificate.
- Deploy your code
Connect your repository on the Git deploys tab. Each deploy runs
npm ci(ornpm installwithout a lock file),npm run buildwhen there is a build script, switches to the new release and restarts the app.
What your app needs
- Listen on
process.env.PORT(and127.0.0.1). The server gives every Node.js application its own local port. - A start command:
npm startby default, so astartscript inpackage.json. Change it on the Node.js tab, for examplenode server.jsornpm run start. - For Next.js:
next startreadsPORTby itself, so the defaultnpm startworks.
Keep secrets (API keys, database passwords) in the Environment variables box of the Node.js tab, not in your repository. They are loaded every time the application starts; PORT and HOST are set by the server.
The Node.js tab
- Status: running or not, memory, how long it has been up, and a Restart button.
- Version and start command: switch between Node.js 20, 22 and 24. A version not on the server yet is installed first.
- Environment variables: one
KEY=valueper line. Saving restarts the app. - Log: the latest lines your app writes to the console, newest first.
When it does not start
| You see | Usually |
|---|---|
| 502 Bad Gateway on the site | The app is not running or listens on another port. Check the log on the Node.js tab and make sure it uses process.env.PORT. |
| The status keeps switching to Starting | The start command fails right away. The log shows the error, often a missing build (npm run build) or a missing variable. |
| Cannot find module | Dependencies are missing. Deploy again from Git so npm ci runs, or check that the module is in dependencies. |
Did this solve it? If not, tell us what you see and we look at your server.
Open a ticket