wordpressdockerkitematic

HTTP Loopback Connections are not enabled on this server - wordpress on docker


I have a wordpress official container with a dock port 80 mapped to 32795 external... when I go to administration area of wordpress I get this error:

Important: HTTP Loopback Connections are not enabled on this server. If you need to contact your web host, tell them that when PHP tries to connect back to the site at the URL http://localhost:32795/wp-admin/admin-ajax.php and it gets the error cURL error 7: Failed to connect to localhost port 32795: Connection refused. There may be a problem with the server configuration (eg local DNS problems, mod_security, etc) preventing connections from working properly.

I think the problem is that the site inside the container tries to communicate with the 32795 port instead of 80, but it can not because this door is only seen from the outside of the container...

I created a script inside the site with phpinfo, and I checked the loopback connections are on...

There is a solution for this? I have docker un windows with kitematic

thanks


Solution

  • I had a similar problem running WordPress with Nginx on Docker Desktop for Windows. I needed to add an entry to the container's hosts file that directed my local.example.com domain to hit my ingress-nginx controller so that WordPress' loopback requests would work. Although my setup might be slightly different this might help you.

    Open /Windows/System32/drivers/etc/hosts and copy the IP address that's next to host.docker.internal. Add an entry to the container's hosts file on startup that ties the domain to the hosts IP by doing one of the following. IP is what you copied from your machine's hosts file by host.docker.internal

    Docker argument:

    --add-host="local.example.com:IP"
    

    Docker compose:

    extra_hosts:
      - "local.example.com:IP"
    

    Kubernetes:

    hostAliases:
    - ip: "IP"
      hostnames:
      - "local.example.com"