Search code examples
phpwindowsapachehostname

Webserver hostname issue after Win10 April update


I have web server in my local network (Apache/2.4.10 + PHP 5.6.36 on Raspbian GNU/Linux 8 (jessie) 4.9.35-v7+ on Raspberry Pi) with hostname webserver. Then I'm also using a local webserver (localhost) on my workstation (Win 10 Home 64bit + Apache/2.4.25 + PHP 7.1.4).

After update to Win 10 "April update" (1803) I have this issue: when a PHP script on my localhost (i.e. workstation) tries read some file from webserver via file_get_contents()

$content=file_get_contents("http://webserver/file.php");

I get this error:

php_network_getaddresses: getaddrinfo failed: The requested name is valid, but no data of the requested type was found.

When I change hostname to IP address (http://192.168.1.100/file.php) then it works. Also there is no problem when I put http://webserver/file.php directly in my broswer (on workstation). The problem is only when a script from localhost (workstation) is trying to reach address on webserver with hostname in address.

Before Win 10 April update everything worked fine, so where can be a problem? I have installed all Windows updates but it didn't help...


Solution

  • Check your HOSTS file in C:\windows\system32\drivers\etc\HOSTS

    Some Windows updates replace this file with a default, which would explain why you can no longer access the server as there will be no reference to it in the HOSTS file.