Troubleshooting

Fix PHP cURL error 28 and other outgoing request errors

Fix cURL error 28 (operation timed out), error 6 (could not resolve host) and error 7 (failed to connect) when PHP, WordPress or Laravel call external APIs.

IntermediatecPanel hosting · Linux VPS3 min read

WordPress Site Health showing cURL error 28: Operation timed out, payment plugins failing, or a Laravel HTTP client throwing connection exceptions: all mean the server's outgoing request did not complete. The website itself may be fine. This guide covers the common cURL error numbers and how to fix them.

Before you start

  • The URL the code was calling (from the error message or log).
  • SSH access on a VPS; on cPanel hosting, Terminal access helps.

Know the error number

ErrorMeaning
6 Could not resolve hostDNS lookup failed on the server
7 Failed to connectConnection refused or blocked
28 Operation timed outNo (complete) response within the timeout
35 SSL connect errorTLS handshake failed
60 SSL certificate problemCertificate could not be verified

Reproduce from the server

curl -sv -o /dev/null -m 20 https://api.example.com/endpoint

Run it as the same server (not your laptop). Add -4 or -6 to test IPv4 and IPv6 separately. If curl on the command line also hangs, the problem is network/DNS/firewall; if it works there but not in PHP, look at PHP settings and the code.

Fix error 28: timeouts

  • IPv6 problems: the server has an IPv6 address but no working IPv6 route, so connections hang before falling back. If curl -4 works and curl -6 hangs, fix IPv6 or force IPv4 in code (CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4).
  • The remote API is slow or down: check its status page; nothing to fix on your side except retries.
  • Timeout set too low: WordPress's default HTTP timeout is 5 seconds for many requests. Raise it for a specific call ('timeout' => 20 in wp_remote_get) rather than globally.
  • Loopback requests time out (WordPress Site Health "loopback request failed"): the server cannot reach its own domain. Check that the domain resolves on the server to the right IP, and that a firewall or Cloudflare challenge does not block the server's own IP.
  • Outbound firewall: CSF or UFW rules blocking outgoing 443/80. Allow them in TCP_OUT or the outgoing policy.

Fix error 6: DNS

The server cannot resolve names. Test with dig api.example.com and fix the resolver configuration (see the name resolution guide).

Fix error 7: connection failed

  • Remote port closed or the remote side blocks your server's IP (check with the API provider; some require IP allowlisting).
  • Local outbound firewall rules.
  • Calling a local service on the wrong host or port (for example localhost inside a Docker container).

Update the server's CA certificates and OpenSSL, check the system clock, and make sure the remote site sends a complete certificate chain.

On cPanel hosting

Outbound connections are usually open, but the host may restrict some ports (for example SMTP 25) or IPs. If command-line curl from your account fails, contact support with the URL and error.

Check the fix

Rerun the curl test and the failing action (Site Health, plugin connection test, API call). The error should disappear from the logs.

cURL errors FAQ

Is cURL error 28 a problem with my website?

It is about requests your server makes, not visitors reaching you. But features depending on those requests (updates, payments, emails via API) will fail.

Should I just increase all timeouts?

No. Long timeouts make pages hang when an API is down. Raise them only for calls that legitimately take longer, and add retries.

Why does it fail only sometimes?

Intermittent DNS, an overloaded remote API or rate limiting. Log the timings to see patterns.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.