Emergence in Games

A Best Games Review Blog

32073 - Emergenceingame

Fix WordPress error showing Localhost IP address

Depending on the software that you install on your server and how it is configured, the client IP address may not be forwarded properly. Unfortunately, WordPress doesn’t have a built-in option to forward the client’s IP address. The following article Emergenceingames.com will guide you how to fix WordPress error displaying the IP address of Localhost on user comments.

On a regular web server, WordPress doesn’t have any problems with correctly displaying the IP addresses of site visitors or commenters, ….
wordpress installation shows the ip address of localhost

However, on some other servers, WordPress may not display the correct IP address in the comments dashboard or other locations. Instead, WordPress shows the IP address of Localhost as 127.0.0.1. So this article Emergenceingames.com will show you how to fix WordPress error showing Localhost IP address on user comments.

Fix incorrect IP address on WordPress

Note: Before editing any file in WordPress, you should create a backup file to avoid possible bad situations.

The simplest way to solve this problem is to add a code snippet to the “wp-config.php“. To do this, you open the FTP client, then log in to your FTP account and open the file wp-config.php.

wordpress installation shows the ip address of localhost 2

After opening the file, copy the code snippet below and paste it at the end of the file:

// Code for showing correct client IP address

if ( isset( $_SERVER[‘HTTP_X_FORWARDED_FOR’] ) ) {

$mte_xffaddrs = explode( ‘,’, $_SERVER[‘HTTP_X_FORWARDED_FOR’] );

$_SERVER[‘REMOTE_ADDR’] = $mte_xffaddrs[0];

}

wordpress installation shows the ip address of localhost 3

Then save the file and re-upload the file.

wordpress installation shows the ip address of localhost 4

From now on you will see the real IP address of the client on the WordPress comment page and other locations, that’s it, you have fixed WordPress error showing the Localhost IP address on user comments successfully.

What happens to Code Snippet?

When a WordPress site is behind an HTTP proxy or uses a load balancer, an HTTP called “X-Forwarded-For” is used to store all IP addresses including the actual client IP address in a string. .

By default, the IP address in X-Forwarded-For is separated by commas, and the first IP address in the string is always the IP address of the client.

What we do with the code snippet above is to get all those IP addresses, split them into separate parts and store them in an array. $mte_xffaddrs. Since the first IP address is related to the client, we can use the index Zero and point it to REMOTE_ADDR in array $ _SERVER.

Fix incorrect IP address on WordPress using Plugin

If you don’t want to touch the core WordPress files, you can use a plugin called Proxy Real IP. Although this plugin hasn’t been updated for a long time, it still works pretty well. Basically this plugin works like the code snippet above. The only difference is that the Real IP Proxy plugin uses the preg_match not a function explode.

Just install and activate the plugin just like you would with other plugins. There is no settings page or options to configure.

Download the Real IP Proxy plugin to your device and install it here: Download Proxy Real IP

wordpress installation shows the ip address of localhost 5

Fix incorrect IP address on WordPress using Cloudflare

When behind a proxy like Cloudflare, WordPress may sometimes show the Cloudflare IP and not the visitor’s real IP or the Localhost’s IP address.

There is a simple way to fix this problem. Just paste the below code at the end of the file wp-config.php:

// Fix incorrect IP when using Cloudflare

if ( array_key_exists( ‘HTTP_CF_CONNECTING_IP’, $_SERVER ) ) {

$_SERVER[‘REMOTE_ADDR’] = $_SERVER[‘HTTP_CF_CONNECTING_IP’];

}

wordpress installation shows the ip address of localhost 6

The above code gets the real IP address of the client using HTTP_CF_CONNECTING_IP and points REMOTE_ADDR to that IP address.

Above Emergenceingames.com has just shown you some ways to fix WordPress error displaying Localhost IP address on user comments. Are you experiencing this error? Don’t forget to share your opinion for Emergenceingames.com.

If you are learning about WordPress and want to experience this website platform, you can first install WordPress on localhost to gradually get acquainted and tinker, learn about it.

https://thuthuat.Emergenceingames.com/sua-loi-wordpress-hien-thi-dia-chi-ip-cua-localhost-32073n.aspx
After successful installation, you proceed with the steps to design and create wordpress according to your own opinion, the article creating WordPress will help you do this easier, Good luck!

Related keywords:

Fix WordPress showing IP address of Localhost

fix WordPress error, WordPress error showing Localhost IP address,

Source link: Fix WordPress error showing Localhost IP address
– Emergenceingames.com

Leave a Reply

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