import socket


def get_random_unopen_port(local_addr: str) -> int:
    """

    :param local_addr: ip to bind, 127.0.0.1
    :return: unopen port
    """
    with socket.socket() as sock:
        sock.bind((local_addr, 0))
        ip, port = sock.getsockname()
        return port