John John - 1 year ago 103
PHP Question

IP Address of the machine in PHP gives ::1 but why?

I am trying to fetch the ip address of my machine through php. For that I am writing the code like:

<?php echo "<br />".$_SERVER['REMOTE_ADDR'];?>

But this piece of code is not working. It is returning "
Please help me how to get the actual IP Address.

Answer Source

::1 is the actual IP. It is an ipv6 loopback address (i.e. localhost). If you were using ipv4 it would be

If you want to get a different IP address, then you'll need to connect to the server through a different network interface.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download