[zeromq-dev] Newbie Question: php-zmq and the "Divide and Conquer" Example - "Failed to bind the ZMQ: Address already in use"

Martin Sustrik sustrik at 250bpm.com
Tue Jan 4 18:26:17 CET 2011


Hi,

> When porting the code directly, the Worker is to
> bind('tcp://localhost:5557'). However, this fails on my system with the
> message:
> ZMQSocketException: Failed to bind the ZMQ: No such device
>
> I'm going to guess that this is a problem with my local system, but when
> I ping localhost, or use ftp/ssh/etc., it resolves to 127.0.0.1 as it
> should and I hit my local box without an issue. I'm perplexed here.

When you are binding, you are binding to local network interface rather 
than to a host name. Say on Linux the loopback interface is called 'lo'. 
The hostname of the local machine is 'localhost'.

You can also use '*' to bind to all network interfaces.

> So, I decided to try to use 127.0.0.1 directly instead of localhost.
> When I do this, I receive the following error message:
> ZMQSocketException: Failed to bind the ZMQ: Address already in use in
> /home/kermode/zmq/example/worker.php on line 4

That looks like the port specified is already being used by another 
application.

Martin



More information about the zeromq-dev mailing list