Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP $_SERVER['REMOTE_ADDR'] sometimes resolves to empty string

Tags:

php

When accessing my site from a number of machines $_SERVER['REMOTE_ADDR'] always resolves to an empty string. What can be the cause of this?

Additional info: One of the machines is running the site on localhost. Shouldn't a machine on localhost always resolve to 127.0.0.1?

My set up is LAMP. One dev. machine that runs the site localhost and that has the problem is a Mac and runs XAMPP. I think our live staging environment is CentOS (shared host).

like image 599
Luke Avatar asked Jul 30 '26 00:07

Luke


1 Answers

I guess this results from a missing reverse delegation for the address. You should avoid reverse resolution unless absolutely necessary.

Not only is it expensive in terms of latency, but can also yield unexpected results as there is no requirement on what to resolve to - or to resolve at aall.

like image 123
Jan Jungnickel Avatar answered Aug 01 '26 16:08

Jan Jungnickel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!