How to set up a Node.js application Print

  • 0

You can run Node.js applications, such as an Express API or a small web app, directly from cPanel. No server administration needed.

Create the application

  1. In cPanel, open Software → Setup Node.js App.
  2. Click Create Application.
  3. Fill in the form:
    • Node.js version: choose a current LTS version, for example 22 or 24.
    • Application mode: Production for a live site, Development while testing.
    • Application root: the folder for your app's files, for example myapp. Keep it outside public_html.
    • Application URL: the domain and, optionally, a path, for example yourdomain.com/app.
    • Application startup file: your entry file, for example app.js or server.js.
  4. Add any Environment variables your app needs, such as API keys or settings.
  5. Click Create.

Creating a Node.js application with version, root, URL and startup file

Upload your code and install packages

  1. Upload your app's files, including package.json, to the application root with File Manager or FTP. Don't upload the node_modules folder.
  2. Back on the Setup Node.js App page, click the pencil icon to edit your app.
  3. Click Run NPM Install to install the packages from package.json.
  4. Click Restart.

Tips

  • You don't need to choose a port. The server passes it to your app automatically, so use process.env.PORT in your code.
  • After changing code or environment variables, click Restart for the changes to take effect.
  • If the app shows an error, check the log file in the application root (if you set one), or run it in Development mode to see more details.
Good to know: Node.js apps on shared hosting are meant for websites and APIs that respond to web requests. Long-running background jobs are better handled with cron jobs. See How to set up a cron job.

Was this answer helpful?

« Back