Marcos Rezende
Marcos Rezende

Reputation: 41

Wordpress / Site Health / The REST API Error / Loopback Error

how are you? I am getting two errors when I use the native WordPress site health feature.

Your site could not complete a loopback request

Loopback requests are used to run scheduled events, and are also used by the built-in editors for themes and plugins to verify code stability.

The loopback request to your site failed, this means features relying on them are not currently working as expected.

Error: cURL error 35: OpenSSL SSL_connect: Connection reset by peer in connection to mydomain.com:443 (http_request_failed)

and

The REST API encountered an error

The REST API is one way WordPress, and other applications, communicate with the server. One example is the block editor screen, which relies on this to display, and save, your posts and pages.

The REST API request failed due to an error.
Error: cURL error 35: OpenSSL SSL_connect: Connection reset by peer in connection to mydomain.com:443 (http_request_failed)

Already did:

but without success. How can I resolve this?

Upvotes: 4

Views: 3905

Answers (5)

Ahmed
Ahmed

Reputation: 11

the following fixed it, same as in @derek.z, however just add to your docker-compose.yml file or Portainer stack the domain "yourdomain.com" instead of "localhost":

extra_hosts:
   - "yourdomain.com:172.XX.0.1"
 

make sure to use the exact domain name and exact docker network gateway ex. 172.18.0.1, recheck after deployment, sometimes the network gets new IP (gateway).

Upvotes: 1

scavenger
scavenger

Reputation: 408

I tried the solution from @derek.z without success. Commenting those lines in .htaccess fixed those 2 errors:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Those 3 lines are a rule for permalinks (when using /%postname%/). Commenting them will indeed break your site as no page can display anymore. But it solves the 2 errors below 100%:

  • Your site could not complete a loopback request
  • Unable to detect the presence of page cache

This is by no means a valid solution but another brick to build one.

Upvotes: 0

Werner Garcia
Werner Garcia

Reputation: 1

In my case, I was running Wordpress on Windows, with nginx and php-cgi.exe as a service. After doing some debugging I realized the php-cgi service only accepts one connection at a time. I had to set the following environment variables so the php-cgi service can handle more requests:

PHP_FCGI_MAX_REQUESTS=0
PHP_FCGI_CHILDREN=10

And That solved the loopback errors in the health-check page.

Upvotes: 0

The009
The009

Reputation: 3

I got this problem myself when hosting WordPress myself.

It was caused by my network setup. If you are using NAT or your own DNS you will need to do either NAT Reflection or Split DNS.

Your best bet is Split DNS. ( You can look up how to do this depending on your own network server. )

You can find more information from NetGate If use PFSense This will solve your issue. Or hopefully point you in the proper direction.

https://docs.netgate.com/pfsense/en/latest/nat/reflection.html

Upvotes: 0

derek.z
derek.z

Reputation: 967

I encountered the same two critical issues exactly, in my local development environment.

My WordPress site with the default address 'http://localhost:8000' is running in local docker containers, after adding the extra_hosts part to the docker-compose.yml, the problem resolved.

Here is the working docker-compose.yml

version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress
   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
       WORDPRESS_DB_NAME: wordpress
     extra_hosts:
       - "localhost:172.18.0.1"
volumes:
    db_data: {}

Note that 172.18.0.1 is the default docker gateway.

Upvotes: 6

Related Questions