XX-net/XX-Net · error

http create conn to %s:%d fail

Error message

http create conn to %s:%d fail

What it means

http_handler tried to establish a tunnel connection to the target host:port through proxy_session.create_conn, but create_conn returned a falsy conn_id, meaning the x-tunnel session could not allocate or register a new connection. The handler responds 'HTTP/1.1 500 Fail' and drops the request.

Source

Thrown at code/default/x_tunnel/local/proxy_handler.py:381

            for line in lines:
                key, _, value = line.partition(b":")
                headers[key] = value
                if key.lower() == b"host":
                    host, port = netloc_to_host_port(value)
            if host is None:
                xlog.warn("http proxy host can't parsed. %s %s", req_line, header_block)
                self.connection.send(b'HTTP/1.1 500 Fail\r\n\r\n')
                return

            if url.startswith(b"/openai/"):
                content_length = int(headers.get(b"Content-Length", 0))
                req_body = self.read_bytes(content_length)
                return openai_handler.handle_openai(method, url, headers, req_body, self.connection)

        sock = self.connection
        conn_id = proxy_session.create_conn(sock, host, port)
        if not conn_id:
            xlog.warn("http create conn to %s:%d fail", host, port)
            sock.send(b'HTTP/1.1 500 Fail\r\n\r\n')
            return

        xlog.info("http %r connect to %s:%d conn:%d", self.client_address, host, port, conn_id)

        new_req_line = b"%s %s %s" % (method, path, http_version)
        left_buf = new_req_line + self.read_buffer[(len(req_line) + 1):]
        g.session.conn_list[conn_id].transfer_received_data(left_buf)

        g.session.conn_list[conn_id].start(block=True)

View on GitHub (pinned to cfa5bc17b6)

Solutions

  1. Check that the x-tunnel session is actually running and logged in (see the 'login_session fail' warning) before routing traffic.
  2. Verify network connectivity to the x-tunnel front servers and check account status/quota.
  3. Retry the request after a short delay to cover transient session restarts or connection-table exhaustion.
  4. If persistent, raise concurrency/connection limits in g.config or inspect server-side logs for rejection reasons.
Defensive patterns

Strategy: retry

Validate before calling

if not proxy_session.running:
    ok = proxy_session.start()
    if not ok:
        abort('tunnel session not available')

Type guard

def tunnel_ready(session) -> bool:
    return bool(getattr(session, 'running', False)) and bool(session.conn_list is not None)

Prevention

When it happens

Trigger: Calling any proxied HTTP request when proxy_session is not running (login failed or session stopped), or when the session is at its connection limit / the server rejected the new conn during create_conn.

Common situations: X-tunnel account login failure or expired quota so the session never started; remote server unreachable; too many concurrent connections; race right after network change where the session is restarting.

Related errors


AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27). Data as JSON: /api/errors/a245c22392aa8727. Report an issue: GitHub.