My hosts file maps 127.0.0.1 to localhost.
$ curl -I \'localhost\'
curl: (7) Failed to connect to localhost port 80: Connection re
Since you have a ::1 localhost line in your hosts file, it would seem that curl is attempting to use IPv6 to contact your local web server.
Since the web server is not listening on IPv6, the connection fails.
You could try to use the --ipv4 option to curl, which should force an IPv4 connection when both are available.