Host NextJS App on Windows Server with Production Build
11 Oct 2025Deploying NextJS on Windows Server is straightforward once you know the process. Here’s how to do it properly.
Prerequisites: Install Node.js (LTS version) and npm on your Windows Server.
First, build your NextJS app for production. In your project folder, run:
npm run build
This creates an optimised .next folder with your production files.
Method 1: Using PM2 (Recommended)
Install PM2 globally to manage your Node process:
npm install -g pm2
npm install -g pm2-windows-startup
pm2-startup install
Start your app:
pm2 start npm --name "my-nextjs-app" -- start
pm2 save
Your app runs on port 3000 by default. Change it by setting PORT environment variable or modifying package.json start script.
Method 2: Using IIS with iisnode
Install iisnode from the official website. Create a web.config file in your project root:
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="NextJS">
<match url="/*" />
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Create a custom server file server.js if not using the default NextJS server, then configure IIS to point to your project folder.
Firewall Configuration
Open Windows Firewall and allow inbound connections on your chosen port (3000 or 80/443 for IIS).
Using Custom Domain
Configure your domain DNS to point to your server IP. For IIS, add bindings in site settings. For PM2, use nginx or IIS as reverse proxy.
That’s it! Your NextJS app is now running in production mode on Windows Server. Check logs using pm2 logs or IIS logs folder to troubleshoot any issues.