Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bad Request- Invalid Hostname while connect to localhost via wifi from mobile phone

Tags:

iis

localhost

I get the Bad Request- Invalid Hostname [HTTP ERROR 400] while trying connect my laptop's localhost. Actually, I am learning to develop mobile web using jQuery Mobile. I want to see the layout of the web whether fit my phone size.

i have added the port number which given by the Visual Studio with this way:
Control Panel> Firewall> Advanced Settings> Inbounce Rules> New Rule.
Then, i get my IP address by typing "ipconfig" at Command Prompt.
After that, I use my Android phone browser (Mozilla 5.0) and enter the link 192.XXX.XXX.XXX:57976.

I have read similar questions but I can't get the solution. Some people think this error is related to the IIS settings. But I can't get the solution of the IIS settings. Hope you guys can help me solve this problem.

like image 643
sky91 Avatar asked Feb 26 '14 14:02

sky91


People also ask

How do you fix a bad request invalid hostname?

The issue occurs because IWSVA overwrites the Host header in the HTTP request with the IP or FQDN of the web server configured in IWSVA. To resolve the issue, configure IWSVA not to overwrite the Host header: Open the /etc/iscan/intscan. ini configuration file of IWSVA and set “ProxyPreserveHost" to "yes".

What is invalid host name?

Invalid Hostname - TCPShield. If your server shows "Invalid Hostname" when querying on the serverlist, this usually means you are accessing a domain (or IP) pointed to our network, but not actually registered within our database.


1 Answers

Step 1: Add Inbound Rule of Windows Firewall

Windows Firewall

  1. Open the Windows Firewall with Advanced Security.
  2. At the left panel, right click on Inbound Rule > New Rule
  3. Rule Type: Port
    Protocol and Ports: TCP
    Specific local ports: 57976
    Action: Allow the connection
    Profile: Tick all (Domain, Private, Public)
    Name: Name, Description(optional)
  4. Finish.

Step 2: IIS or IIS Express

Add Bindings of IIS Manager

IIS Manager

  1. Open the IIS Manager.
  2. At the left panel, Go to Sites > Default Web Sites.
  3. At the right panel, click on the Bindings. Then, the new dialog pop ups.
  4. At the pop-up dialog, click on the "Add" buttons. Input the port number and the hostname.
    For my case,
    port = 57976;
    hostname = 192.XXX.XXX.XXX (my IP address)

Add Bindings of IIS Express (Visual Studio)

IIS Express

  1. Stop the current Site
  2. For Visual Studio 2015, change the IIS config under your project folder C:\Projects\<ProjectName>\.vs\config\applicationhost.config‌​.
  3. For previous version of Visual Studio 2015, change the IIS config under IIS Express folder C:\Users\<your profile name>\Documents\IISExpress\config\applicationhost.config
  4. In applicationhost.config, search by the port number (for my case is 57976), then one more binding with your IP Address

        <site name="Web(1)" id="9">       <application path="/" applicationPool="Clr4IntegratedAppPool">         <virtualDirectory path="/" physicalPath="E:\abc\project\dev\web" />       </application>       <bindings>         <binding protocol="http" bindingInformation="*:57976:localhost" />         <binding protocol="http" bindingInformation="*:57976:192.XXX.X.XXX" />       </bindings>     </site> 

Updated:

For windows 10 or Visual Studio 2015 users, you may get the error message below:

Unable to launch the IIS Express Web server, Failed to register URL, Access is denied 

Solution:

  1. Close Visual Studio
  2. Right click on Visual Studio > Run as Administrator



Reference: https://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-how-to-configure-iis-express/

like image 131
sky91 Avatar answered Sep 19 '22 12:09

sky91