Closed
Description
Description
wp-cron and "loopback requests" don't work when using this wordpress docker image.
docker-compose version: 3
wordpress image version: latest
(5.7.2 as of writing)
docker-compose file: See below. Courtesy of BradTraversy
Error Message
In Tools > Site Health
there are 2 errors:
The REST API encountered an error
The REST API request failed due to an error
Error: cURL error 7: Failed to connect to localhost port 8000: Connection refused (http_request_failed)
and also:
Your site could not complete a loopback request
The loopback request to your site failed, this means features relying on them are not currently working as expected.
Error: cURL error 7: Failed to connect to localhost port 8000: Connection refused (http_request_failed)
If you install the Plugin called WP Crontrol
you will also see this error in Tools > Cron Events
:
There was a problem spawning a call to the WP-Cron system on your site. This means WP-Cron events on your site may not work. The problem was:
cURL error 7: Failed to connect to localhost port 8000: Connection refused
Steps to Reproduce
mkdir wp-cron-test && cd wp-cron-test
- (Create the docker compose file below)
docker-compose up
- Go to localhost:8000 and complete the wordpress installation
- Go to
/wp-admin
- Go to
Tools > Site Health
and you should see the first two errors mentioned above - (optional) Install the plugin
WP Crontrol
- (optional) Go to
Tools > Cron Schedules
then click on thecron events
tab and you will see the errorThere was a problem spawning a call to the WP-Cron system on your site
- (optional) You can also click on any of the scheduled cron events and click
run now
and you will get anothercurl error 7
error
Docker Compose File:
version: '3'
services:
# Database
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
networks:
- wpsite
# phpmyadmin
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
restart: always
ports:
- '8080:80'
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: password
networks:
- wpsite
# Wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- '8000:80'
restart: always
volumes: ['./:/var/www/html']
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
networks:
- wpsite
networks:
wpsite:
volumes:
db_data: