How to Resolve WordPress showing IP for Visitor’s Comments.

You might come across this issue if you have your site on a hosting (like Cloudways) that uses Varnish Cache you may see  as your visitor’s IP here’s a simple solution on how you can resolve this issue.

Step 1: Login in your Server via SSH

The very first is to login in your account is login in the server via SSH if you don’t know how to login in your server via  SSH simply refer to the official Cloudways guide here:

Step 2: Goto your Application’s Webroot

After logging into SSH, navigate to main sites public_html directory. Here wshqpdcabz is my main WordPress app. you can use the command below to go in your site’s public_html folder

cd /home/master/applications/wshqpdcabz/public_html/

Remember to change wshqpdcabz with your app folder name.

Step 3: Edit wp-config.php

Add below code just before /* That’s all, stop editing! Happy blogging. */

# Use X-Forwarded-For HTTP Header to Get Visitor's Real IP Address
if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
    $http_x_headers = explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] );

    $_SERVER['REMOTE_ADDR'] = $http_x_headers[0];

Let us know if the guide was helpful or not, share your reviews in the comment section

Leave a Reply

Your email address will not be published. Required fields are marked *