gearman gives me GEARMAN_COULD_NOT_CONNECT, it is definitely running

I had the same problem and recently solved them after a couple days of frustration (hard to troubleshoot since there are three processes to worry about :-)

It appears (at least in my case) that the PHP documentation for GearmanClient::addServer() and GearmanWorker::addServer() is incorrect. Specifically, the docs seem to imply that hostname and port number are optional and that it will use localhost and port 4730 as defaults if you do not specify them. This never works - it suddenly occurred to me today to try explicitly specifying them for both client and worker processes and everything started working.

Try specifying all values for hostnames and ports and see if this works for you.


In case if you have used something like this

$client->addServers('127.0.0.1', 4730);

or

$client->addServers();

use something like this

$client->addServers('127.0.0.1:4730');

PS - I have used localhost IP, this can be replaced with actual host IP.