Sometimes instead of the real customer IP address, you can see or some other wrong customer IP in your Magento 2 Admin panel. It can be due to proxies, like Varnish, Cloudflare, that may be enabled for your Magento 2 store.

To solve the wrong IP address issue you need to:

1. Create a new file in M2 directory:


2. Paste the code:

<?xml version="1.0"?>
<config xmlns:xsi=""
<type name="Magento\Framework\HTTP\PhpEnvironment\RemoteAddress">
<argument name="alternativeHeaders" xsi:type="array">
<item name="x-client-ip" xsi:type="string">HTTP_X_REAL_IP</item>
                <item name="x-cf-connecting-ip" xsi:type="string">HTTP_CF_CONNECTING_IP</item>
                <!-- <item name="x-cf-mfcustom-ip" xsi:type="string">SOME_CUSTOM_SERVER_KEY</item> -->

3. Save the file, and run dependency injection compilation, use CLI command:

php bin/magento setup:di:compile

4. If this does not help, then you need to use other values instead of "SOME_CUSTOM_SERVER_KEY" and uncomment line. To get a proper value you need to create test.php file in your Magento folder with the code:

echo '<pre>';

and execute this script in a browser (URL: The purpose is to define the right key, that stores customer IP, you need to look for your IP.