up vote 1 down vote favorite
share [g+] share [fb]

I want to specify host names with two different ports in the Windows hosts file.

Is there a way to do it? Or is it not allowed by Windows itself?

I have been wasting my time searching for the solution for the last 8 hours.

Is it possible to specify ports in the host file, hosts? E.g.: 127.0.0.1:80 and 127.0.0.1:9211

link|improve this question
The HOSTS file only associates names with IP addresses, not IPs+port(s). Do check superuser.com, however, by describing more of the specifics of what you are trying to do (is this for a web server etc. etc.) as there are many ways to achieve this type of mapping, but always depending on specifics at hand. – mjv Feb 21 '10 at 18:44
feedback

migrated from stackoverflow.com Feb 21 '10 at 18:45

This question came from our site for professional and enthusiast programmers.

1 Answer

You cannot associate a port number with a hostname mapped to an IP in the hosts file. You can achieve this with Fiddler though using FiddlerScript:

if (oSession.HostNameIs("somesite.com")){
    oSession.bypassGateway = true;
    oSession["x-overrideHost"] = "1.2.3.4:8080";
}
link|improve this answer
feedback

Your Answer

 
or
required, but never shown