Unable to launch debugger with Godot 4 (workaround included)
Godot version
4.0 alpha 10
VS Code version
1.68.1
Godot Tools VS Code extension version
1.3.1
System information
Windows 11
Issue description
Unable to launch a debugger with Godot 4, connection with GDScript language server works fine. Godot instance was already running.
My analysis says that an "&" is missing from suffix of exe

Steps to reproduce
Try opening debug session with default generated launch.json from VS code
I don't think they added Godot 4 support for this addon yet and a lot of things has changed between 3 and 4. Your best bet might be to wait for 4.0 to be released.
I don't think they added Godot 4 support for this addon yet and a lot of things has changed between 3 and 4. Your best bet might be to wait for 4.0 to be released.
Just to make sure I'm not doing something wrong, after all the setup, I also get Failed to launch Godot instance: Error: Command failed with Godot 4-beta1 (non-Mono) + VS Code,
So Godot 4.0 is still not support right?
In Godot 4.0 beta1, default LSP port is
6005, not6008(like 3.x).
LSP is for autocompletions, not debugging.
The input flags has changed and now requires a port to launch with remote debugging.
By trying to launch it form a terminal you get this error:
PS> Godot_v4.0-beta2_win64.exe --path "....\Godot\PROJECT" --remote-debug 127.0.0.1:6008
Invalid debug host address, it should be of the form <protocol>://<host/IP>:<port>.
I tested a none real protocole and it seems launches
PS> Godot_v4.0-beta2_win64.exe --path "....\Godot\PROJECT" --remote-debug any://127.0.0.1:6008
Godot Engine v4.0.beta2.official.f8745f2f7 - https://godotengine.org
Vulkan API 1.2.0 - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce GTX 970
--------------------------------
...
Adding the same fake protocole to the address field in launch.json launches a debug window but workout working breakpoints.

Edit:
Chaning the protocol to tcp and prot to 6006 breakpoints stops the runtime but gives not feedback in vscode.

looks like 6006 is the defualt debug adapter port not ~~6008~~

I was able to adjust the launch.json and use the tcp port like you mentioned, and get the editor to launch, but I get some strange errors, and the debugger doesn't work still.
I don't expect things to work prior to Godot 4 launch, just interesting and thought I'd share the error.
Failed to launch Godot instance: Error: Command failed: "D:\Game Dev\Godot\Godot 4\Godot_v4.0-beta2_win64.exe" --path "D:\Game Dev\Games\Constellation-Cadence" --remote-debug tcp://127.0.0.1:6007 --breakpoints res://Levels/Conductor.gd:30,res://Levels/level.gd:27,res://Levels/level.gd:30,res://Levels/level.gd:33,res://Levels/level.gd:36,res://Levels/level.gd:37
ERROR: Remote Debugger: Unable to connect. Status: 1.
at: connect_to_host (core/debugger/remote_debugger_peer.cpp:182)
SCRIPT ERROR: Parse Error: Expected ":" after function declaration.
at: GDScript::reload (res://Preload/Transitions/sceneTransition.gd:8)
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
at: cleanup (core/object/object.cpp:1956)
ERROR: Resources still in use at exit (run with --verbose for details).
at: clear (core/io/resource.cpp:473)
@Zyjinn
failed: "D:\Game Dev\Godot\Godot 4\Godot_v4.0-beta2_win64.exe" --path "D:\Game Dev\Games\Constellation-Cadence" --remote-debug tcp://127.0.0.1:6007 --breakpoints
Check your remot debugging port really is 6007
Project -> Network -> Debug Adapter
I have not gotten brakeponts working ether but I got it to lunch.
@yoieh Oh, yeah I got the software to launch, just no breakpoints, which is hard to sell because if I'm going to use it as a primary editor, and I can't debug, that's a pretty big issue for me personally.
If you change the external editor, I don't think there's even a way to set breakpoints in the godot editor either, so you can't even use VSC for coding and godot for debugging super well, other than by kinda like, using VSC most times, and then just using Godot when you want to debug and not setting the external editor.
I'll play around with it, but mostly going to wait for debugging to come back for now, but thanks for the notice!
Hey guys!
I was able to get breakpoints working with this launch.json
First of all, obviously godot_tools.editor_path is set in settings.json
I'm not using tcp as advised above, but have added "debugServer": 6006 to the default config
{
"version": "0.2.0",
"configurations": [
{
"name": "Godot",
"type": "godot",
"request": "launch",
"project": "${workspaceFolder}",
"port": 6006,
"debugServer": 6006,
"address": "127.0.0.1",
"launch_game_instance": true,
"launch_scene": false
}
]
}
As for Godot options:
-- Debug Adapter - Sync Breakpoints is True
-- Debug - Remote Port is 6006
-- Deploy with Remote Debug is True as shown below

You might have to launch your game in Godot Editor once (with at least one breakpoint set from VSCode) and then breakpoints should work in VSCode as well. Also, note that as of Beta 3, breakpoints set in VSCode can be disabled only from Godot Editor
Running on Godot 4 Beta 3 and Godot Tools 1.3.1
Thanks @Winprox , I can confirm that in Godot 4.0 Beta 4 I had to follow most one of your instructions before debugging GDScript worked -- except for setting Debug - Remote Port away from its default of 6007. I did have to launch the game in Godot Editor with breakpoints set in VSCode.
And I think you meant launch.json not config.json, and I think the only change you made was to add the debugServer entry.
So to summarize,
To get VSCode GDScript debugging working in Godot 4.0 Beta 4:
In VSCode
- In
Settings, search forgodotand setGodot_tools: Editor_pathto the Godot executable - If your workspace has no
.vscode/launch.jsonfile,- Open the Run and Debug sidebar, click
create a launch.json file - Choose
GDScript Godot Debugto create the file
- Open the Run and Debug sidebar, click
- In
launch.json:- Change
"port"to6006 - Add on the next line:
"debugServer": 6006
- Change
In Godot Editor
- Enable the
Debugmenu'sDeploy with Remote Debugentry - In
Editor Settings, setNetwork/Debug Adapter/Remote Portto6006 - In
Editor Settings, setNetwork/Debug Adapter/Sync BreakpointstoOn
Finally
- Add a breakpoint in VSCode.
- Run your project in Godot Editor, then stop it.
Now from VSCode you can Start Debugging, and it should run your code, and trip your breakpoint. Happy debugging!
PS: See next comment if you're using C# -- I don't know how to get that working :/
@michaelgundlach I've followed these instructions and @Winprox's multiple times to the letter but debugging from VSCode 1.73.0 still doesn't work on Godot v4.0.beta4.mono.official [e6751549c] with Godot Tools 1.3.1. Start Debugging results in Godot reporting [DAP] Connection Taken and if repeated will eventually result in Max client limits reached, but the program never starts. If Start Debugging is used while the program is running it shuts down and no debugging occurs. This is occurring in a project with mixed GDscript and C#.
On further inspection this error occurs on Start Debugging:
[error] The editor and client are working on different paths; the client is on
"d:\gameDev\gd4proj\builder\pawn.cs", but the editor is on "D:/gameDev/gd4proj/builder": CodeExpectedError:
The editor and client are working on different paths;
the client is on "d:\gameDev\gd4proj\builder\pawn.cs", but the editor is on "D:/gameDev/gd4proj/builder"
This definitely seems related to C#.
Sorry @glimpsebeyond, I'm just using GDScript. I updated my comment to not disappoint C# users. If you figure it out ping me again and I'll update the comment again.
@michaelgundlach I tried it using the godot build without C# and a new gdscript only project and the behavior is mostly unchanged, though it did resolve that error I posted the program does not open.
@glimpsebeyond @michaelgundlach
Same for me - it resolves errors in vscode, but the debugger immediately quits.
Might be an issue with the Godot editor, or something needs to be changed in the editor settings.

Edit: No idea how I caused the "Max client limits reached" errors. The vscode debugger either starts and stops or kills it if already started from the Godot editor.
Edit: "Max client limits reached" errors seem to occur when changing launch.json while the Godot editor is connected.
@michaelgundlach I was also seeing the [DAP] Connection Taken error, although unlike the above users, I only see the error once, and get nothing from the debugger.
I even tried going into the scripts menu and closing any open scripts, and even going into the "scripts" menu under "debug" and selecting "debug with external editor" and it still shows the error [DAP} Connection Taken
I also tried messing around with the ports as well, trying different ones, as well as making sure the debugServer and port properties were not the same, and no luck.
Not sure what is still taking that port? I tried running a netstat, and only saw the listening ports from Godot looking at the ports specified for the debug server.
Let me know if anyone finds anything else regarding this, I would of course like to use Vscode whenever possible for debugging, but for now, it's understandable as it's beta afterall
I'm having a similar issue with respect to C# debugging. Looking in my VSCode terminal tab where the GodotTools is launching Godot's debug mode:
Running: /opt/Godot/Godot_v4.0-beta13_mono_linux_x86_64/Godot_v4.0-beta13_mono_linux.x86_64 --path /home/thoraxe/Documents/spacetrader/spacetrader-godot --remote-debug tcp://127.0.0.1:6007 --editor-pid 1313396 --position 960,572 res://Scenes/Main.tscn
ERROR: Couldn't find the given section "res://Scenes/CameraController.cs" and key "state", and no default was given.
at: get_value (core/io/config_file.cpp:86)
ERROR: Condition "!breakpoint_list.find(breakpoint)" is true. Returning: Array()
at: update_breakpoints (editor/debugger/debug_adapter/debug_adapter_protocol.cpp:799)
The file CameraController.cs is definitely in the stated place:
find | grep \.cs | grep Scenes
./Scenes/Main.cs
./Scenes/Camera3D.cs
./Scenes/CameraController.cs
Not sure if this warrants a separate issue.
Here's my launch config:
{
"name": "Launch",
"type": "godot-mono",
"request": "launch",
"mode": "executable",
"preLaunchTask": "build",
"debugServer": 6006,
"executable": "/opt/Godot/Godot_v4.0-beta13_mono_linux_x86_64/Godot_v4.0-beta13_mono_linux.x86_64",
"executableArguments": [
"--path",
"${workspaceRoot}"
]
},
Using the config specified in https://github.com/godotengine/godot-vscode-plugin/issues/389#issuecomment-1296351171 does not make breakpoints work, but it doesn't produce the odd errors.
I am setting a breakpoint, launching the editor from vscode, running the project in the editor after launching the editor from vscode, stopping the project, and then running the project again from VSCode.
I'm on 4 Beta13.
same issue with GDScript @thoraxe
i followed the instruction that @michaelgundlach give earlier, works on Linux Mint, and have same error with @kkhhaann on WIndows 11
The "Max clients limit reached" error seems to happen after opening and closing the debug session 8 times. I assume the DAP server can only take 8 connections before it maxes out, and for some reason each time you try to debug from vscode it eats a new client. (I am using GDscript, so it doesn't seem to be exclusively C#)
Also this can even happen with the language server if you open and close vscode 8 times. It maxes out the connections. Though this is not really a problem anyone is likely to run into.
I'm also having the same issue, I can get the DAP connection but can't get breakpoints to work correctly. Or get it to run from VS code.
Hi, I implemented the DAP backend in Godot quite a long time ago, and haven't really looked at it lately to check if it's working properly. I'll have a look regarding some issues reported here.
One thing I've neglected to do was document how to configure Godot and text editors to use this protocol. I'll have a look and see if this could be added to Godot Docs. In the mean time, this comment and my GSOC report should have all the info you need to setup DAP through VSCode.