HTTP_X_REAL_IP is missing?

Hello! I was using Cloudflare about one year so far.
I need to use and get the user real ip address so i get their location and so on.
However today i saw that the HTTP_X_REAL_IP key in the $_SERVER variable is missing. This was the only key, that was containing the real ip address.Can someone tell me what is happening? Why this is missing now? And is there some setting in my website profile, that i have to do to bring it back?

I didn’t think that X-Real-IP was ever sent? So I would check whether your backend software changed what that is referencing.

I would try HTTP_CF_CONNECTING_IP instead.

I will ask my hosting, did they update something, but my php framework is not touched at all.
I checked the whole $_SERVER variable, and right now, there is nothing containing my ip address.

If the request is proxied through Cloudflare then two headers are sent, X-Forwarded-IP and Cf-Connecting-IP. PHP should expose those in $SERVER, if it’s not then either the request isn’t Cloudflare proxied or something has gone wrong at the hosting/PHP side.

That said, another possibility is that “Remove visitor IP headers” is configured under Transform Rules > Managed transforms, so I suggest checking that as well:


I have only these:
“HTTP_X_FORWARDED_FOR” => “246.204.222.XXX, 162.158.60.XXX”
“HTTP_CF_RAY” => “88eb219ab9da3139-XXX”
“HTTP_CF_VISITOR” => “{“scheme”:“https”}”
“HTTP_CF_CONNECTING_IP” => “246.204.222.XXX”
“HTTP_CDN_LOOP” => “cloudflare”
“HTTP_CF_CONNECTING_IPV6” => “2a01:5a8:30c:2c20:105e:13c0:6f15:XXXX”
“HTTP_CF_PSEUDO_IPV4” => “246.204.222.XXX”

But non of them are containing my IP.
I just google for some information, and i indeed remembered that they were these 3 before:


“Remove visitor IP headers” was disabled.
I enabled “Add visitor location headers” but the real ip is still missing :confused:

You’re connecting over IPv6, so HTTP_CF_CONNECTING_IPV6 is showing you your IPv6 address and HTTP_CF_CONNECTING_IP was rewritten to show you a fake IPv4 address since you have the feature “Pseudo IPv4” enabled. You won’t see your real IPv4 address unless you connect over IPv4 (which is impossible to guarantee, hence the fake IPv4 option)

The system is working as designed there.


Yes, i just realized that the ipv6 is correct, and checked the $_SERVER value from my other network.
There the correct ipv4 is showed in ‘HTTP_CF_CONNECTING_IP’.
Somehow they change my network and right now reports me that i have 2 ip’s in the same time.
I will change my system to check for ipv6 and then ipv4.
Thank you for your help!

1 Like

Happy to help! Glad you worked that out.

Yep, your setup will have access to IPv6 now when it didn’t before. Which is a great thing.

Right now, i saw that i have IPv4 and IPv6 in the same time.
I saw that Cloudflare disabled the option to disable the IPv6 Compatibility, but is there any setting, that i can change my preference? To show the IPv4 and then if not existing to show the IPv6?

That’s not possible. A web request uses either IPv4 OR IPv6, not both. Most likely the website you used to check your IP was doing some smart checks in the background using multiple web requests to extract both of them (for example requesting IPv4-only and IPv6-only resources). Cloudflare gets whatever IP version your web browser sends the request using.

Well, lets say that. I have multiple websites. Some are using cloudflare, some not.
The dev website, that is not using cloudflare is giving my IPv4. The same function, but on the production version, that is using cloudflare is giving my IPv6. So somehow Cloudflare is prioritizing the IPv6 over the IPv4

Cloudflare isn’t the one prioritising anything.

Cloudflare supports both IPv4 and IPv6. Your other web host may only support IPv4. Your network and thus browser, support both and will try to use whichever one they want based on a few factors, usually slightly favouring IPv6. If your other web host supported IPv6 the same as Cloudflare does, you would see the same behaviour.


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.