Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should a MAMP return ::1 as IP on localhost?

I need to retrieve a user's IP. My localhost is returning ::1 as the IP. I am curious, if this is an expected behaviour? I'm running MAMP on Snow Leopard.

like image 916
Mild Fuzz Avatar asked Sep 13 '10 10:09

Mild Fuzz


People also ask

How do I run Mamp on localhost?

Starting MAMP If you don't see the Welcome page, go to http://localhost:8888/MAMP/ in your browser. From the control panel, you can stop your local servers by clicking Stop Servers, or start them by clicking Start Servers. You can also open the Welcome page, and access Preferences.

Is IP address same as localhost?

On almost all networking systems, localhost uses the IP address 127.0. 0.1. That is the most commonly used IPv4 “loopback address” and it is reserved for that purpose.

Is localhost IPv4 or IPv6?

The name localhost normally resolves to the IPv4 loopback address 127.0. 0.1, and to the IPv6 loopback address ::1.


1 Answers

Same question, and found a valid solution, tested, works well. I wanted to have the ip addy - of 127.0.0.1 as well instead of having to accept the the ::1 and debate the whole IPv4/6 issues. So, i trolled for a few moments and fell onto a 2008 comment made by @Brad - here: http://board.issociate.de/thread/489575/SERVERquotREMOTEADDRquot-returning-1.html

Summarizing - (on Mac OS - Mountain Lion in particular)

sudo vi /etc/apache2/httpd.conf

Find where your apache is 'listen'-ing to the ips/ports, etc... Typically this will be a line looking like this

Listen 80

Make it look like this:

Listen 127.0.0.1:80

Resave it. Restart Apache. Voila!

Now $_SERVER[REMOTE_ADDR] will look like this 127.0.0.1.

Hope it helps someone.

like image 175
Bill Ortell Avatar answered Sep 25 '22 19:09

Bill Ortell