Peter Morlion logo


Redirecting a public URL to localhost with port

I have a customer that sells a multi-tenant SaaS platform. I often have to run the thing locally, but there is some interaction with other websites that then redirect to the customer’s system. And these website won’t redirect to localhost of course. What’s more, the application running on my localhost is running on port 3000, instead of 443 (the default HTTPS port). Let’s see how we can fix this.

The hosts File

First, we need to tell our system that our URL ( is actually hosted on localhost. Assuming you’re working on Windows, open the hosts file as administrator. You can find it in C:\Windows\System32\drivers\etc. Then add a line like this:

It doesn’t have to be

When you request now, your local system will want to respond. Anything listening on port 443 will now respond. My local application was listening on port 3000, so I didn’t get a response.

The netsh Tool

Open a command prompt as administrator and tell your system to forward requests on port 443 to port 3000. At least, for the correct IP address:

netsh interface portproxy add v4tov4 listenport=443 listenaddress= connectport=3000 connectaddress=

So all requests that enter your machine for are sent to, which is where my local application was running.


Of course, once you’re done testing, you want to clean everything up. The hosts file is easy: just remove the line.

For the netsh tool, run the following command:

netsh interface portproxy delete v4tov4 listenport=443 listenaddress=

And now everything’s cleaned up.

So that’s how you can intercept calls and route them to your own application, regardless of which port it is listening to.

Leave a Reply

Your email address will not be published. Required fields are marked *