'I get a "cURL error 28" when I try to install a new plugin or theme

I'm new to WordPress. I'm trying to complete the FreeCodeCamp tutorial now.

The tutorial explains how to install a new them. Whenever I click Install to install a new theme or plugin, the progress circle spins for about 10 seconds, and then I get the following error:

Installation failed: Download failed. cURL error 28: Resolving timed out after 10000 milliseconds

Some details about my setup/troubleshooting steps I've taken:

  • I have WordPress.org installed on a VM.
  • The OS on the VM is Ubuntu Server 20.04.
  • The value of $XDG_CURRENT_DESKTOP is LXQt.
  • WordPress Updates says I have the latest version of WordPress (5.9.3).
  • Site Health in wp-admin says, "Your site is unable to reach WordPress.org at 198.143.164.251, and returned the error: cURL error 28: Resolving timed out after 10000 milliseconds"
    • Don't know why I'm getting this error. A random webpage suggests running curl -s -w "%{time_total}\n" -o /dev/null 198.143.164.251. I did and 0.088994 was returned (suggesting the issue isn't with curl).
    • I've also already installed resolvconf and reconfigured DNS to point to Google's Public DNS.
  • Site Health in wp-admin also says I'm running PHP v7.4.3, cURL v7.68.0, and OpenSSL v1.1.1f. I think these are the latest versions of these software that can be installed on Ubuntu Server 20.04.
  • My ufw rules are (these apply for both v4 and v6:
    • 22/tcp ALLOW Anywhere
    • 22 ALLOW Anywhere
    • Apache ALLOW Anywhere
    • 80/tcp ALLOW Anywhere
    • 443/tcp ALLOW Anywhere
  • I've ran sudo ufw disable, just to see if ufw was causing the issue. It wasn't; the same issue persisted even after disabling ufw.
  • In /etc/php/7.4/cli/php.ini, memory_limit = -1
  • I don't have SELinux installed (I ran sestatus and Linux told me it couldn't find the command).
  • I've already disabled and uninstalled all of the plugins that came with the basic WordPress install.
  • I don't have a modsecurity directory in /etc .
  • I can't install the Query Monitor plugin. I'm in catch 22 -- this plugin could help me debug my problem, but I can't install any plugins because of this error I'm getting.
  • I've followed a StackOverflow post to reconfigure my PHP file. Also ran sudo systemctl restart apache2 for good measure.
  • I've added 198.143.164.251 api.wordpress.org to /etc/hosts file


Solution 1:[1]

Oh man, I found the issue. It's weird how constant googling and trying random things and just taking a break can help.

I was following Ubuntu's tutorial for installing WordPress. Currently their webpage says to install these packages:

sudo apt update
sudo apt install apache2 \
                 ghostscript \
                 libapache2-mod-php \
                 mysql-server \
                 php \
                 php-bcmath \
                 php-curl \
                 php-imagick \
                 php-intl \
                 php-json \
                 php-mbstring \
                 php-mysql \
                 php-xml \
                 php-zip

Turns out this webpage is missing some other php packages that we need to install. I found a DigitalOcean webpage that suggests installing these packages too: sudo apt install php-gd php-xmlrpc php-soap. I did this, then ran sudo systemctl restart apache2 again, just to be safe. After that, I logged in to wp-admin and clicked Install for a theme. The installation was almost instantaneous, no errors.

(A side note -- I'm using Firefox in the VM, and sometimes the browser was just slow. Had to follow the directions on a TechMint page to speed things up a bit).

My bad for not including a link to that Ubuntu page originally. If I had, I'm assuming someone would've noticed those missing php packages.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1