How to Route a Node.js App to a Subdomain in cPanel
To run your Node.js app on a subdomain like app.yourdomain.com, you create the subdomain in cPanel and set it as your application's URL in Setup Node.js App. This is the clean way to give an app its own address.
Step 1: Create the subdomain
In cPanel, open the Subdomains (or Domains) tool and create your subdomain, for example app for app.yourdomain.com — see creating a subdomain in cPanel.
Step 2: Point the app to it
- Open Setup Node.js App.
- Create or edit your application.
- Set the Application URL to your subdomain.
- Set the application root and startup file — see the startup file and root.
- Save and restart.
Step 3: Test it
Visit your subdomain in a browser. If you see a "Cannot GET" or an error instead of your app, check your routes and startup file — see fixing the "Cannot GET" error and "application failed to start".
Subdomain vs subfolder
You can also run an app in a subfolder of an existing site. For the trade-offs between the two, see subfolder vs subdomain.
Frequently asked questions
Do I need a separate subdomain for each Node app?
It is the cleanest approach — each app gets its own URL and root. You can also use subfolders, but subdomains keep apps clearly separated.
My subdomain shows the default page, not my app.
Make sure the application URL in Setup Node.js App is set to the subdomain, and that the app is running. A new subdomain shows a placeholder until the Node app is correctly attached and restarted.
Does the subdomain need its own SSL?
Yes — secure it with a certificate. Free SSL usually covers subdomains; see installing a free SSL certificate.
Was this article helpful?