Setting Up Node.js Applications
Deploy a Node.js app on GoZen Host. Shared hosting with cPanel or a VPS with PM2.
3 min read
Node.js runs server-side JavaScript. How you deploy it depends on whether you’re on shared hosting (cPanel) or a VPS.
On Shared Hosting (cPanel)
GoZen Host shared plans support Node.js through cPanel’s built-in Node.js selector.
Step 1: Create the Application
- Log into cPanel
- Go to Software → Setup Node.js App
- Click Create Application
- Configure:
| Setting | Value |
|---|---|
| Node.js version | Pick the newest LTS offered (24.x, or 22.x if 24 isn’t listed) |
| Application mode | Production |
| Application root | myapp (folder inside your home directory) |
| Application URL | Your domain or subdomain |
| Application startup file | app.js or server.js |
- Click Create
Step 2: Upload Your Code
Upload your project files to the Application root directory. Use File Manager, FTP, or cPanel Git Version Control. Shared plans have no SSH or SFTP.
Your project should include a valid package.json.
Step 3: Install Dependencies
In the Node.js App screen:
- Click Run NPM Install. This installs your
package.jsondependencies - Click Restart to start the app
Environment Variables
Add environment variables in the Node.js App interface:
- Scroll to Environment variables
- Click Add Variable
- Enter the key/value pairs (e.g.,
NODE_ENV=production) - Click Save then Restart
On a VPS
On a VPS, you have full control. Use PM2 to keep your app running.
Step 1: Install Node.js
Step 2: Deploy Your App
# Clone or upload your project
cd /var/www
git clone https://github.com/you/your-app.git myapp
cd myapp
# Install production dependencies (npm ci needs a package-lock.json;
# without one, use npm install --omit=dev)
npm ci --omit=dev
Step 3: Install and Configure PM2
PM2 keeps your app alive, restarts it on crash, and handles logs.
# Install PM2 globally
sudo npm install -g pm2
# Start your app
pm2 start app.js --name "myapp"
# Generate the boot script. This prints a "sudo env PATH=..." command:
# copy it and run it exactly as printed
pm2 startup
# Then save the process list so it restarts on reboot
pm2 save
Step 4: Set Up Nginx as a Reverse Proxy
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_cache_bypass $http_upgrade;
}
}
# Test and reload Nginx
sudo nginx -t
sudo systemctl reload nginx
After verifying Nginx works, install an SSL certificate with Let’s Encrypt using certbot.
PM2 Cheat Sheet
| Command | What it does |
|---|---|
pm2 list | Show all running apps |
pm2 logs myapp | View real-time logs |
pm2 restart myapp | Restart the app |
pm2 stop myapp | Stop the app |
pm2 delete myapp | Remove from PM2 |
pm2 monit | Interactive monitoring dashboard |
Troubleshooting
| Problem | Fix |
|---|---|
| App not starting on cPanel | Check the startup file path. Make sure package.json exists in the app root |
| “Module not found” errors | Run NPM Install again from the Node.js App screen |
| 502 Bad Gateway (VPS) | Your Node app isn’t running. Check pm2 list and pm2 logs |
| Port already in use | Another process is on port 3000. Use lsof -i :3000 to find it |
| App doesn’t start after reboot | Run pm2 startup, run the sudo command it prints, then pm2 save |
What to Do Next
- First Boot: Initial Server Setup: secure your VPS before deploying apps
- Monitoring Your Server: watch CPU and memory while your app runs
Last updated 21 Oct 2026, 00:00 +0300.