Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
Sometimes when I’m debugging my Python apps in Cursor, the debugger behaves as if it hit a breakpoint, but doesn’t make any of the UI changes that allow me to control the program flow. This leaves my app in a permanently hung state until I stop the debug server in Cursor.
Steps to Reproduce
I debug my python WSGI apps via a middleware I wrote which connects to the debugpy server running in my Cursor app when a request starts, and disconnects after the request ends. The WSGI app is running in gunicorn inside a Docker container running on my Mac, and it connects to the debug server in Cursor via host.docker.internal:6765.
To reproduce the bug:
- Place a breakpoint in one of my views and visit that view’s URL via my browser.
- The breakpoint is hit as normal, and I can debug the code.
- Press Continue, allowing the request to complete.
- Refresh the page in my browser.
- The gunicorn worker hangs right when the breakpoint should have been hit. Print statements before the breakpoint get printed to my docker logs, but nothing after.
Expected Behavior
I expect the debugger hitting a breakpoint to consistently give me control of the debugging process, rather than hanging.
Operating System
MacOS
Version Information
Version: 3.23.12 (Universal)
VS Code Extension API: 1.128.0
Commit: 2d29876d567da1607532b23bbf2cd5ddbca496f0
Date: 2026-10-01T04:41:16.627Z
Layout: IDE
Build Type: Stable
Release Track: Default
Electron: 42.10.0
Chromium: 148.0.7778.280
Node.js: 24.18.1
V8: 14.8.178.38-electron.0
xterm.js: 6.1.0-beta.291
OS: Darwin arm64 25.6.0
Additional Information
If I perform Steps 1-3, then remove the breakpoint, and then do Step 4, the refresh works fine and the request completes as normal.
If I do Steps 1-3, then restart the debug server in Cursor, then do Step 4, the breakpoint gets hit as normal.
If I trigger Step 5, then, while gunicorn is hung, I click Disconnect in Cursor to stop the debug server, gunicorn un-hangs and the request completes as normal. If I then turn the debug server back on and refresh the page again, I get a normal breakpoint hit, with control of the debug process.
So the problem is related to hitting a breakpoint, and then hitting another breakpoint after the debug client has disconnected and reconnected, but without stopping and restarting the debug server.
I can get the same behavior if I instead configure my gunicorn server to connect to the debug server at boot time, staying connected across all requests. If I hit a breakpoint, then change my code such that gunicorn restarts itself to reload the new code, a subsequent request for a breakpointed view will trigger the hang.
Here’s my debugging middleware:
class DebugpyClientWSGIMiddleware:"""Enables client-style debugging, connecting to a remote debug server runninginside VS Code (usually). Only activates if REMOTE_DEBUG_ENABLED=True."""
def __init__(self, app):
self.app = app
self.enabled = env.bool("REMOTE_DEBUG_ENABLED", default=False)
self.host: str = env("REMOTE_DEBUG_HOST", default="host.docker.internal")
self.port: int = env.int("REMOTE_DEBUG_PORT", default=6765)
if self.enabled:
print("REQUEST DEBUGGING IS ENABLED.", flush=True)
print(f"Ensure a python debug server is running at {self.host}:{self.port}.", flush=True)
def __call__(self, wsgi_environ, start_response):
"""
Connect to the debug server at the start of every request.
"""
connected = False
if self.enabled:
try:
debugpy.connect((self.host, self.port))
except ConnectionRefusedError:
print(f"No debug server is running at {self.host}:{self.port}.", flush=True)
else:
connected = True
print(f"Connected to debug server at {self.host}:{self.port}.", flush=True)
response = self.app(wsgi_environ, start_response)
if connected:
# We can ignore this "invalid import" warning from BasedPyright. It just doesn't
# know about the vendored pydevd that debugpy installs. Though it only _does_
# that after you've called at least one debugpy API, which is why we do the
# import here.
import pydevd
# Disconnect from the debug server after the request is over.
pydevd.stoptrace()
return response
Note that commenting out the if connected: block has no effect on the hang.
I wasn’t experiencing this hanging behavior before yesterday, Oct 1st, 2026.
Does this stop you from using Cursor
No - Cursor works, but with this issue



