Shouldn't the value match the IP of the computer that's requesting the script regardless of the fact that it's the same computer that's hosting the script?

  • 12
    "That's when I run PHP locally." totally answers your own question. No? – Tomalak Aug 26 '11 at 12:35
  • No, it doesn't. – Emanuil Rusev Aug 26 '11 at 13:01
  • 2
    Please edit in the URL you're accessing as well, or a facsimile of it, and possibly some more information. As it stands now the question is of very low quality, and risk being closed as such. – Lasse V. Karlsen Aug 26 '11 at 13:10
  • If you feel that the question adds no value then go ahead and close it. I got the answer I was looking for. – Emanuil Rusev Aug 26 '11 at 13:17
  • 2
    Far fetched != impossible. Once the OP stated he doesn't know, it doesn't matter how far fetched it sounds even if it's coming from a high reputation user. – Rikudo Sennin Aug 26 '11 at 16:06

Because when you run PHP locally every request you make will come from your machine, which happens to have a remote (or in this case, local) address of... wait for it.... (== localhost).

Elaboration: Let's assume for a second you have no internet connection, nothing at all, no WiFi, no cable. The local connection would still work. Why? because it would be stupid to require internet connection for local affairs. Instead, the connection comes from the server itself which means, you will see localhost or as the remote address, because that's the remote address of the server, relatively to the server.

  • 1
    Did you ever watch "How I met your mother"? :p – genesis Aug 26 '11 at 12:38
  • That's the thing. My machine has a remote address. Why do I get the local "" instead of it? – Emanuil Rusev Aug 26 '11 at 12:58
  • What do you mean by "has a remote address"? Unless you've borked your network setup, your machine also has as an address, and this is used as the source address. – Lasse V. Karlsen Aug 26 '11 at 13:00
  • I mean that it has a regular address that looks something like 95.87... – Emanuil Rusev Aug 26 '11 at 13:02
  • Still... is obviously the one used. – Lasse V. Karlsen Aug 26 '11 at 13:02

The reason for this is that you're talking to

When talking to a network device (local machine or otherwise), packets has to have a source address, and an address is picked that will be available in the network you're communicating over.

So the source address used depends on the target address being communicated with.

Since the server is reporting that you're coming from, you will have to be talking to, because that's the only target address where that source address would've been picked.

If you had talked to your machine using its IPv6 local address (::1), then you would've seen ::1 reported as the source address as well.

However, in order to see the 95.87... address, you need to be talking to that address as well.

You can try that by simply replacing the hostname or localhost or whatever you wrote in the URL with 95.87... for the hostname part, and it should report that you're also coming from that address.

My guess is that you're doing http://machinename, which is resolving to, and thus the address was picked as the source address as well.


because localhost ===


It is a local connection.

The connection is being made locally. You local IP address for your localhost is

No connections are being made through any other network other than your localhost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.