CF-Connecting-IP returns NULL in latest version of Workers?

Hi folks,

a couple of weeks ago I developed a small script to test how Workers performs, but today I tested the live service and it seems the CF-Connecting-IP header always returns null, and before it returned the IP of the remote client. I have also tested it in the old Cloudflare Workers sandbox and I get the same error: it returns null and not the IP address.

Here goes the gist: Using Cloudflare Workers and API add to the request headers information of the blacklists of abusers that contains the IP address of the client. · GitHub

Did I miss something? Is this still the right way to get the IP address of the remote client?


Hi Diego,

Hmm, I just tested this now, and it seems to work for me, both in production and in the preview. (By the way, we update the preview every week along with the Workers runtime, so it isn’t “old”. :slight_smile: )

Here’s a site implemented as a Worker that returns the headers it sees:

I see cf-connecting-ip showing my IP address, tested from multiple locations.

What do you see?

Hi Kenton!

Ok, I found out what was going on: the worker gets the IP from cf-connecting-ip if I use the Preview mode. But I tried the Testing mode and then cf-connecting-ip has null. Obviously, it was my mistake because I did not get the difference between both modes. :crazy_face:

Thank you very much for your support. I really love this product!


P.D.: ‘Old’ because you have a shiny and awesome new product available to everyone. :heart_eyes:

Ah, yes. In “Testing” mode, the idea is you can supply your own cf-connecting-ip value, so that you can test what happens if the IP isn’t your own. But I get how that’s not totally clear. We should probably automatically initialize all the usual headers in the request editor, and then let you modify from there.

1 Like