Why Wordfence Shows the Wrong IP Address and How to Fix It
Content
One of the most common issues WordPress administrators face with the Wordfence Security plugin is incorrect IP address detection. Instead of seeing the real IP addresses of your visitors, you might see IPs from your Content Delivery Network (CDN), your hosting provider, or even your own server. This can lead to inaccurate blocking, failed login attempts from legitimate users, and skewed traffic data.
This guide will explain why this happens and walk you through the most effective solutions to get Wordfence displaying the correct visitor IPs.
Why Does Wordfence Show the Wrong IP?
Wordfence, like any web application, relies on information provided by your server to identify a visitor's IP address. When your site sits behind a proxy service—such as a CDN (like Cloudflare, QUIC.Cloud, or Azure Front Door), a load balancer (like Google Cloud Load Balancer), or a reverse proxy—the server often receives the IP address of that service instead of the original visitor.
For example, if you use Cloudflare, your server and Wordfence might only see Cloudflare's IP addresses in the REMOTE_ADDR server variable. The actual visitor's IP is typically passed along in a separate HTTP header, such as CF-Connecting-IP or X-Forwarded-For. Wordfence needs to be configured to look for the IP in the correct header.
How to Correctly Configure IP Detection in Wordfence
Fixing IP detection is usually a matter of telling Wordfence where to find the real IP address. Follow these steps.
Step 1: Determine Your Real IP Address
First, you need a baseline. Visit a site like WhatsMyIP.org from the device you use to administer your site. Take note of the IP address it shows you; this is your true public IP.
Step 2: Check Wordfence's IP Detection Settings
- Navigate to Wordfence > All Options > General Wordfence Options.
- Find the section titled "How does Wordfence get IPs".
- Just below the dropdown menu, Wordfence displays a line that says "Detected IP(s) and country" with the IP it currently sees.
- Try each option in the dropdown menu one by one, refreshing the page after each change. The options are:
- Use the X-Forwarded-For HTTP header.
- Use the X-Real-IP HTTP header.
- Use the Cloudflare "CF-Connecting-IP" HTTP header. (Only use this if you are using Cloudflare)
- After selecting each option, check the "Detected IP(s)" line. Your goal is to find the setting where the IP shown matches the real IP you noted from WhatsMyIP.org.
If one of these settings works, you're done! This is the most straightforward fix.
Step 3: Configure Trusted Proxies (If Necessary)
Sometimes, simply selecting a header isn't enough. If your proxy service sends multiple IP addresses in the X-Forwarded-For header, Wordfence might still pick the wrong one. This is where the "Trusted Proxies" setting comes in.
In the same General Wordfence Options section, scroll down to "Define trusted proxies".
- Here, you can enter the IP addresses or ranges of your proxy service (e.g., your CDN's IPs or your server's internal network range).
- By telling Wordfence which IPs belong to trusted proxies, it knows to ignore them and take the next IP in the chain, which should be the visitor's real IP.
- Many popular services have presets. Look for the "Trusted Proxy Preset" dropdown menu—if your service (like QUIC.Cloud) is listed, selecting it can automatically populate this field for you.
Example: If your server's internal IP is 10.110.19.84 and your CDN uses the range 100.64.0.0/16, you would add both to the trusted proxies list: 10.110.19.84, 100.64.0.0/16.
What If It Still Doesn't Work?
If you have tried all detection methods and configured trusted proxies but Wordfence still cannot detect the correct IP, the issue may be at the server level.
- The required HTTP header containing the real visitor IP (like
X-Forwarded-For) might not be being passed to WordPress by your host or proxy configuration. - In this case, you will likely need to contact your hosting provider's support or your CDN's support and ask them to ensure the original visitor's IP address is being passed through to the origin server.
Important Considerations
- Whitelisting: If your own IP is being blocked after making these changes, ensure it is correctly whitelisted in Wordfence > Firewall > Advanced Firewall Options > Allowlisted IP addresses. First, confirm Wordfence is detecting your IP correctly.
- Don't Bypass All Rules: Avoid adding your IP to the "Allowlisted IP addresses that bypass all rules" list unless absolutely necessary, as this disables all Wordfence protection for that IP, creating a security risk.
- Plugin Conflicts: In some cases, installing an official plugin for your service (like the Cloudflare plugin) can help resolve IP detection issues automatically.
Correctly configuring IP detection is crucial for Wordfence to function properly. By following these steps, you can ensure your firewall is blocking the right bad actors and allowing the right visitors.
Related Support Threads Support
-
Firewall not blocking any requests for bad urlshttps://wordpress.org/support/topic/firewall-not-blocking-any-requests-for-bad-urls/
-
allowlisted ip addresshttps://wordpress.org/support/topic/allowlisted-ip-address/
-
Unable to accurately detect IPs (Wordfence + QUIC.Cloud)https://wordpress.org/support/topic/unable-to-accurately-detect-ips-wordfence-quic-cloud/
-
Free WordFence working well: Can I ask a question?https://wordpress.org/support/topic/free-wordfence-working-well-can-i-ask-a-question/
-
Can We Configure So Only Certain IPs Can Access Backendhttps://wordpress.org/support/topic/can-we-configure-so-only-certain-ips-can-access-backend/
-
Whitelist ONLY Specific IP Rangeshttps://wordpress.org/support/topic/whitelist-only-specific-ip-ranges/
-
Can’t detect IPs accurately Issuehttps://wordpress.org/support/topic/cant-detect-ips-accurately-issue-2/
-
Not able to unblock iphttps://wordpress.org/support/topic/not-able-to-unblock-ip/
-
Starlink IP addresses being blockedhttps://wordpress.org/support/topic/starlink-ip-addresses-being-blocked/
-
Wordfence block verified Google crawlers…https://wordpress.org/support/topic/wordfence-block-verified-google-crawlers/
-
Allowlisted IP address (static) doesn’t work for longhttps://wordpress.org/support/topic/allowlisted-ip-address-static-doesnt-work-for-long/
-
wordfence blocking this IP: 13.74.50.26https://wordpress.org/support/topic/wordfence-blocking-this-ip-13-74-50-26/
-
Wrong IP block methodhttps://wordpress.org/support/topic/wrong-ip-block-method/
-
Wordfence stops working after adding a blocking on my .htaccesshttps://wordpress.org/support/topic/wordfence-stops-working-after-adding-a-blocking-on-my-htaccess/
-
Firewall %https://wordpress.org/support/topic/firewall-14/
-
HOw to remove IP address from firewall Optionhttps://wordpress.org/support/topic/how-to-remove-ip-address-from-firewall-option/
-
Unable to accurately detect IPs Type: IP Detectionhttps://wordpress.org/support/topic/unable-to-accurately-detect-ips-type-ip-detection-7/
-
dublicate querieshttps://wordpress.org/support/topic/dublicate-queries-2/
-
IP Addresses for WordFence?https://wordpress.org/support/topic/ip-addresses-for-wordfence/
-
Issue with detection visitors Ip addresshttps://wordpress.org/support/topic/issue-with-detection-visitors-ip-address/
-
Potentially unwanted allowed urlshttps://wordpress.org/support/topic/potentially-unwanted-allowed-urls/
-
Server ip address blocked by wordfencehttps://wordpress.org/support/topic/server-ip-address-blocked-by-wordfence/
-
Plugin uses cloudflare IP instead of actual visitor IPhttps://wordpress.org/support/topic/plugin-uses-cloudflare-ip-instead-of-actual-visitor-ip/
-
Wordfence Allowlisted IPhttps://wordpress.org/support/topic/wordfence-allowlisted-ip/
-
Function to get all blocked IPs / to add IPs to Wordfence block list?https://wordpress.org/support/topic/function-to-get-all-blocked-ips-to-add-ips-to-wordfence-block-list/
-
Malicious IPs getting through/how to contribute to real-time IP blocklisthttps://wordpress.org/support/topic/malicious-ips-getting-through-how-to-contribute-to-real-time-ip-blocklist/
-
X-Forwarded-For incorrect IP addresshttps://wordpress.org/support/topic/x-forwarded-for-incorrect-ip-address/
-
Wordfence IP Mask for Whitelistinghttps://wordpress.org/support/topic/wordfence-ip-mask-for-whitelisting/
-
Unexpected Outbound Connection from php-fpm to AWS IP (54.148.171.133:443)https://wordpress.org/support/topic/unexpected-outbound-connection-from-php-fpm-to-aws-ip-54-148-171-133443/
-
IP Blocking with Wordfence Central Templateshttps://wordpress.org/support/topic/ip-blocking-with-wordfence-central-templates/
-
Question about whitelisting user-agents by IP addresshttps://wordpress.org/support/topic/question-about-whitelisting-user-agents-by-ip-address/
-
Wordfence trusted proxy setting for Azure Front Door CDNhttps://wordpress.org/support/topic/wordfence-trusted-proxy-setting-for-azure-front-door-cdn/
-
REST API Blocked Despite Allowlisting GetResponse IPshttps://wordpress.org/support/topic/rest-api-blocked-despite-allowlisting-getresponse-ips/
-
block iphttps://wordpress.org/support/topic/block-ip-13/
-
I can not block an IP addresshttps://wordpress.org/support/topic/i-can-not-block-an-ip-address/
-
Wordfence Live Traffic: IP addresses from Cloudflarehttps://wordpress.org/support/topic/wordfence-live-traffic-ip-addresses-from-cloudflare/
-
IP 89.248.172.183https://wordpress.org/support/topic/ip-89-248-172-183/
-
Visitor Ip issuehttps://wordpress.org/support/topic/visitor-ip-issue/