{"record":{"id":"12e1ec1795c83fb4","repo":"oraios/serena","slug":"failed-to-connect-to-serena-service-at-url-e","errorCode":null,"errorMessage":"Failed to connect to Serena service at {url}: {e}","messagePattern":"Failed to connect to Serena service at (.+?): (.+?)","errorType":"exception","errorClass":"ConnectionError","httpStatus":null,"severity":"error","filePath":"src/serena/jetbrains/jetbrains_plugin_client.py","lineNumber":341,"sourceCode":"                response = self._session.post(url, data=json.dumps(data_dict), timeout=self._timeout)\n            else:\n                raise ValueError(f\"Unsupported HTTP method: {method}\")\n\n            response.raise_for_status()\n\n            # Try to parse JSON response\n            try:\n                response_json = response.json()\n                if pythonify:\n                    return self._pythonify_response(response_json)\n                else:\n                    return response_json\n            except json.JSONDecodeError:\n                # If response is not JSON, return raw text\n                return {\"response\": response.text}\n\n        except requests.exceptions.ConnectionError as e:\n            raise ConnectionError(f\"Failed to connect to Serena service at {url}: {e}\")\n        except requests.exceptions.Timeout as e:\n            raise ConnectionError(f\"Request to {url} timed out: {e}\")\n        except requests.exceptions.HTTPError as e:\n            if response is not None:\n                # check for recoverable error (i.e. errors where the problem can be resolved by the caller or\n                # other errors where the error text shall simply be passed on to the LLM).\n                # The plugin returns 400 for such errors (typically illegal arguments, e.g. non-unique name path)\n                # but only since version 2023.2.6\n                if self.is_version_at_least(2023, 2, 6):\n                    is_recoverable_error = response.status_code == 400\n                else:\n                    is_recoverable_error = True  # assume recoverable for older versions (mix of errors)\n                if is_recoverable_error:\n                    raise APIError(response)\n                raise PluginServerError(f\"API request failed with status {response.status_code}: {response.text}\")\n            raise PluginServerError(f\"API request failed with HTTP error: {e}\")\n        except requests.exceptions.RequestException as e:\n            raise SerenaClientError(f\"Request failed: {e}\")","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/jetbrains/jetbrains_plugin_client.py#L323-L359","documentation":"_make_request wraps requests.exceptions.ConnectionError and re-raises it as a Python ConnectionError with the target URL. This means the Serena service HTTP endpoint inside the JetBrains IDE could not be reached at all (nothing listening, wrong port, IDE busy/blocked).","triggerScenarios":"Any plugin HTTP call (client init, find_symbol, move, find_references, get_symbols_overview, get_supertypes) when the plugin's local server is down, the discovered port is stale, or the IDE is frozen/starting up.","commonSituations":"IDE crashed or was closed mid-session; cached service URL points to a dead port; firewall/proxy intercepting localhost requests; IDE still initializing after project open.","solutions":["Verify the JetBrains IDE with the Serena plugin is running and responsive","Re-run project discovery (JetBrainsPluginClient.from_project) to refresh the service URL/port","Restart the IDE if the plugin service appears hung","Check proxy env vars (http_proxy/HTTPS_PROXY) aren't routing localhost requests away"],"exampleFix":"// before\nNO_PROXY unset; requests routed via corporate proxy\n// after\nexport NO_PROXY=localhost,127.0.0.1","handlingStrategy":"retry","validationCode":"import requests\ndef service_reachable(url: str) -> bool:\n    try:\n        return requests.get(url, timeout=2, proxies={\"http\": None, \"https\": None}).ok\n    except requests.exceptions.ConnectionError:\n        return False","typeGuard":null,"tryCatchPattern":"import time\nfor attempt in range(3):\n    try:\n        result = client.find_symbol(name_path=\"foo\")\n        break\n    except ConnectionError as e:\n        if \"Failed to connect\" in str(e) and attempt == 2:\n            raise\n        time.sleep(1)","preventionTips":["Set NO_PROXY=localhost,127.0.0.1 so requests don't go through a proxy","Confirm the IDE is running and the plugin service is up before heavy calls","Refresh the client (from_project) after IDE restarts to get a fresh port","Add short retries with backoff for startup races"],"tags":["network","jetbrains","connection","http"],"backgroundTag":"connection-refused","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}