How to Deploy a Node.js App in cPanel
Does cPanel hosting support Node.js? Yes. On HosterPK, "Setup Node.js App" is in cPanel on Hosting Plans I to IV, the Unlimited plans and the Business plans. You upload your project, choose a Node.js version, install your packages with one button and start the app. You do not need SSH.
Before you start
- Your project has a
package.jsonfile in its top folder. - You know your start-up file: the file that starts the server, often
app.jsorserver.js. - If your app has a build step (React, Vite, Next.js, TypeScript), run the build on your computer first. For Next.js follow How to deploy a Next.js app in cPanel.
Steps
- Upload the project. In cPanel open File Manager and create a folder outside
public_html, for examplemyapp. Upload your project into it as a zip file and extract it. Do not upload thenode_modulesfolder. To bring the project from GitHub instead, see How to deploy from a GitHub repository in cPanel. - Open the tool. In cPanel open "Setup Node.js App" and click CREATE APPLICATION.
- Fill in the form.
- Node.js version: choose 22 or 24 for a new project. The version the form pre-selects may be an older one.
- Application mode: change "Development" to "Production".
- Application root: the folder from step 1, for example
myapp. - Application URL: choose your domain. Leave the box beside it empty to run the app on the whole domain, or type a sub-folder such as
api; the app then opens atyourdomain.com/api/. - Application startup file: your start-up file, for example
app.js. - Environment variables: click ADD VARIABLE for each value your app needs, such as a database password.
- Install the packages. Under "Detected configuration files" click Run NPM Install. cPanel installs everything listed in
package.json. A small Express app takes a few seconds; a large project can take about 10 minutes. Wait for it to finish. - Click RESTART and open your address.
A small example
This Express app was tested on our servers. The file package.json:
{
"name": "myapp",
"version": "1.0.0",
"dependencies": { "express": "^4.19.2" }
}
The start-up file app.js:
const express = require("express");
const app = express();
app.get("/", (req, res) => res.send("Hello from Node.js " + process.version));
app.listen(process.env.PORT || 3000);
You do not need to open or choose a port. In our test an app that named port 3000 in its code opened normally at its address.
If something goes wrong
Errors from your app are written to the file stderr.log in the app's folder. Open it in File Manager first.
| What you see | Usual cause | Fix |
|---|---|---|
| Run NPM Install stops with "application should not contain folder/file with such name in application root" | A node_modules folder was uploaded with the project. | Delete that folder in File Manager and click Run NPM Install again. |
| Run NPM Install stops with "Web application is inaccessible by its address" | cPanel checks that your address opens before it installs, and the domain does not open yet, for example a new domain that is not pointed to us. | Point the domain to your hosting account and try again once it opens, or open a ticket and we run the install for you. |
| "503 Service Unavailable" after creating the app | The packages are not installed yet, or the app stopped with an error. | Click Run NPM Install, then RESTART. If it stays, read stderr.log. |
ERR_REQUIRE_ESM in stderr.log | The project is an ES module ("type": "module") and the app runs on Node.js 18 or older. | Choose Node.js 20 or newer. To stay on an older version, add a file start.cjs containing the one line import("./app.js"); and set it as the Application startup file. |
| "Out of memory" when you run a build with Run JS script | Builds of large frameworks such as Next.js do not run on shared hosting. | Build on your computer and upload the result. |
| "Disk quota exceeded" | Packages filled the plan's space. | Remove the packages of Node.js versions you no longer use (see below), or move to a larger plan. |
Changing the Node.js version later
- Open the app in "Setup Node.js App", choose the new version under Node.js version and click SAVE.
- cPanel reinstalls your packages for the new version by itself. A small app takes seconds; a Next.js app took about 5 minutes in our test, and the site may not answer meanwhile.
- Click RESTART, so that the app runs on the new version.
The old version's packages stay on your account and take space. To remove them, open File Manager, go to the folder nodevenv, open the folder with your app folder's name, and delete the folder named after the old version, for example 20. Do not delete the folder of the version in use.
Still stuck? Open a support ticket or start a live chat, and we will create the app, install the packages and start it for you. See the plans on our Node.js hosting page.
Related: Fixing "Node.js Selector is not available" and Terminal access in cPanel.