Enabling NodeJS in cPanel
Knowledgebase Article
}
Knowledgebase Article
This guide explains how to deploy and manage Node.js web applications using the Node.js Selector in cPanel. This tool is designed for running apps that need to be accessible via a web browser — for example:
The Node.js Selector is a tool provided in cPanel that allows you to:
Under the hood, the Node.js Selector uses Phusion Passenger to manage your application. Passenger handles routing and process management, meaning your app:
3000 or 3001)app.listen(...)This article walks you through the graphical method of creating and managing Node.js apps in cPanel and understand how to set them up to work in this environment. It also covers how to install dependencies and use SSH to enter the app's virtual environment for development tasks.

Click Create Application and configure:
This sets the NODE_ENV environment variable automatically:
myapp).app.js, server.js).
Click Create when done.
Use File Manager or SFTP to upload your app files into the application root directory that you created earlier.
package.json file.
{
"name": "myapp",
"version": "1.0.0",
"description": "Example Node app",
"main": "app.js",
"dependencies": {
"express": "^4.18.2"
}
}
package.json.
Your startup file is the main entry point for your application — it’s the file specified during app creation in the Node.js Selector. This is what Phusion Passenger uses to launch and serve your app.
Unlike traditional standalone Node.js apps (which listen on a custom port), applications deployed through the Node.js Selector must:
app.listen()module.exports = appThis pattern ensures your app is compatible with Passenger:
// app.js
const express = require('express');
const app = express();
app.get('/', (req, res) => res.send('Hello from Express!'));
// Instead of app.listen(), export the app
module.exports = app;
By exporting the app instead of listening to a port, you’re letting Passenger take full control of starting and serving your app.
const express = require('express');
const app = express();
app.listen(3000); // ❌ This will break under Passenger
app.listen(3000)), it will conflict with Passenger. The application will not start correctly and you may see a 503 Service Unavailable error when you visit your site.Phusion Passenger is integrated into your hosting environment's web server. It:
Calling app.listen() assumes you’re managing the HTTP server yourself, but under Passenger, that’s already handled for you.
Using SSH you can activate your app’s virtual environment to run npm commands, use build tools, or debug interactively. To do so, you must first enter the NodeJS virtual environment using the command listed when you edit the app in the UI, which will look something like this:
source /home/username/nodevenv/node-scripts/20/bin/activate && cd /home/nodejs/node-scripts
Replace:
username with your cPanel usernamemyapp with your application root folder20 with the Node.js version you selected (e.g. 18)Inside the virtual environment, you can:
npm install <module> manuallynode app.js (for non-web code)To exit the environment, just type:
deactivate
module.exports = app is required).app.listen(...), which is not allowed under Passenger.Do not attempt to bind to ports like 3000 or 3001. Phusion Passenger manages all routing internally via standard web ports (80/443).
If you're uploading a full app, it's safe to delete the auto-generated public/ folder and app.js file from the app root.
console.log() to output diagnostic messages.~/.nodeapp/ or under the ~/logs/ directory in your cPanel account.Powered by WHMCompleteSolution