{"record":{"id":"a245c22392aa8727","repo":"XX-net/XX-Net","slug":"http-create-conn-to-s-d-fail","errorCode":null,"errorMessage":"http create conn to %s:%d fail","messagePattern":"http create conn to (.+?):(.+?) fail","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"code/default/x_tunnel/local/proxy_handler.py","lineNumber":381,"sourceCode":"            for line in lines:\n                key, _, value = line.partition(b\":\")\n                headers[key] = value\n                if key.lower() == b\"host\":\n                    host, port = netloc_to_host_port(value)\n            if host is None:\n                xlog.warn(\"http proxy host can't parsed. %s %s\", req_line, header_block)\n                self.connection.send(b'HTTP/1.1 500 Fail\\r\\n\\r\\n')\n                return\n\n            if url.startswith(b\"/openai/\"):\n                content_length = int(headers.get(b\"Content-Length\", 0))\n                req_body = self.read_bytes(content_length)\n                return openai_handler.handle_openai(method, url, headers, req_body, self.connection)\n\n        sock = self.connection\n        conn_id = proxy_session.create_conn(sock, host, port)\n        if not conn_id:\n            xlog.warn(\"http create conn to %s:%d fail\", host, port)\n            sock.send(b'HTTP/1.1 500 Fail\\r\\n\\r\\n')\n            return\n\n        xlog.info(\"http %r connect to %s:%d conn:%d\", self.client_address, host, port, conn_id)\n\n        new_req_line = b\"%s %s %s\" % (method, path, http_version)\n        left_buf = new_req_line + self.read_buffer[(len(req_line) + 1):]\n        g.session.conn_list[conn_id].transfer_received_data(left_buf)\n\n        g.session.conn_list[conn_id].start(block=True)\n\n","sourceCodeStart":363,"sourceCodeEnd":393,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/x_tunnel/local/proxy_handler.py#L363-L393","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check that the x-tunnel session is actually running and logged in (see the 'login_session fail' warning) before routing traffic.","Verify network connectivity to the x-tunnel front servers and check account status/quota.","Retry the request after a short delay to cover transient session restarts or connection-table exhaustion.","If persistent, raise concurrency/connection limits in g.config or inspect server-side logs for rejection reasons."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if not proxy_session.running:\n    ok = proxy_session.start()\n    if not ok:\n        abort('tunnel session not available')","typeGuard":"def tunnel_ready(session) -> bool:\n    return bool(getattr(session, 'running', False)) and bool(session.conn_list is not None)","tryCatchPattern":null,"preventionTips":["Gate proxy traffic on session.running before issuing requests.","Implement client-side retry with backoff for 500 responses from the local proxy.","Monitor login/session warnings to catch a dead session early."],"tags":["network","proxy","tunnel","connection-establishment"],"backgroundTag":"connection-establishment-failed","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}