wp-cli "Connection refused" error

Couldn't find anything about this with a few google searches so I decided to note it here. Weird problem: whenever I ran any wp-cli command, I'd get a list of 100+ lines of "Connection refused" before it actually did what I wanted.

I tried a few things to figure it out, including

  • Searching the site for malware pointing to a blocked URL (no)
  • Checking the firewall logs (nothing)
  • Checking the db config, running performance tools on it to see that it wasn't exceeding max connections. (no)
  • Running tcpdump to see where wp-cli was trying to connect to (it wasn't)
  • Updating all plugins, themes, (good to do anyway)
  • Checking db.php, which I found in wp-includes … which, hmmm, belongs to W3 Total Cache.

So on a hunch I tried

> wp-cli plugin deactivate w3-total-cache 
Connection refused
Connection refused

... plus 200 more lines 

Connection refused
Connection refused
Connection refused
Plugin 'w3-total-cache' deactivated.

… after which all wp-cli operations worked again.

After some further digging, I enabled w3 Total Cache again, and found that it was configured to use redis, which wasn't running on the server. So the connection attempts were failing to connect to that. Pretty easy to sort out after that …

Leave a Comment