I am struggling with a Local site running on my iMac using Local 5.2.3, though this issue dates back to the old Local that ran on VirtualBox as well. This is a clone of a client site that runs WP multisite with a number of heavy plugins.
Every now and then (but usually within 6 to 12 requests or so) this site just stops responding. I don’t see any error messages on the router or site error logs for nginx or PHP. The site just does not respond and my only way to kick it in the pants is to go to Local and “restart” the site.
When I restart the site any browser waiting for a response suddenly shows 502 (which makes sense) and the site works fine as soon as it comes up (until the next time it hangs).
From curl these hangs look like this…
curl --insecure --verbose https://rea-again.local
* Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 443 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to rea-again.local (127.0.0.1) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use h2
* Server certificate:
* subject: CN=rea-again.local; C=XX; ST=XX; L=Fake Locality; O=Super Fake Company, Fake.; OU=Fake Organizational Unit
* start date: Oct 23 19:46:39 2019 GMT
* expire date: Oct 23 19:46:39 2029 GMT
* issuer: CN=rea-again.local; C=XX; ST=XX; L=Fake Locality; O=Super Fake Company, Fake.; OU=Fake Organizational Unit
* SSL certificate verify result: self signed certificate (18), continuing anyway.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7f9f74005400)
> GET / HTTP/2
> Host: rea-again.local
> User-Agent: curl/7.64.1
> Accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
As soon as I restart this finishes out with…
< HTTP/2 502
< server: nginx/1.16.0
< date: Tue, 31 Mar 2020 17:32:51 GMT
< content-type: text/html
< content-length: 1108
< etag: "5e826270-454"
<
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Request Error</title>
<meta name="viewport" content="width=device-width, initial-scale = 1.0; maximum-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link href="//fonts.googleapis.com/css?family=Lato:400,700" rel="stylesheet" type="text/css">
<link href="/local-error-page-assets/errors.css" rel="stylesheet" type="text/css">
</head>
<body class="error">
<div class="layout">
<div class="layout__content">
<div class="kitchensink text-center">
<p class="error-code">502</p>
<h1>Request Error</h1>
<hr />
<p>The page you requested generated a server error and could not be processed.<br /><strong>If you continue to get this message after refreshing, try restarting the Local site.</strong></p>
<p>If the error persists, check the Local Router Logs in Local by going to<br />Help » Reveal Local Router's Logs.</p>
</div>
<img src="/local-error-page-assets/local-gray.svg" />
</div>
</div>
</body>
</html>
* Connection #0 to host rea-again.local left intact
* Closing connection 0
I am not really expecting anyone to resolve this for me, but I am wondering how to monitor the situation so that I might be able to determine what is going wrong. How can I debug this?
In the nginx router error.log I see things like this
2020/03/31 14:19:48 [error] 40128#0: *558 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: rea-again.local, request: "GET / HTTP/2.0", upstream: "http://127.0.0.1:10008/", host: "rea-again.local", referrer: "https://rea-again.local/asdfa"
2020/03/31 14:19:48 [error] 40128#0: *694 upstream prematurely closed connection while reading response header from upstream, client: ::1, server: rea-again.local, request: "GET /?cache-buster=1350 HTTP/1.1", upstream: "http://127.0.0.1:10008/?cache-buster=1350", host: "rea-again.local"
2020/03/31 14:19:48 [error] 40128#0: *692 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: rea-again.local, request: "HEAD /rea2015/schedule/ HTTP/1.1", upstream: "http://127.0.0.1:10008/rea2015/schedule/", host: "rea-again.local", referrer: "https://rea-again.local/rea2015"
2020/03/31 14:19:48 [error] 40128#0: *698 kevent() reported that connect() failed (61: Connection refused) while connecting to upstream, client: ::1, server: rea-again.local, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:10008/favicon.ico", host: "rea-again.local", referrer: "http://rea-again.local/?cache-buster=1350"
I have no idea if this is hinting at a problem.
Any guidance in how to debug Local problems would be welcome.
Thanks.