Next.js is usually deployed on Vercel, but a lot of people already pay for cPanel hosting, or want their app, database and email in one place without per-seat or bandwidth bills. If your host has Setup Node.js App (CloudLinux's Node.js Selector), Next.js runs there fine with next start behind a small server file. This guide covers the App Router and Pages Router. Static export works too and is even simpler (see the end).
1. Check the Node.js version
Next.js 14 needs Node.js 18.17 or newer; Next.js 15 needs 18.18 or newer (20 LTS is a safe choice). In cPanel open Setup Node.js App and look at the versions offered. Pick the same major version you use locally.
2. Add a server.js
cPanel starts your app from one startup file and gives it the port to listen on in process.env.PORT. Add this server.js to the project root:
const { createServer } = require('http');
const next = require('next');
const app = next({ dev: false });
const handle = app.getRequestHandler();
app.prepare().then(() => {
createServer((req, res) => handle(req, res))
.listen(process.env.PORT || 3000);
});
3. Build locally, upload the result
next build needs a lot of memory and CPU. On hosting with limits per account it can be killed halfway. It is faster and safer to build on your computer:
npm ci
npm run build
Upload the project folder (for example to /home/youruser/myapp, outside public_html) with .next, public, package.json, package-lock.json, next.config.js and server.js. Leave node_modules out, because the server installs its own.
4. Create the application
In Setup Node.js App → Create Application:
- Node.js version: from step 1.
- Application mode: Production.
- Application root:
myapp. - Application URL: your domain.
- Application startup file:
server.js.
Add your environment variables (DATABASE_URL, API keys, NEXT_PUBLIC_… values) in the same screen. Note that NEXT_PUBLIC_ variables are baked in at build time, so they must also be set when you build locally.
5. Install and start
Press Run NPM Install, then Restart. Open your domain. You should see the app over HTTPS (cPanel's free SSL covers the domain).
When it doesn't start
- 503 / "Incomplete response received from application": the app crashed at start. Open
stderr.login the app folder. Typical causes: a missing environment variable, a Node.js version that is too old, or.nextmissing because the build wasn't uploaded. See our guide to the 503 error. - "Could not find a production build": the
.nextfolder is missing or was built with a different Next.js version than the one installed by npm. Usenpm ciwith the lock file both locally and on the server. - Images not optimised / sharp errors: install
sharpas a dependency, or setimages: { unoptimized: true }in next.config.js.
Updating the app
Build locally again, upload the new .next folder (and changed files), run NPM Install if dependencies changed, and press Restart. Many people automate this with a git push and a small deploy script over SSH.
The static option
If your site has no server-side code (no API routes, no server actions, no ISR), add output: 'export' to next.config.js. next build then writes plain HTML to out/. Upload that folder's contents to public_html and no Node.js app is needed at all.
Droxin Node.js hosting runs Next.js this way, with the CPU, RAM and NVMe storage you choose. If your app won't start, our engineers look at your logs and fix it, because repair is part of the hosting.