IIS Returning Bad Request - Invalid Hostname when accessing via IP address but not localhost

Sean Patterson 0 Reputation points
2024-12-24T15:23:43.2166667+00:00

We have a server that suddenly started returning an HTTP 400 for Invalid Hostname after a reboot today. We have multiple other servers in the environment running the same configuration, OS version, patches etc. but do not see this issue.

This IIS server hosts several dozen IIS sites that are all configured similarly. HTTP binding, IP Address set at All Unassigned, Host Name field left blank with a unique non-conflicting port.

User's image

After a server reboot this morning, when we attempt to access any sites hosted on this server via IP address directly we are receiving the Invalid Hostname error however when attempting to access via hostname (localhost, server name, via a WAF with the host header being passed) we are properly receiving a response.

For example the following URLs fail:

http://127.0.0.1:1234/index.html

http://<serverIP>:1234/index.html

However these URLs work:

http://localhost:1234/index.html

http://<serverName>:1234/index.html

https://domain.com/index.html (which is forwarded by the Web App Firewall to the internal server on http with the host header containing the original request URL)

This is occurring with all sites hosted on this specific server, but not on other servers in the same environment with what should be identical configurations that also did a reboot this morning.

I cannot find any configuration differences between this server and ones that are working and am not seeing any sort of errors logged that would help me troubleshoot the issue further. The httperr log is reporting all of the invalid hostname requests like this:

2024-12-24 09:40:13 <sourceIP> 49756 <destIP> 18041 HTTP/1.1 POST <url> - 400 - Hostname W3SvcInspection

Where else can I look for logs to understand why IIS is returning the Invalid Hostname error?

Edit:

To confirm that I'm looking at the same site:

User's image

This is the confit for a test site.

http://localhost:19123 works fine

http://<servername>:19123 works fine

http://127.0.0.1:19123 returns invalid hostname

http://<serverIP>:19123 returns invalid hostname

These are the entries in the httperr log for the last 2 when running directly on the server:

2024-12-24 18:17:51 127.0.0.1 58322 127.0.0.1 19123 HTTP/1.1 GET / - 400 - Hostname W3SvcInspection

2024-12-24 18:17:51 127.0.0.1 58323 127.0.0.1 19123 HTTP/1.1 GET /favicon.ico - 400 - Hostname W3SvcInspection

2024-12-24 18:17:59 <serverIP> 58328 <serverIP> 19123 HTTP/1.1 GET / - 400 - Hostname W3SvcInspection

2024-12-24 18:17:59 <serverIP> 58329 <serverIP> 19123 HTTP/1.1 GET /favicon.ico - 400 - Hostname W3SvcInspection

Internet Information Services
{count} votes

1 answer

Sort by: Most helpful
  1. MotoX80 34,776 Reputation points
    2024-12-24T20:23:54.1166667+00:00

    The word W3SvcInspection should be a clue about what's going on, but an internet search doesn't show much. I found that in iisw3adm.dll but surrounding text doesn't point to any specific function.

    I can recreate the 400 error with a bogus hostname, but I don't see W3SvcInspection in my httperr log. That's on Win11.

    Do you have any isapi filters or redirects that might affect the request url? Does "inspection" ring any bells?

    If you add a bogus hostname to the site so that all requests fail, do you see W3SvcInspection on all/any 400 entries in the httperr log?

    User's image

    What about defining a simple new site and putting it on a different port. If that works then it would point to some configuration setting in the existing site.

    If you don't find anything, then the next step is to configure Failed Request Tracing and capture the 400 error.

    https://learn.microsoft.com/en-us/troubleshoot/developer/webapps/iis/health-diagnostic-performance/troubleshoot-arr-using-frt-rules

    There are other sites on the net like this one that offer instructions on FRT if you run into problems.

    https://4sysops.com/archives/iis-failed-request-tracing/

    The biggest issue with FRT that I've experienced is with browsing the XML trace files. I've had to load MSEdge in IE Mode (from the 3 dot menu) to get it to format the file.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.