Skip to content

BUG: socket.bind('tcp://127.0.0.1:...') fails with ZMQError: Invalid argument on macOS ARM with pyzmq 26.4.0 #2093

Open
@itsmevictor

Description

@itsmevictor

This is a pyzmq bug

  • This is a pyzmq-specific bug, not an issue of zmq socket behavior. Don't worry if you're not sure! We'll figure it out together.

What pyzmq version?

26.4.0

What libzmq version?

4.3.5_1 (Installed separately via Homebrew)

Python version (and how it was installed)

Python 3.11.12 (Installed via Homebrew)

OS

macOS Sequoia

What happened?

Summary:

When using pyzmq version 26.4.0 on macOS ARM with Python 3.11 (installed via Homebrew) and libzmq 4.3.5_1 (also installed via Homebrew), attempting to bind a socket to a localhost TCP address fails with zmq.error.ZMQError: Invalid argument.

Expected behavior:
The socket.bind('tcp://127.0.0.1:<port>') call should succeed without raising an exception.

Actual behavior:
The call raises the following exception: zmq.error.ZMQError: Invalid argument (addr='tcp://127.0.0.1:<port>')

Code to reproduce bug

import zmq
import platform

print(f"pyzmq version: {zmq.pyzmq_version()}")
print(f"libzmq version: {zmq.zmq_version()}")
print(f"Python version: {platform.python_version()}")
print(f"OS: {platform.system()} {platform.release()} ({platform.machine()})")

ctx = zmq.Context()
sock = ctx.socket(zmq.REP)
address = 'tcp://127.0.0.1:9027' # Example port

try:
    print(f"Attempting to bind to {address}...")
    sock.bind(address) 
    print("Bind successful!")
    sock.close()
except zmq.error.ZMQError as e:
    print(f"Bind failed: {e}") # This is where the error occurs
except Exception as e:
    print(f"An unexpected error occurred: {e}")
finally:
    if not sock.closed:
        sock.close()
    ctx.term()

Finally, reverting to 25.1.2 solved the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions