H
10Corp Premium Hosting

Setting Up a Node.js Application in cPanel

Last Updated: 2025-01-01 3 min read

Many cPanel hosting accounts include a Node.js Selector that allows you to deploy and manage Node.js applications without requiring root access or manual server configuration. This tool handles version management, dependency installation, and application startup.

Prerequisites

  • A hosting plan that supports the Node.js Selector (check with your hosting provider).
  • Your Node.js application code ready to deploy.
  • An application entry point file (commonly app.js or server.js).

Creating a Node.js Application

  1. Log in to cPanel.
  2. Navigate to the Software section.
  3. Click on Setup Node.js App.
  4. Click Create Application.
  5. Configure the application:
SettingDescription
Node.js versionSelect the desired version (e.g., 18.x, 20.x)
Application modeChoose Development or Production
Application rootThe directory containing your app files (e.g., myapp)
Application URLThe URL path where the app will be accessible
Application startup fileThe entry point (e.g., app.js)
Passenger log fileOptional log file path for debugging
  1. Click Create to set up the application.

cPanel will create the application environment and display a success message with your application’s details.

Installing Dependencies

After creating the application:

  1. Go back to Setup Node.js App in cPanel.
  2. Click the pencil icon (edit) next to your application.
  3. Scroll down to find the Run NPM Install button and click it.

This reads your package.json file and installs all listed dependencies into a virtual environment managed by cPanel.

Alternatively, copy the command shown at the top of the application page and run it in the cPanel Terminal:

source /home/username/nodevenv/myapp/18/bin/activate
cd ~/myapp
npm install

Managing Your Application

From the Node.js Selector dashboard, you can:

  • Start/Stop/Restart the application using the action buttons.
  • Change Node.js versions by editing the application settings.
  • Switch between Development and Production modes.
  • View logs to troubleshoot issues.

Application Structure

A typical Node.js application in cPanel should have:

myapp/
├── app.js              # Entry point
├── package.json        # Dependencies and scripts
├── package-lock.json   # Dependency lock file
├── node_modules/       # Installed packages (created by npm install)
└── public/             # Static files (if applicable)

Environment Variables

To set environment variables for your Node.js application:

  1. Edit your application in the Node.js Selector.
  2. Scroll to the Environment variables section.
  3. Add key-value pairs as needed (e.g., NODE_ENV=production, DB_HOST=localhost).
  4. Save and restart the application.

Troubleshooting

  • Application not loading: Check the startup file path and ensure all dependencies are installed.
  • 502 or 503 errors: Review the Passenger log file for error messages. The application may have crashed.
  • Port issues: cPanel uses Phusion Passenger to proxy requests — do not hardcode a port. Instead, use the PORT environment variable or let Passenger handle it.
  • Module not found errors: Run NPM Install again from the Node.js Selector to reinstall dependencies.
  • Version compatibility: If your app requires a specific Node.js version, ensure it is available in the selector. Contact your hosting provider if the needed version is not listed.

Important Notes

  • Node.js applications on cPanel shared hosting run through Phusion Passenger, not as standalone processes.
  • Resource limits on shared hosting may restrict CPU and memory usage for your application.
  • For production applications with high traffic, consider a VPS or dedicated server for better performance.
Tags: cpanel hosting nodejs javascript application

Still need help?

Our support team is available 24/7 to assist you.