Below is a simple, clean, and production-ready guide to configure Express.js on a Windows Server.
Use this when hosting Node/Express apps on a Windows machine (local server or cloud VM).
Step 1. Install Node.js
Download and install LTS version:
https://nodejs.org
After install, verify:
node -v
npm -v
Step 2. Set Up Your Express App
If you don’t already have an Express project:
mkdir myapp
cd myapp
npm init -y
npm install express
Create index.js:
const express = require('express');
const app = express();
const PORT = 3000;
app.get("/", (req, res) => {
res.send("Server is running!");
});
app.listen(PORT, () => console.log(`Server started on ${PORT}`));
Run node index.js
Note : some projects may run node src/app.js depends on the arcitecture you have created
Step 3: Run Express App in Background Using PM2
npm install pm2 -g
Start app:
pm2 start index.js --name myapp / pm2 start src/app.js --name myapp
Enable auto-start on reboot:
pm2 startup
pm2 save
Step 4:Prepare IIS to Reverse Proxy to Node
IIS will receive HTTP(S) traffic and forward to Node on port 3000.
Install URL Rewrite & ARR (one-time)
If not already installed, do these on the server (you may have done parts earlier):
- Install URL Rewrite (rewrite_amd64.msi)
- Install Application Request Routing (ARR) (requestRouter_amd64.msi)
Then in IIS Manager:
- Click the server name (top left)
- Open Application Request Routing Cache
- Click Server Proxy Settings… (right side)
- Tick Enable Proxy → Apply
Step 4:Create a Site in IIS for the API
Create the site
In IIS Manager:
-
Right-click Sites → Add Website…
-
Site name: MyApiSite (anything)
-
Physical path: C:\apps\myapi
-
Binding:
- Type: http
- IP: All Unassigned (or specific IP)
- Port: 80
- Host name: (e.g. api.yourdomain.com or leave empty for IP)
Click OK.
Add web.config to site root
Create C:\apps\myapi\web.config with:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:3000/{R:1}" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Restart IIS
Now:
- Make sure PM2 is running your app: pm2 list
- Open browser from your PC (not just server):
If you used IP binding only:
http://SERVER_IP/api/healthhttp://SERVER_IP/api/hello
If you configured hostname (like api.yourdomain.com and DNS is pointing to server):
http://api.yourdomain.com/api/health
You should see the same JSON as when calling localhost:3000 before.
Step 5:Firewall Check (Important)
Make sure port 80 is open:
In Windows Firewall → Inbound Rules →
Allow World Wide Web Services (HTTP).
If you’re using a cloud VM (AWS/Azure/etc.), also open port 80 in the cloud security group / NSG.
This is all about configure Express.js on a Windows Server , if you want to confgure nextjs applications on linux platform please visit the here