Http request failed. Error: cURL error 28: Operation timed out

I’m trying to build a WordPress plugin to make a GET request to the server that I’m running on Local. This is not a request to a remote server (server external to the one running on Local). It’s an internal server request ( a request to the very server that the site is running on ).

I’m using the WordPress API function wp_remote_get( home_url() ); and then outputting the result to the front end. It returns the following error message:

http_request_failed =>
[ 0 => “cURL error 28: Operation timed out after 5000 milliseconds with 0 bytes received” ]

I’ve set the $args parameter in wp_remote_get() as high as 300 seconds ( 5 minutes ). No effect. Error returned.

Checked the nginx configuration file.

http {
fastcgi_read_timeout 1800s;
proxy_read_timeout 1800s; // Added this.
}

Eighteen hundred seconds for a timeout (30 minutes) seems plenty long. No effect. Error returned.

A colleague who is running this plugin right now (which runs wp_remote_get() ) on a site hosted by Local has no problems running this WP function and returning the response header and body from her local server. So it suggests there’s something off with my setup.

Here’s what I know about my own system thus far:

- OS: MacOS 10.14.6 (Mojave) 
- Local: v5.2.5+2498
- local firewall on my computer: off
- ISP: AT&T, which operates a firewall on their router. Not sure that it matters since I’m not making external server requests via my ISP. 
- Xcode v11.3.1. I accepted their terms of service. Not running in the background. 
- DNS Settings for my ISP: {
4.4.4.4
8.8.8.8
    8.8.4.4
}  // I think these were set for the benefit of Google Chrome. 

From the router log 2 days ago (formatted for readability):

2020/03/03 20:43:19 [error] 

17718#0: *9 upstream prematurely closed connection while reading response header from upstream, client: ::1, 
server: ktcstarter.local, 
request: "GET / HTTP/1.1", 
upstream: "http://127.0.0.1:10000/", 
host: "ktcstarter.local", 
referrer: "http://ktcstarter.local/"

What do I need to investigate to evaluate and hopefully resolve this problem?

After more research on possible sources of cURL errors, and investigating the active processes running on my computer, I think I can ask a more pointed question about this problem.

Is Local’s nginx server configured to use a web application firewall? I inspected the following config files for a Local site that I’m testing.

  • /nginx/nginx.conf.hbs
  • /nginx/site.conf.hbs
  • /nginx/includes/restrictions.conf.hbs

I didn’t see anything in those files that directly addresses mod_security ( the nginx web application firewall ), or any other specific reference to a firewall.

There’s either:

(1) a conflict between Local and another application running on my computer, or

(2) a setting in Local that prevents a site from making a GET request to the server that’s it’s running on.

When I invoke the WordPress API function:

wp_remote_get( home_url() );

to query the value of home_url, I receive the following error:

‘cURL error 28: Operation timed out after XXX milliseconds with 0 bytes received’.

Aside: The wp_options database table assigns option name (key) of ‘home’ to the value returned by ‘home_url()’.

In anticipation of a possible response:

‘Hey, wp_remote_get() only makes GET requests to servers remote from the one making the call’.

I would say ‘not true’. Why? Because this code works on another instance of Local run by a major WP plugin products company. There is something different between the environment on that computer and mine.

The task here is to determine what that difference is and resolve it, so that I can make a GET request to the same server on which the code is making the call.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.