504 Gateway Timeout on WP Plugin Update

This site is running on Nginx with PHP-FPM, on vanilla Debian. I’m thinking of trying out OpenLiteSpeed and some other PHP alternative.

Anyways, I always get 504 errors when I update any plugin or WordPress itself.

504 Update Failure 2

This problem was bugging me for the past month or so. It would give that error while updating, instead of a success/failure message. The updates always succeeded though.

Unfortunately, this story will need to be cut short. By sheer luck, I found the problem. It was the DNS resolvers.

Simply changing /etc/resolv.conf was not an option for me since the system simply re-wrote the file. Marking it as immutable with chattr +i /etc/resolv.conf caused issues.

resolv.conf Bug
Bug caused by immutable resolv.conf. On every DHCP renew, a new resolv.conf appeared.

Here’s what I did:

  • Installed resolvconf usingĀ apt-get install resolvconf
  • After that, I edited /etc/resolvconf/resolv.conf.d/head
    • Added Google and OpenDNS nameservers:
      • nameserver 8.8.8.8
        nameserver 208.67.222.222
        nameserver 8.8.4.4
        nameserver 208.67.220.220
  • After editing the file, I updated the system resolver usingĀ resolvconf -u
  • I then verified if the proper nameservers were added in /etc/resolv.conf.
    • If correct, your added nameservers should be above the ones that DHCP gives you.
Success
Success

Yes, I know there may be better solutions out there like changing dhclient config files, but that usually didn’t work for me in the past.