WordPress WP-Cron cURL connection refused

Posted February 27, 2017 18.7k views
WordPressUbuntu 16.04

I created a droplet from the WordPress One Click install option, set everything up, and tried to schedule a post. The schedule failed and after some digging I found the error message

cURL error 7: Failed to connect to <domain>.com port 443: Connection refused

I SSH'ed into the droplet and tried cURL and wget but I get the same result. I have no idea what’s wrong or how to fix it. Can someone please point me in the right direction?

  • Do you have HTTPS over port 443 enabled? Or are you only accessing your domain through HTTP over port 80?
    Remember to unblock ports in firewall - not sure if the one-click sets up firewall rules automatically.

  • @hansen yes, I have https over port 443 enabled. I followed the tutorial to setup let’s encrypt. UFW is included in the one click and it’s enabled.

  • From SSH, can you run the full curl command, but add -vv ?
    curl -vv ......... i.e curl -vv
    It gives you the IP-address instead of domains in the error message, which is what we need. My guess is that [yourdomain].com is listed in /etc/hosts together with localhost or private ip 10.x.x.x

  • @hansen I ran the command you suggested

     curl -vv https://[mydomain].com
    * Rebuilt URL to: https://[mydomain].com/
    *   Trying [mydropletipv4]...
    * connect to [mydropletipv4] port 443 failed: Connection refused
    * Failed to connect to [mydomain].com port 443: Connection refused
    * Closing connection 0
    curl: (7) Failed to connect to [mydomain].com port 443: Connection refused

    On a whim, I added my domain to /etc/hosts with and the problem went away.

  • Great, it’s working. Not the solution I was looking for and not quite sure what the problem is.
    @jtittle do you know why it didn’t work before? I really don’t understand why it wouldn’t connect, when the domain translated to the public droplet IP.

  • Show 2 more comments

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer


Since you’re on Ubuntu, run:

ufw status

That’ll tell you whether or not ufw is enabled and if it is, which ports are open on the server. If it’s not enabled, then the issue would be that you either don’t have SSL enabled (for your domain), thus it’s not returning a successful return code, or something else is preventing the connection.

  • Here is the results:

    ufw status
    Status: active
    To                         Action      From
    --                         ------      ----
    22                         LIMIT       Anywhere
    443                        ALLOW       Anywhere
    80                         ALLOW       Anywhere
    22 (v6)                    LIMIT       Anywhere (v6)
    443 (v6)                   ALLOW       Anywhere (v6)
    80 (v6)                    ALLOW       Anywhere (v6)

    It looks like ufw is enabled and ports 80 and 443 allowing requests from anywhere.