Reputation: 57
Problem
I've recently found out that PHP has a built-in webserver which can be used for development purposes. Starting the server with the address "127.0.0.1" and the port "8080" works without any problems and my requests are handled properly. However, if I dare to use the address "localhost" with the same port, the webserver doesn't handle any requests.
Specs
Upvotes: 1
Views: 498
Reputation: 78994
Name resolution for localhost
is handled by your DNS server which is likely resolving it to the IPv6 address ::1
.
If you run:
php -S 127.0.0.1:8080
The webserver is running on the IPv4 address but localhost
resolves to the IPv6 address.
So you can either use 127.0.0.1:8080
in the browser address bar.
Or force the address by un-commenting the following line from C:\Windows\System32\drivers\etc\hosts
:
# 127.0.0.1 localhost
Or bind the webserver to the IPv6 address (this is what I do):
php -S localhost:8080
Upvotes: 1