Is there a reason "localhost" resolves to SERVER_ADDR "::1" under Apache?

I don't see any mod_rewrites or such, but PHP reports $ SERVER['SERVERADDR'] as "::1" when using "http://localhost" to access my local Apache server.

"http://127.0.0.1" works as expected.

Is this an artifact of all Apache servers on all hosts when referenced as "localhost"?

G5 Dual-2GHz; eMac G4-1GHz; Pismo G3; iMac (Intel); 2 MBPs, tv, ..., Mac OS X (10.5.4)

Posted on Dec 28, 2009 10:23 PM

Reply
3 replies

Dec 29, 2009 10:37 AM in response to Jon Milan

::1 is, indeed, the IPv6 equivalent of IPv4's 127.0.0.1, i.e. localhost

If your machine is configured to use IPv6 then the resolver will return IPv6 addresses by default, so that's why 'localhost' resolves to ::1 and that's what Apache/PHP report.

If you don't like that, turn off IPv6 in System Preferences -> Network. If your machine isn't running IPv6 then localhost will resolve to the IPv4 address you're familiar with.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Is there a reason "localhost" resolves to SERVER_ADDR "::1" under Apache?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.