Skip to content

wp-cron / loopback requests don't work (Curl error 7) #611

Closed
@MinKaizen

Description

@MinKaizen

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

  1. mkdir wp-cron-test && cd wp-cron-test
  2. (Create the docker compose file below)
  3. docker-compose up
  4. Go to localhost:8000 and complete the wordpress installation
  5. Go to /wp-admin
  6. Go to Tools > Site Health and you should see the first two errors mentioned above
  7. (optional) Install the plugin WP Crontrol
  8. (optional) Go to Tools > Cron Schedules then click on the cron events tab and you will see the error There was a problem spawning a call to the WP-Cron system on your site
  9. (optional) You can also click on any of the scheduled cron events and click run now and you will get another curl 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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionUsability question, not directly related to an error with the image

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions