
Running Node.js with PM2 on Hiverift Through cPanel Access
Running Node.js with PM2 on Hiverift Through cPanel Access
PM2 is a powerful production-grade process manager for Node.js applications. It ensures your app stays online, restarts on crashes, and simplifies log management. This guide walks you through running your Node.js app with PM2 on Hiverift shared hosting using cPanel and SSH access.
📦 What You’ll Need
- Hiverift shared hosting account with Node.js and SSH access
- Access to your cPanel dashboard
- Your Node.js project (with
server.js
or similar entry point)
🔐 Step 1: Enable SSH in cPanel
- Login to your Hiverift cPanel
- Navigate to SSH Access under the Security section
- Note down the SSH credentials (username, hostname, port)
- Use a terminal or SSH client like PuTTY to connect:
ssh username@yourdomain.com -p 22
🛠️ Step 2: Install PM2 via SSH
Once connected via SSH, run the following command to install PM2 locally in your project:
npm install pm2 --save
Or install it globally if your environment allows:
npm install pm2 -g
📂 Step 3: Upload Your Project to the Server
Using cPanel’s File Manager or Git:
-
- Upload your project folder into a directory like
~/myapp
- Or clone your repo:
- Upload your project folder into a directory like
git clone https://github.com/yourusername/yourapp.git
-
- Navigate into the project directory:
cd myapp
📦 Step 4: Install Dependencies
Ensure your package.json
is present, then run:
npm install
🚀 Step 5: Start the Node.js App with PM2
Use PM2 to start your application:
pm2 start server.js --name myapp
This command:
- Starts your app
- Names the process
myapp
for easier management - Keeps it running in the background
📝 Step 6: Configure Environment Variables (Optional)
Create a .env
file in your project root:
PORT=3000
DB_URI=mongodb+srv://username:password@cluster.mongodb.net/app
Make sure your app uses dotenv
to load variables:
require('dotenv').config();
🔄 Step 7: Save and Auto-Start PM2 Processes
To ensure PM2 restarts your app after a reboot:
pm2 save
This saves the current state of your running apps.
Then, add PM2 startup script (works if your shared host supports it):
pm2 startup
Note: Some shared hosts restrict the use of startup scripts. In that case, restart apps manually via SSH when needed.
📊 Step 8: Monitor and Manage Your App
- List running apps:
pm2 list
- Restart app:
pm2 restart myapp
- Stop app:
pm2 stop myapp
- View logs:
pm2 logs myapp
🛠 Troubleshooting Tips
- Permission denied errors? Ensure proper permissions for your app folder
- Port already in use? Change the port in
.env
or app - App not running? Check logs using
pm2 logs
✅ Benefits of Using PM2
- Automatic process restarts on crash or failure
- Log aggregation and real-time monitoring
- Easy management of multiple apps
- Works well on shared servers with SSH support
📌 Conclusion
PM2 is a powerful way to ensure your Node.js apps on Hiverift stay up and running. Even on shared hosting, combining cPanel’s file management with SSH and PM2 gives you near-VPS level control. With proper setup, your production applications will be robust, resilient, and easier to maintain.