A simple, yet practical command-line utility enabling .NET developers to test web applications served by IIS Express on remote devices.
It works just as well with Kestrel (dotnet run) or any other development server that only listens on localhost.
Are you a .NET developer building mobile web applications? Have you ever been frustrated by the fact that there's no easy way to enable IIS Express to accept connections from remote devices?...
If you've tried pointing a phone at your machine's IP address and got HTTP Error 400. The request hostname is invalid., this tool is for you.
You need Node.js 22 or newer.
There's no need to install iisexpress-proxy; you can simply run it with npx:
npx iisexpress-proxy@latest localPort to proxyPortIf you use it often, you may prefer installing it as a global module:
npm install -g iisexpress-proxy
iisexpress-proxy localPort to proxyPortThe examples below assume a global install; if you're using npx, prefix them with npx iisexpress-proxy@latest instead.
Upgrading from 1.x? Version 2 requires Node.js 22+ and is otherwise a drop-in replacement. If you're stuck on an older Node.js version, use
npx iisexpress-proxy@1 ....
If your application's IIS Express port is 51123, run this in the Command Prompt:
iisexpress-proxy 51123 to 3000The program will list the external addresses you can use for testing your application on remote devices, for instance http://192.168.0.102:3000.
The same goes for Kestrel: if dotnet run says Now listening on: http://localhost:5123, run iisexpress-proxy 5123 to 3000.
iisexpress-proxy <SOURCE> to <PROXY_ENDPOINT> [--cert=<path> --key=<path>]
| Argument | Description |
|---|---|
SOURCE |
Where your application is running: a port (51123), host:port (192.168.96.3:5000) or a full URL (https://localhost:44300). The host defaults to localhost and the protocol to http://. |
PROXY_ENDPOINT |
Where the proxy listens: a port (3000), ip:port (10.0.0.1:3000) or a full URL (https://*:3000). Without an IP address (or with *) it listens on all network interfaces. An IP must belong to one of your network interfaces; domain names are not allowed. |
--cert |
Path to a PEM certificate to use for an https:// proxy endpoint. Must be used together with --key. |
--key |
Path to the PEM private key matching --cert. |
iisexpress-proxy defaults to http, so if your application is running https, include the full URL:
iisexpress-proxy https://localhost:51123 to 3000Note that this will terminate HTTPS. On your destination device, connect to port 3000 using HTTP, not HTTPS.
If you want the proxy itself to serve HTTPS, specify the proxy endpoint with the full URL as well:
iisexpress-proxy https://localhost:51123 to https://*:3000This will generate a self-signed certificate and use it; openssl must be in PATH for this to work.
If you're on Windows, the easiest way to get openssl is to use Git Bash that comes with it pre-installed.
If you don't want to use a generated certificate, you can provide your own certificate and key using the --cert/--key arguments. In this case, openssl is not needed:
iisexpress-proxy https://localhost:51123 to https://*:3000 --key=./your-key.pem --cert=./your-cert.pemYou can also use iisexpress-proxy to expose an IIS server instance running on a different host accessible through VPN, like this:
iisexpress-proxy host:port to proxyHost:proxyPortFor instance, let's consider this scenario:
- the application is running on 192.168.96.3:5000 and it only accepts connections from clients within a VPN;
- your development machine has a network interface within the same VPN and another publicly accessible one (192.168.0.102);
- you need to test the application from mobile devices without having to add those devices to the VPN.
By running this in the Command Prompt:
iisexpress-proxy 192.168.96.3:5000 to 192.168.0.102:3000...you'll be able to access the application by pointing the mobile devices to 192.168.0.102:3000.
For another advanced example, consider that you're on public Wi-Fi and don't want to publicly expose your dev server. You could set up a VPN between your laptop and your phone and only expose the server on the VPN interface (10.0.0.1). Then you can run
iisexpress-proxy 5000 to 10.0.0.1:8080...and open http://10.0.0.1:8080 on your phone with VPN enabled, while other Wi-Fi users won't be able to connect.
Each iisexpress-proxy instance handles a single source/target pair. To proxy several sites at once, start one instance per site, each in its own window, using a batch file such as proxies.bat:
@echo off
start "Site 1" iisexpress-proxy 51123 to 3000
start "Site 2" iisexpress-proxy 51124 to 3001
start "Site 3" iisexpress-proxy 51125 to 3002For a range of consecutive ports, use a loop instead. This one maps 8100..8105 to 3000..3005:
@echo off
setlocal enabledelayedexpansion
for /L %%p in (8100,1,8105) do (
set /a t=%%p-8100+3000
start "Proxy %%p" iisexpress-proxy %%p to !t!
)Closing a window stops that proxy. These scripts assume a global install; with npx, every window resolves the package at the same time, which is slower.
The device can't connect at all. Make sure the device is on the same network as your machine, and that you're using one of the addresses listed when the proxy starts. On Windows, the first run usually triggers a "Windows Defender Firewall has blocked some features of Node.js" prompt; allow access on private networks. If you dismissed it, or your network is marked as public, add an inbound rule from an elevated Command Prompt:
netsh advfirewall firewall add rule name="iisexpress-proxy" dir=in action=allow protocol=TCP localport=3000The browser shows 502 Bad Gateway.
The proxy is reachable, but it can't reach your application. Check that the application is running and that SOURCE (port and http/https) matches what IIS Express or Kestrel is listening on. The reason is logged in the console.
The device warns about an untrusted certificate.
That's expected with the generated self-signed certificate; accept the warning, or provide a certificate the device trusts with --cert/--key.
The generated certificate is cached in your temp folder; delete iisexpress-proxy-cert.pem and iisexpress-proxy-key.pem from there to regenerate it.
Server error: listen EADDRINUSE.
Another program is already using the proxy port; pick a different one.
iisexpress-proxy doesn't work in scenarios involving integrated Windows authentication (see issue #5).
It's proxying the HTTP traffic on localPort to proxyPort on all the available network interfaces and it's also changing the origin of the host header, allowing you to test web applications hosted by IIS Express on various remote devices (mobile devices, other desktops, etc.).
WebSocket connections are proxied as well.
If you need to access the original host requested by the browser, the request headers will include X-Forwarded-* headers. In ASP.NET, Request.Headers["x-forwarded-host"] will contain the requested host.
- v2.0.0 – requires Node.js 22+; switched to http-proxy-3, which removes the
util._extenddeprecation warning;502 Bad Gatewaywhen the application is unreachable;--cert/--keyno longer require openssl. - v1.7.0 (02/14/2022) – custom certificates via
--cert/--key. - v1.4.0 – WebSocket support by Stan Hebben (see PR #21).
- v1.1.0 (10/21/2015) – proxying applications running on a different host.
This command-line utility wraps http-proxy-3, a maintained successor of http-proxy. The original http-proxy logo was created by Diego Pasquali.
If you find this repo useful, please give it a star, share it on X and endorse me on LinkedIn:
I'm getting lots of questions from people just learning to do web development or simply looking to solve a very specific problem they're dealing with. While I will answer some of them for the benefit of the community, please understand that open-source is a shared effort and it's definitely not about piggybacking on other people's work. On places like GitHub, that means raising issues is encouraged, but coming up with useful PRs is a lot better. If I'm willing to share some of my code for free, I'm doing it for a number of reasons: my own intellectual challenges, pride, arrogance, stubbornness to believe I'm bringing a contribution to common progress and freedom, etc. Your particular well-being is probably not one of those reasons. I'm not in the business of providing free consultancy, so if you need my help to solve your specific problem, there's a fee for that.
On 24th of February 2022 Russia unlawfully invaded Ukraine. This is an unjustified, unprovoked attack on the sovereignty of a neighboring country, but also an open affront to international peace and stability that has the potential to degenerate into a nuclear event threatening the very existence of humanity. I am a Romanian (EU) citizen, but I stand with Ukraine and I am doing everything in my power to stop this madness. Here's how you can show your support.
The ISC License.

