How to Deploy Node.js App on Shared Hosting
{{COMPANY_NAME}} shared hosting supports Node.js applications through CloudLinux. Here is how to deploy your Node.js app without needing a VPS.
Prerequisites
- A {{COMPANY_NAME}} cPanel or DirectAdmin hosting account (any plan).
- Your Node.js application code.
- SSH access (available on all plans).
Method 1: cPanel Node.js Application Manager
Step 1: Access the Node.js Setup
- Log in to cPanel.
- Go to Software > Setup Node.js App.
- Click Create Application.
Step 2: Configure the Application
- Node.js Version: select the version your app requires (14.x, 16.x, 18.x, 20.x).
- Application Mode: Development or Production.
- Application Root: the folder containing your app (e.g., `
myapp`). - Application URL: the domain/path for your app.
- Application Startup File: your entry point (e.g., `
app.jsorserver.js`).
Step 3: Upload Your Code
- Use File Manager or FTP to upload your application files to the Application Root folder.
- Or use SSH with Git:
bash
cd ~/myapp
git clone https://github.com/you/your-repo.git .Step 4: Install Dependencies
- In the Node.js App Manager, click Run NPM Install or use the virtual environment command shown.
- Or via SSH:
bash
cd ~/myapp
source /home/username/nodevenv/myapp/18/bin/activate
npm installStep 5: Start the App
- In the Node.js App Manager, click Start or Restart.
- Visit your application URL to verify it works.
[screenshot: cPanel Node.js Application Manager]
Method 2: DirectAdmin Node.js
- Log in to DirectAdmin.
- Go to Node.js setup (under Extra Features or Advanced).
- Create a new application.
- Set the version, root directory, and startup file.
- Upload code and install dependencies.
- Start the application.
Environment Variables
Set environment variables in the Node.js Application Manager:
- Click your application.
- Find Environment Variables section.
- Add key-value pairs (e.g., `
NODE_ENV=production,PORT=3000`). - Click Save and restart.
Troubleshooting
Application Not Starting
- Check the startup file name is correct.
- Review error logs (shown in the Application Manager).
- Verify all dependencies installed correctly.
"502 Bad Gateway"
- The Node.js process may have crashed. Check logs.
- Restart the application from the Application Manager.
Port Issues
- Do NOT bind to a specific port. The hosting proxy handles routing.
- Use the port provided by the environment or bind to the socket.
Related Articles
Need help? Contact our support team at {{SUPPORT_URL}}/client/support.