Hello,
I have set up a server-side cronjob and keep getting the following error message:
PHP Warning: Undefined array key “REMOTE_ADDR” in /var/www/vhosts/***/html/***/wp-config.php on line 1
I will not receive these as soon as I deactivate the brute force protection.
After consulting with the support of my hosting provider, it is because the protection is only limited to one IP address and therefore the cronjob error is triggered.
Is there a way to fix this error?
Warm regards
Lina
Your hosting support did not understand or explain the problem correctly, but I can help make it clear and present a workaround for you to use to get rid of that error without disabling the Brute-Force Protection.
First, just to clarify, the first part of that if statement on linw 1 or your wp-config.php file is not limit the protection to one IP but rather to exclude the given IP from the Brute-Force Protect (effectively whitelisting your originally detected admin IP address).
if (!in_array($_SERVER["REMOTE_ADDR"], array(“*********”)) && file_exists(…
The problem is that your cronjob executes the PHP process without setting the $_SERVER environment variable indexed as “REMOTE_ADDR”. This causes the PHP Warning message you are seeing.
The simplest solution is to just remove that first condition from the if statement, leaving the file_exists condition intact. This would result in the first line of your wp-config.php file starting like this:
if (file_exists(…
Please let me know if you need any further assistance with this.