
Running a Node.js application on cPanel or DirectAdmin is possible on hosting plans that support Node.js through the control panel. This guide explains the practical steps to deploy your Node.js app, install dependencies, set the correct startup file, and make the application accessible through your domain or subdomain.
Before You Start
Before setting up your Node.js application, make sure you have the following ready:
- An active hosting account with Node.js support enabled.
- Your Node.js project files.
- A valid domain or subdomain already added to your hosting account.
- A
package.jsonfile inside your app folder. - Your main startup file such as
app.js,server.js, or another entry file used by your project.
What Your App Folder Should Contain
Your application folder should normally contain files like these:
package.json
app.js or server.js
node_modules (will be created after installation)
public
views
.env (if your app uses environment variables)
Part 1: How to Set Up a Node.js App on cPanel
Step 1: Log in to cPanel
Log in to your cPanel account for the domain or hosting package where you want to run the Node.js application.
Step 2: Open the Node.js App Feature
In cPanel, look for one of the following options:
- Setup Node.js App
- Node.js Selector
- Application Manager
The name may vary depending on your server configuration.
Step 3: Create the Application
Click Create Application and fill in the required details.
Typical fields you will see:
- Node.js Version: Choose the version your project requires.
- Application Mode: Choose Production for live websites.
- Application Root: This is the folder where your app files will be stored, for example
myapp. - Application URL: Select the domain or subdomain that should load the app.
- Application Startup File: This is usually
app.jsorserver.js.
After filling in the details, click Create.
Step 4: Upload Your Application Files
Open File Manager in cPanel and go to the application root you selected earlier. Upload your Node.js app files into that folder.
Example:
/home/username/myapp
If your application was created with application root myapp, then your files should be uploaded into that same folder.
Step 5: Install the App Dependencies
After creating the app, cPanel usually provides a command that activates the Node.js environment. Copy the command shown on your Node.js app page.
It often looks similar to this:
source /home/username/nodevenv/myapp/20/bin/activate && cd /home/username/myapp
Open Terminal in cPanel if available, or connect through SSH, then run the environment activation command. After that, run:
npm install
This will install all packages listed in your package.json file.
If your project needs a build step, also run:
npm run build
Only use this if your app actually requires it.
Step 6: Make Sure Your App Uses the Correct Port
Your application must listen on the port provided by the server environment. Do not force a fixed port unless your setup specifically requires it.
Use code like this in your Node.js app:
const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;
app.get('/', (req, res) => {
res.send('Node.js app is working');
});
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});
Step 7: Restart the Application
Go back to the Setup Node.js App page in cPanel and click:
- Restart, or
- Start App
This will start the application with the new settings and installed dependencies.
Step 8: Test the Application URL
Visit your assigned domain or subdomain in a browser. If everything is correctly configured, your Node.js app should now load successfully.
Part 2: How to Set Up a Node.js App on DirectAdmin
Step 1: Log in to DirectAdmin
Log in to your DirectAdmin account for the hosting package where you want to deploy the Node.js app.
Step 2: Locate Node.js Support
Depending on how the server is configured, Node.js may appear under one of these areas:
- Node.js
- Application Manager
- CustomBuild Features integrated into the user panel
If you do not see Node.js in DirectAdmin, your hosting plan may not have Node.js enabled yet.
Step 3: Create the Node.js Application
Create a new Node.js application and fill in the details provided by DirectAdmin.
Common settings include:
- Node.js Version
- Application Root
- Domain or Subdomain
- Startup File
- Environment Mode
Use the same logic as cPanel:
- Set the correct application folder.
- Use the proper startup file.
- Choose the correct domain or subdomain.
Step 4: Upload Your App Files
Use the DirectAdmin File Manager or upload over FTP/SFTP to place your project files inside the selected application root folder.
Step 5: Install Dependencies
If DirectAdmin provides terminal access or SSH access is enabled, go into the application folder and run:
npm install
If your app requires a build step, also run:
npm run build
Step 6: Start or Restart the App
After installation is complete, use the DirectAdmin Node.js app controls to start or restart the application.
Step 7: Test the URL
Open the configured domain or subdomain in your browser to confirm that the Node.js app is loading properly.
Important Notes for Both cPanel and DirectAdmin
1. Use the Correct Startup File
Your startup file in the control panel must match the actual main file in your project.
Examples:
- If your app starts from
app.js, then useapp.js. - If your app starts from
server.js, then useserver.js.
2. Do Not Upload node_modules If Not Necessary
It is usually better to upload the project files and then run npm install on the server instead of uploading a large node_modules folder from your computer.
3. Check Your package.json File
Make sure your package.json file is valid and includes all required dependencies and scripts.
Example:
{
"name": "my-node-app",
"version": "1.0.0",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"dependencies": {
"express": "^4.18.2"
}
}
4. Use Environment Variables Properly
If your app uses database credentials, API keys, or other sensitive values, keep them in environment variables or a properly secured .env file where supported.
5. Make Sure Your Domain Points Correctly
The domain or subdomain used for the Node.js app must already be active on the hosting account and pointing to the correct server.
Common Issues and Fixes
App Does Not Open
Possible causes:
- Wrong startup file
- Dependencies not installed
- App crashed on startup
- App not listening on
process.env.PORT
503 Error or Application Unavailable
This usually means the app failed to start correctly. Restart the app and review your startup file and dependency installation.
Module Not Found Error
This usually means packages were not installed properly. Run:
npm install
App Starts Then Stops
This usually means the application is crashing during launch. Check the app logs, terminal output, or application error logs in your control panel.
Node.js Option Missing in Control Panel
If you cannot find any Node.js feature in cPanel or DirectAdmin, it means Node.js may not be enabled on your current hosting package.
Simple Example of a Basic Node.js App
Create a file called app.js with the following content:
const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;
app.get('/', (req, res) => {
res.send('Welcome to my Node.js app');
});
app.listen(PORT, () => {
console.log(`App is running on port ${PORT}`);
});
Then create your package.json file, upload both files, install dependencies, and restart the application.
Final Setup Checklist
- Node.js is enabled on the hosting account.
- The application has been created in cPanel or DirectAdmin.
- The correct app root folder was selected.
- The correct startup file was entered.
- Your app files were uploaded successfully.
npm installwas run successfully.- The app uses
process.env.PORT. - The app was restarted after setup.
- The assigned domain or subdomain opens correctly.
Need Help?
If your Node.js app is not starting correctly on your telaHosting account, kindly contact the telaHosting support team with your domain name, app root folder, startup file name, and any error message you are seeing so the issue can be checked faster.
Need help? Our friendly support team is always here for you! Reach out below.
Happy hosting! 🌟