Java / Spring Boot Debug Restart fails on first attempt in Cursor (works in VS Code)

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Restarting a Java Spring Boot debug session in Cursor often fails on the first attempt. The old JVM is not fully torn down before the new launch starts. The same project, same launch.json, and the same Java extensions work correctly in VS Code: one Restart cleanly stops the old process and starts a new one.

After a failed Cursor restart, the previous process on the app port is gone or half-dead, and the new process does not come up. A frontend proxy then sees ECONNRESET / ECONNREFUSED against the backend port.

This looks like a Cursor debug-host timing issue (stop + start), not a Maven or project configuration problem. Both IDEs share the same ~/.m2/repository and the same launch config.

Related existing report: Spring Boot process not terminating after stopping debug in Cursor IDE

Steps to Reproduce

Open a Spring Boot Maven project in Cursor.
Start Debug with a Java launch config, for example:

{
“type”: “java”,
“name”: “NgsApplication”,
“request”: “launch”,
“mainClass”: “cn.biosan.ngs.NgsApplication”,
“projectName”: “biosan-ngs”
}
Wait until the app is listening on its configured port.
Click the built-in Restart button, or press Shift+Cmd+F5.
Repeat the same steps in VS Code with the same repo and extensions.

Expected Behavior

Restart should stop the current debuggee, wait until the process and debug adapter are gone, then start a new session. The app should listen on the same port again after one Restart, same as VS Code.

Operating System

MacOS

Version Information

Operating System
macOS 15.8.1 (Build 24H32), Apple Silicon

Current Cursor Version
Version: 3.24.9
VSCode Version: 1.128.0
Commit: cd6d2a1f2e56e9841f0ed9c7c24542087b4e69b0

Java extensions

Debugger for Java (vscjava.vscode-java-debug) 0.59.0
Language Support for Java by Red Hat (redhat.java) 1.56.0
JDK used to run the app: OpenJDK 17 (/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home)

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey @shihao_zhao, thanks for the detailed report and for comparing it side by side with VS Code. That helps a lot.

To understand exactly what’s happening during the failing restart, could you please try this:

  1. Start the NgsApplication debug config and wait until the app begins listening on its port.
  2. Press Restart once with Shift+Cmd+F5.
  3. As soon as the restart fails, open the terminal tab with your config name, or the Debug Console, and copy the last ~30 lines, especially any messages like Port ... was already in use or Address already in use.
  4. In a separate macOS Terminal, run lsof -nP -iTCP:<your port> -sTCP:LISTEN and copy the output. This will show whether the old JVM is still holding the port.
  5. Add "console": "internalConsole" to the same launch config and repeat steps 1 and 2. Does the first restart work now?

Also, could you let us know:

  • what console is currently set to in your launch config. If it’s not set, the default is the integrated terminal
  • whether the Debugger for Java and Language Support for Java versions match in both editors, in the Extensions tab in each one

As a workaround for now, press Stop with Shift+F5, wait a couple of seconds until the terminal returns to the prompt, then press F5. That should start the app cleanly.

Let us know what steps 3 to 5 show, and we’ll go from there.

@deanrie Hi @deanrie — thanks for the follow-up. Here are the answers I can give right now.

**Request ID:** `c8434d67-edf5-45a7-bc63-0b0f5800a193`

**Current `console` setting**
`console` is not set in `launch.json`, so Cursor uses the default integrated terminal.

```json
{
“type”: “java”,
“name”: “test”,
“request”: “launch”,
“mainClass”: “cn.test.Application”,
“projectName”: “test”,
“javaExec”: “/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home/bin/java”
}

Extension versions (matched in both editors when I reproduced this)

  • Debugger for Java (vscjava.vscode-java-debug): 0.59.0 in Cursor and VS Code
  • Language Support for Java (redhat.java): 1.56.0 in Cursor and VS Code

Same project, same launch.json, same ~/.m2/repository. Only the IDE host differs. Restart works on the first try in VS Code; first Restart often fails in Cursor.

Steps 3–4 (from previous failed Restart repros) After the first failed Restart in Cursor:

  • I usually do not see Port ... was already in use / Address already in use
  • lsof -nP -iTCP:<port> -sTCP:LISTEN is often empty — the old JVM is already gone (or half-dead), but the new debug session does not come back up
  • Frontend then hits ECONNRESET during teardown, then ECONNREFUSED because nothing is listening again

So this looks less like a stuck port holder, and more like Cursor’s Restart path tearing down the session without completing the follow-up start (debug-host / debug-adapter timing).

Step 5 ("console": "internalConsole") I have not finished retesting with "console": "internalConsole" yet. I will try that next and paste the terminal / Debug Console last ~30 lines plus a fresh lsof dump right after a failing Restart.

Workaround Agreed — Shift+F5 → wait for the terminal prompt → F5 starts cleanly. I also use a small local helper that does stopDebugging → wait for session end → startDebugging, because Cursor’s built-in Restart is unreliable for this Java / Spring Boot case.

Happy to collect any other logs you need (Debug Console, Developer Tools, etc.).

Thanks for the detailed replies. The port is free after the failed Restart, and there’s no Address already in use error, so the old JVM is not holding the port. We can rule out that hypothesis.

We found an issue with restarted debug sessions that looks similar to your case. If the app stops on a breakpoint during startup after Restart, Cursor may not show the paused state. The app is actually paused and never gets to the point where it opens the port, so it looks like it just failed to start. A fresh session with Stop and then F5 is not affected, which is why your workaround helps. Here’s a similar case, but for Python: Debugging python via remote client connection sometimes hangs permanently after hitting a breakpoint

Could you please check two things the next time Restart fails:

  1. Do you have any breakpoints enabled when you press Restart? Also check the Caught Exceptions and Uncaught Exceptions boxes in the Breakpoints section of the Run and Debug tab.
  2. Does the Spring Boot startup log in the debug terminal stop somewhere in the middle, without a final Started ... in N seconds line?

And one quick test:

  1. Start the debug config and wait until the app begins listening on the port.
  2. In Run and Debug, in the Breakpoints section, click Toggle Activate Breakpoints, the crossed-out circle, to disable all breakpoints.
  3. Press Shift+Cmd+F5 once.
  4. Does the app come up on the port this time?

If yes, that confirms the hypothesis. For now, the most reliable workaround is to do Stop with Shift+F5 and then F5, like you’ve been doing, or disable breakpoints before Restart. If you get a chance to retest with "console": "internalConsole", that result would also help.

Let us know what the test shows.