Every time I build or run a program in VSCode a new python debug console is loaded. Before I know it I have 20+ and need to start deleting them. After 32 open consoles I get the error "The terminal process terminated with exit code: 256". I changed the terminal from the default console to git bash recently. How can I stop this?
-
3I have the same problem. Your mention of Git Bash prompted me to change the VS Code setting `terminal.integrated.shell.windows` back to the default instead of Git Bash, and now the problem is gone. It seems to be a bug specific to using Git Bash as your default VS Code terminal, as you may already know. – MarredCheese Jan 17 '19 at 19:54
-
I got the "The terminal process terminated with exit code: 256" error after I had to alter my launch.json configuration to include "console": "integratedTerminal" in order to be able to debug a script that was using an external package (package "inquirer", which outputs a text-based wizard, and for which the output isn't shown in the debug console). As I was debugging, I didn't notice each debug opened another terminal. The error I encountered was from git: "*** fatal error - console device allocation failure - too many consoles in use, max consoles is 32" . It looks like this number is fixed – Daniël Teunkens Aug 29 '19 at 08:10
-
See my [detailed answer here](https://stackoverflow.com/a/58194881/6501141). – LightCC Oct 28 '20 at 15:47
5 Answers
A way around this issue is to stop VS Code from redundantly printing to the TERMINAL
during debugging in the first place. Since it prints to the DEBUG CONSOLE
as well, you can use that instead.
Change console
to "none"
"internalConsole"
in each configuration in your project's launch.json
file:
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "internalConsole"
}
]
May 2019 Update: the "none"
option was replaced by "internalConsole"
so I edited my answer to reflect that. Here's the relevant GitHub Issue.

- 17,541
- 8
- 92
- 91
-
1Note that the internalConsole does not allow standard input (i.e. ask for user input via the console), so this solution may not be workable. See alternative solution in [this answer](https://stackoverflow.com/a/58194881/6501141) I verified via logging a defect that there is some disconnect with how Python extension is requesting the terminal but it not being reused by the core VS Code framework. The Python code guys say it SHOULD be reusing it... There's got to be something wrong though, because if you launch a Python script it will reuse the same "Python" named terminal for that function... – LightCC Oct 28 '20 at 15:50
Adding "args": ["&&", "exit"],
to launch.json
remedies this for Git Bash. Certainly a hack, but I no longer have to manually close many debug terminals.

- 121
- 2
- 4
-
3In my case this didn't work, but `"args": ["\n","exit", "0"]` did. Thank you for pointing me in the right direction, anyway – pcan Apr 11 '20 at 09:51
-
1
This may have been resolved in recent debug updates to core VS Code within the last year (as of 8/2022), but I was still seeing this intermittently.
I don't know if this will help the original poster, but I discovered that for me the issue persisted due to using Git Bash as the default terminal in Windows. Switching to Command Prompt as the default terminal fixed the issue. I haven't tested with other platforms or terminals.
Changing the default terminal to Command Prompt causes the Python extension to launch the "Python Debug" terminal with Command Prompt instead of Git Bash. I did log a VS Code/Python Extension defect about this. The initial response is that Git Bash is not officially supported currently.
There appears to be a communication problem between the Git Bash terminals and VS Code that causes this issue. Some of the characters between Git Bash and VS Code get dropped. Sometimes this mangles the debug command and I get and error and have to retry in addition to getting an extra debug window.
There is some additional background info and hacks to fix this from the past in this answer.

- 9,804
- 5
- 52
- 92
Hopefully fixed in the Insiders Build and should be in v1.54. See Debug opens a new integrated terminal for each Python session . Test it in the Insiders Build if you can and report at the issue if it fixed/did not fix.

- 143,421
- 24
- 428
- 436
Actually you can delete all the instances of the terminal just by clicking on the trash can icon . If it does not work for the first time, restart the VS Code and try again.

- 71
- 1
- 3
-
Hitting delete actually causes a crash or hang if there are too many consoles open from a long debugging session. I've seen this behavior around ~10 open debug consoles. Not a solution – Isaac Oct 06 '20 at 19:21
-
There's a memory limitation for using too many instances. VS Code still needs some improvements. I've tested with some Java code, every time you run the code a new instance is called. The result is a lot of consoles open, behind the scenes. – marcfreir Jan 20 '21 at 15:15