Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Fix curl error 28 connection timed out

· 4 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To fix curl error 28, you must increase the timeout limit in your application settings or resolve the network blockage preventing the server from responding. This error occurs when the client waits for a response from the server for a set amount of time and the server fails to reply before that limit is reached.

What You'll Need

  • Administrative access to the server or computer running the curl command.
  • Access to your web hosting control panel or server configuration files.
  • Knowledge of the specific application or plugin triggering the error (e.g., WordPress).

Step-by-Step

  1. Increase the Timeout Limit
    If you are using curl via a command line, add the --connect-timeout or -m (max-time) flag to allow more time for the connection. For example, curl --connect-timeout 30 [URL] gives the connection 30 seconds to establish. If you are using a plugin or CMS, look for "Timeout" settings in the application options and increase the value from 5 or 10 seconds to 30 or 60 seconds.
  2. Check Server Resource Limits
    Low memory (RAM) or CPU exhaustion can cause a server to respond too slowly, triggering a timeout. Check your server's resource usage via a system monitor. If memory is full, restart unnecessary services or upgrade your hosting plan.
  3. Verify DNS Resolution
    If the DNS cannot resolve the hostname quickly enough, curl will time out. Try pinging the destination URL. If the ping fails or takes several seconds to start, try switching your DNS providers to a more reliable service.
  4. Inspect Firewall and Security Rules
    Firewalls can silently drop packets, leading to a timeout. Check your server's firewall (such as ufw or iptables) and any external cloud firewalls. Ensure that the outgoing port (usually 80 for HTTP and 443 for HTTPS) is open and that the destination IP is not blacklisted.
  5. Disable Conflicting Plugins or Modules
    In environments like WordPress, a security plugin or a caching tool may interfere with loopback requests. Temporarily disable security plugins one by one to see if the error disappears.
  6. Update PHP and cURL Versions
    Outdated versions of PHP or the cURL library may have bugs or lack support for newer TLS protocols, causing connection delays. Update your environment to the latest stable version provided by your host.

Common Mistakes

  • Setting the timeout too high: While increasing the timeout can fix the error, setting it to an extreme value (like 3600 seconds) can hang your server processes and lead to a "Maximum Execution Time" error.
  • Ignoring the server logs: Many users try to fix the client-side timeout without checking the server-side error logs, which often contain the actual reason why the request was dropped.
  • Confusing timeout with 404/500 errors: Error 28 is a connectivity issue, not a "page not found" or "internal server error." Changing the URL or the page content will not fix a timeout.

Tips

  • Use Verbose Mode: When running curl from the command line, use the -v flag. This provides a detailed log of the handshake process, showing exactly where the connection stalls.
  • Test with a Different URL: Try running a curl request to a reliable site like google.com. If that works, the issue is specific to the destination server, not your local configuration.
  • Check for Loopback Issues: If your server is trying to call itself (a loopback request), ensure the server's own IP address is not blocked by its own firewall.

Troubleshooting

If the steps above do not resolve the issue, follow these diagnostic steps:

  • Check the Host Status: Use a third-party "Is it down" service to verify if the destination server is actually online. If the remote server is down, no amount of configuration on your end will fix error 28.
  • Test via a Different Network: If possible, run the same request from a different network or a different server. If it works elsewhere, your current network or ISP is likely blocking the traffic.
  • Review Proxy Settings: If your server uses a proxy to access the internet, ensure the proxy settings are correct in your environment variables or application config. A misconfigured proxy is a frequent cause of timeouts.
  • Contact Hosting Support: If you are on shared hosting, you may not have permission to change firewall rules or DNS. Contact your provider and provide them with the specific destination URL and the error code.

Frequently Asked Questions

Why does curl error 28 happen in WordPress?

It usually happens during site health checks or plugin updates when the server cannot complete a loopback request to itself, often due to firewall restrictions or low server resources.

Is curl error 28 a DNS problem?

It can be. If the DNS lookup takes too long, the connection will time out before the request even reaches the destination server.

Will increasing the PHP memory limit fix this?

Not directly, but if the server is crashing due to memory exhaustion, it may stop responding to requests, which results in a timeout.

Does a slow internet connection cause this?

Yes. If the network latency is higher than the defined timeout limit, curl will terminate the connection and return error 28.

Can a VPN cause curl error 28?

Yes, if the VPN is misconfigured or if the destination server blocks the VPN's IP range, the request may time out.