• Resolved Kim Hornung

    (@keepmovingdk)


    I think I’ve found a bug in the wfUtils::serverIPs() function that causes Wordfence to make each request take 30+ seconds to execute.

    The issue only affects local installations with custom domain names that don’t contain a dot, such as “mytestsite” (but it doesn’t happen if you use “mytestsite.test” or “localhost”).

    Steps to reproduce:
    1) Install WordPress + Wordfence
    2) Configure the site to use a custom domain name WITHOUT a dot, such as “mytestsite”
    3) Open the frontpage of the website

    Result: The request takes 30+ seconds to load

    Expected result: The request should take less than a second.

    My environment: Apache 2.4 running PHP 7.4 on a MacBook Pro with a M1 Pro chip.

    The problem is the following line in wfUtils::serverIPs():
    $aRaw = @dns_get_record($host, DNS_A);

    When used with a value such as “mytestsite” on my machine, it takes 30 seconds.

    To fix this problem, you can simply add a “.” after the hostname. This also works for all other requests, such as “realdomain.com” (i.e. looking up “realdomain.com.”):
    $aRaw = @dns_get_record($host . ‘.’, DNS_A);

    Links to two resources where I found out that adding the dot is valid notation and that it solves timeouts/slow lookups when specifying a non-existent domain name:
    https://www.php.net/manual/en/function.dns-get-record.php#121278
    https://stackoverflow.com/a/14077874

    PS: The obvious workaround is to disable Wordfence when doing local development, which I’ve already done. But I thought you might want to know about this issue nonetheless.

    Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support wfpeter

    (@wfpeter)

    Hi @keepmovingdk,

    Thanks for providing this information, hopefully it’ll help others with their local environments in future through searches etc. I’d not encountered anybody doing this before as, like you mention, disabling Wordfence until it’s in a live environment is often the way developers will go.

    It’s unlikely we’d be able to alter the product itself for this to happen automatically but I’ve copied your solution to the development team as we’re always interested in this kind of information for issues our customers are facing.

    Thanks,

    Peter.

    Thread Starter Kim Hornung

    (@keepmovingdk)

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Wordfence takes 30 secs to load on localhost when using custom domain name’ is closed to new replies.