PHP Warning: Undefined array key "REMOTE_ADDR"

Home Forums Support Forum PHP Warning: Undefined array key "REMOTE_ADDR"

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  Anti-Malware Admin 6 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #115157

    Lina Grebe
    Member

    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

     

    #115168

    Anti-Malware Admin
    Key Master

    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.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Comments are closed.