You’ve built a full-stack MERN application—MongoDB, Express, React, and Node.js—and now you need to get it live. You already have cPanel hosting and don’t want to migrate to a VPS or a platform like Vercel. The question is, can you host a MERN app on cPanel? The answer is yes, but it requires a specific approach. While cPanel was traditionally built for PHP and static websites, modern versions include Node.js support via the Setup Node.js App feature (often powered by CloudLinux’s Node.js Selector). In this guide, I’ll show you exactly how to host a MERN app on cPanel in 2026 with a practical step‑by‑step strategy.
The Key Challenge: Two Deployment Models
The MERN stack combines a frontend (React) and a backend (Node.js/Express). cPanel’s Node.js support is designed to run a single Node.js application. Therefore, you have two options to host MERN app on cPanel successfully:
| Approach | How It Works | Best For |
|---|---|---|
| Approach 1: Separate Frontend & Backend | Deploy the React build as static files (HTML, CSS, JS) and run the Express backend as a separate Node.js app. | Most shared hosting plans. |
| Approach 2: Unified Node.js App | Serve both the React build and the Express API from a single Node.js process. | Advanced setups with dedicated resources. |
Prerequisites Before You Start
Before you can host a MERN app on cPanel, verify these requirements:
- Your cPanel account includes the Setup Node.js App feature (look under the Software section).
- Your hosting plan supports Node.js (contact support if unsure).
- You have MongoDB access—either via MongoDB Atlas (recommended) or a locally installed MongoDB instance.
- You have FTP or File Manager access to upload files.
Approach 1: React as Static Files + Express as Node.js App (Recommended)
This is the most reliable way to host a MERN app on cPanel on shared hosting.
Step 1: Prepare Your React Frontend
Build your React app for production:
npm run build
This creates a build (or dist) folder containing static files. Compress this folder into a .zip file.
Step 2: Upload the React Build to cPanel
- Log into cPanel and open File Manager.
- Navigate to the root directory for your domain (e.g.,
public_html). - Upload the
.zipfile and extract it. Your React app is now accessible via your domain.
Fix React Router Issues: If you use React Router, create a .htaccess file in the same directory with:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
This ensures all routes point to index.html.
Step 3: Deploy Your Express Backend as a Node.js App
-
In cPanel, go to Software → Setup Node.js App.
-
Click Create Application.
-
Fill in the details:
-
Node.js version: Select the latest LTS (e.g., 18.x or 20.x).
-
Application root: Set to the folder containing your Express
server.js(e.g.,/home/username/api). -
Application URL: Choose a subdomain or a subdirectory (e.g.,
api.yourdomain.com). -
Application startup file:
server.js(or your entry file).
-
-
Click Create.
Step 4: Upload Your Express Code
-
In File Manager, navigate to the application root you set above.
-
Upload your Express backend files (excluding
node_modules). -
Return to Setup Node.js App, find your application, and click Run npm install to install dependencies.
-
Click Start to launch the Node.js process.
Step 5: Configure Environment Variables
Add your MongoDB connection string and other secrets in the Setup Node.js App interface under Environment Variables. If using MongoDB Atlas, ensure your hosting IP is whitelisted.
Step 6: Update React API Calls
In your React app, update all API calls to point to your backend URL (e.g., https://api.yourdomain.com). Rebuild and re-upload the React build.
Approach 2: Unified Node.js App (Serving React + API)
If your hosting allows it, you can serve both from one Node.js process:
-
Build your React app and place the
buildfolder inside your Express project. -
In
server.js, add static file serving:
const express = require('express');
const path = require('path');
const app = express();
// API routes
app.use('/api', apiRoutes);
// Serve React static files
app.use(express.static(path.join(__dirname, 'build')));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
app.listen(process.env.PORT || 5000);
-
Upload the entire project and set the application root in cPanel’s Setup Node.js App.
Common Pitfalls and How to Avoid Them
| Problem | Solution |
|---|---|
| Node.js app won’t start | Check the startup file path and ensure all dependencies are installed. |
| React routes return 404 | Add the .htaccess file as shown above. |
| MongoDB connection fails | Whitelist your cPanel server’s IP in MongoDB Atlas. |
| Port conflicts | cPanel assigns a port automatically—use process.env.PORT in your code. |
| “Setup Node.js App” missing | Your hosting plan may not support Node.js—contact support or upgrade. |
Is This the Best Way to Host a MERN App?
While you can host a MERN app on cPanel, it’s important to understand the limitations. cPanel’s Node.js support is not as seamless as dedicated platforms like Vercel, Render, or a VPS with PM2 and Nginx. Some cPanel representatives have even noted that cPanel does not “support the MERN project” natively. However, with the steps above, thousands of developers successfully host MERN apps on cPanel every day.
For an external deep dive into cPanel’s Node.js capabilities, check the official cPanel Node.js documentation.
Conclusion
Can you host a MERN app on cPanel? Yes—and now you know exactly how. The recommended approach is to treat React as static files (deployed via File Manager) and run your Express backend as a separate Node.js application via cPanel’s Setup Node.js App feature. While it requires a few extra steps compared to VPS or specialized platforms, it’s a perfectly viable solution for shared hosting environments.
For more full‑stack deployment strategies, check out our internal guide on deploying React apps to various hosting platforms. If you need personalized assistance with your MERN deployment, feel free to contact our team here.
