MdmHost cPanel hosting runs CloudLinux, so you can host a full Next.js app (server rendering, API routes, middleware) with the Setup Node.js App tool. Passenger starts the app and connects it to your domain, so no ports or proxies are needed. This guide is for Next.js specifically; for the general app screen see Set up a Node.js app in cPanel.
Before you start
- A cPanel hosting account with Setup Node.js App under Software.
- Your Next.js project working locally with
npm run buildandnpm start. - Node.js on your computer at the same major version you will pick in cPanel.
- Optional but useful: SSH access (cPanel SSH access).
Tip: If your site has no server features, a static export is simpler and faster on cPanel. See Next.js static export.
Add a server.js entry file
Passenger needs a JavaScript file to start, not an npm script. Create server.js in the project root:
const { createServer } = require('http');
const next = require('next');
const port = process.env.PORT || 3000;
const app = next({ dev: false });
const handle = app.getRequestHandler();
app.prepare().then(() => {
createServer((req, res) => handle(req, res)).listen(port);
});Build the app
Building on shared hosting can hit memory limits, so build on your computer:
npm ci
npm run buildUpload everything except node_modules and .git: the .next folder, public, package.json, package-lock.json, next.config.js and server.js. Zip the files, upload with cPanel → Files → File Manager to a folder such as /home/USER/nextapp (outside public_html) and extract.
Create the Node.js app
- Open cPanel → Software → Setup Node.js App and click Create Application.
- Node.js version: the same major version you built with.
- Application mode: Production.
- Application root:
nextapp. - Application URL: your domain (leave the path empty for the whole site).
- Application startup file:
server.js. - Add environment variables such as
NODE_ENV=production, then click Create.
Install dependencies and start
- On the app screen click Run NPM Install. CloudLinux places
node_modulesin a virtual environment and links it into your app folder. - Click Restart and open your domain.
Using SSH instead? Copy the source command shown at the top of the app screen, run it, then npm install --omit=dev.
Deploy updates
- Build locally again and upload the new
.nextfolder (and any changed files). - If
package.jsonchanged, click Run NPM Install. - Click Restart. From SSH you can instead run
touch tmp/restart.txtin the app root.
Troubleshooting
- 503 Service Unavailable — the app crashed at start. Check
stderr.login the app root and see CloudLinux Node.js app troubleshooting. Could not find a production build— the.nextfolder was not uploaded or was built withnext dev.- Folder named node_modules already exists — delete your uploaded
node_modules; CloudLinux manages it.
Next steps
- CloudLinux Node.js Selector: set up an app
- Node.js environment variables
- Deploy Next.js on a Linux VPS
Need a plan? See MdmHost web hosting.
