239

I have had up to 8 git bash terminals running at the same time before.

Currently I have only 2 up.

I have not seen this error before and I am not understanding what is causing it.

Any help would be appreciated!

Picture attached:

enter image description here

4
  • 51
    -1 to all current answers. All variations of "just kill terminal and start again". What's the underlying problem? Why can't I have 100 terminals?
    – RJFalconer
    Aug 16, 2018 at 15:53
  • 35
    I've had this issue for such a long time and never been able to get to the bottom of it. It seems to be applications that are left open which can cause some handles to remain open, but in my case the bash processes were being closed and there are no ssh processes around (I'm using mosh). I've just been able to replicate the issue by launching vscode using vscode . and then closing the terminal used to open it. While the vscode window stays open it seems Cygwin doesn't want to open more terminals, as soon as I close it, it works. Nov 22, 2018 at 18:34
  • I'm using msys2 and had to kill three processes using Windows Task-Manager. I identified them by their commandline. Sep 17, 2020 at 19:11

36 Answers 36

107

Found a similar issue and solution in google groups

I opened a windows command prompt and ran the command

$ tasklist

It looks as though the ssh connections I had made in my git bash shells weren't being closed when those windows were closed and were hanging the available git bash shell windows.

This may be a dangerous solution but from the windows command prompt I ran

$ taskkill /F /IM ssh.exe 

Everything appears to be working again after this. It may not have directly been an issue of orphan processes, but this worked for at least for me.

Additional note: you can also kill other processes, for example like:

$ taskkill /F /IM vim.exe
16
  • 6
    This procedure worked, although in my case the culprits were node.exe (Node.js) and link.exe (GNU link). So you may have to hunt through the tasklist for the guilty processes. I'm not sure why, but it does seem like programs launched from inside Bash sessions can somehow out-live their parent shell.
    – mamacdon
    Aug 28, 2017 at 19:06
  • 2
    Thank you scott, this procedure worked by as mentioned by @mamacdon even in my case culprits was node.exe.
    – S52
    Oct 6, 2017 at 16:18
  • 24
    For me, I had to perform "taskkill /F /IM ssh-agent.exe" but close enough for an up-vote. Oct 12, 2017 at 19:46
  • 15
    I had to kill node.exe with the command taskkill /F /IM node.exe
    – Tarator
    Feb 15, 2018 at 12:09
  • 1
    In my case (with Cygwin) it was a single adb.exe that was still running. Killing it solved. Jun 22, 2018 at 18:54
89

In my case, it was related with the use of VS code. Previously I have opened VS code using a git bash terminal and executing

code .

then closing the terminal.

The problem is solved by closing all the VS code windows opened.

When you have any editor or IDE configure to open a terminal as git bash, then when the IDE/IDE is running, the git bash will spin up bash from "C:\Windows\System32\bash.exe" and any other attempt to open bash from a separate window is likely to crash.

The best solution is to kill the IDE/Editor bash and open from a new window or continue from the IDE/Editor command.

2
  • 1
    Rather than closing all the VSCode windows - which can set you back - I was able to relaunch Git Bash by just trashing (clicking on the trash icon rather than just closing) the integrated terminal in VSCode. Then you can launch Git Bash as a separate process. Afterwards, you shouldn't get the error in the integrated terminal when you ctrl + ~ to open a new one either.
    – chrisz
    Jul 5, 2020 at 19:12
  • Is there an explanation for how / why VSCode is the problem / root cause? I experienced this today and ended up here. It turned out VSCode was the cause.
    – truedat101
    Dec 22, 2022 at 2:08
70

I see the problem on windows in git bash when I kill my git bash console without using exit. I found killing ssh-agent.exe task from windows task manager to fix the problem.

1
  • 2
    this is a short term solution. the problem returns eventually. hoping there is a more permanent way to fix this issue
    – Sonic Soul
    May 8, 2019 at 17:15
42

I address this with a workaround:

  1. Close the Git Bash window.
  2. Open Task manager.
  3. Find the 'Git for Windows' process.
  4. Kill it.
  5. Open Git Bash.

It should be ok now.

0
9

This happens when you exit Git Bash without terminating an existing process. Just try and kill those processes that you started from Git Bash.

I was running node process inside Git Bash, so I killed all node processes.

Steps to kill

  1. Open Task Manager
  2. Go to Details Tab
  3. Look for the process that was running in Git Bash (e.g. node, python)
  4. Kill all instances of that process
  5. Open Git Bash again
1
  • for me, it was python, which was running when I closed a Git Bash window.
    – wisbucky
    Aug 16, 2023 at 17:38
7

Open task manager and kill process with name bash, this worked for me.

7

To make life easier (this problems happens quite often) create a file called fixbash.bat in home directory and paste this:

taskkill /F /IM ssh-agent.exe

When problem occurs just open cmd and type fixbash.bat to fix a problem.

Or

Just paste the taskkill command into your cmd if you don't want to create a script.

2
  • 4
    returns: ERROR: The process "ssh-agent.exe" not found. Aug 20, 2019 at 0:10
  • This solution worked for me . However you have to go to the task manager and kill all ssh-agent.exe as there can be many
    – Java Main
    Apr 21, 2020 at 9:26
6

Restart your machine.

(The other answers did not work for me. (I didn't try reinstalling. Restarting is probably faster.))

1
  • 13
    And if that doesn't work, reinstall your machine, or buy a new one.
    – john16384
    Sep 17, 2019 at 7:16
6

finally figured out what was causing this.

if we use code like this (explicitly or implicitly) i.e. in .bashrc file

eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa

it spawns a new process.

if you don't exit it and just close the window, that process is still running. so each new bash opened just keeps adding new ones w/out disposing old ones.

when done with a bash window, simply hit ctrl+d or type exit to kill the agent process, and you should not run out of forks.

0
6

In my Case I need to kill Git bash in Windows. So opened Command Prompt and ran below command

$ tasklist

It will list down all running tasks, then need to kill bash.exe task using below command

$ taskkill /F /IM bash.exe 
1
  • process bash.exe not found. It's something beyond some stray exe hanging around.
    – Larry_C
    Jul 28, 2020 at 17:56
5

For me (or anyone running protractor, which may spin up a standalone Selenium/WebDriver server), I needed to taskkill the specific webdriver which was running my tests.

So just a different argument: or your chromedriver version may vary

taskkill /f /im chromedriver_2.34.exe

Note your driver may vary: IEDriverServer*.*.*.exe vs chromedriver_*.**exe

Your driver may version may vary:chromedriver_2.34.exe vs chromedriver_2.33.exe

This problem got worse after protractor quit without closing the automated /test-driven browser, (due to a separate issue I don't yet understand.) Naturally many chromedriver tasks remain running, that's why kill them.

0
3

Seems to be an issue with the processes launched from the git bash indeed, like @mamacdon suggested in his comment on the top answer by @Scott Newson.

For me, the issue appeared if I launched a vscode from the bash with code, and if this instance of vscode launched an integrated git terminal while the original bash was still running.

Doesn't matter whether that terminal was launched at the start or later, as long as it was while the original bash was still running.

Didn't happen when the bash was closed before the integrated terminal was opened. Didn't differentiate between exit and closing bash via windows. Didn't happen with another older bash window still running.

The way to deal with it was for me to close the terminals in vscode with exit or 'Kill Terminal' (be careful not to mix that up with 'close pane'), or of course, closing vscode itself.

If you get this error try to remember what you launched from the bash and kill it. If the other answers worked for you, it's probably just that these are the things launched by your bash or launched by processes you launched from the bash and they somehow were getting a child of your original bash.

3

If you are using Visual Studio Code and you can't find ssh-agent.exe or can't taskkill it and after opening Git Bash you get that error, just go to your VSCode open Terminal>New Terminal and just press the trashbin icon the (Kill Terminal). e.g (1:bash) if you got multiple then just kill them all and you should be good.

3

In my case, I was running jupyter-notebook from Git Bash and closed the terminal without closing the notebook. When I closed all running git bash terminals and tried to open new terminal, this gave me the error:

Error: Could not fork child process: There are no available terminals (-1).

Solution

taskkill /F /IM jupyter-notebook.exe

After that, I was able to run commands in git bash terminal.

1
2

I tried to kill all my git terminals in task manager solves the problem. This works for me too. good luck.

2

Open your Task manager, search "sh" procces and kill them. Good luck

1

i found that killing msys2 terminal in task manager solves the problem

0
1

On a more recent version of git for windows, the process to kill in task manager was "GitExtensions.exe". Killed that and the terminals restarted with no issues.

1

Please find the ssh-agent process in the Task Manager window. After you stop or kill the ssh-agent process the error will disappear.

1

Open Task manager, find bash.exe process and kill it. Helped in my case.

1

In my case I had visual studio code running and closing it resolved the issue.

0
1

Windows 10 this worked for me:

1) open cmd as administrator

2) type:

taskkill /f /im git-bash.exe


3) If there was an Error: The process "ssh-agent.exe" not found. then:

type:

tasklist

4) Find and kill every process with words like "bash" or "git" (This may be a dangerous solution, but once you will find the process name, next time you will know.)

taskkill /f /im ***.exe
1

Im my case, the solution was to close Visual Studio Code -where I had console running too without noticing-

After closing it all back to normal. Hope this helps someone.

1

In my case, I needed to kill sh.exe taskkill /F /IM sh.exe

1

In my case the problem was the file [git_install_dir]/etc/nsswitch.conf

I previously followed the instructions given here: https://cygwin.com/faq.html#faq.using.startup-slow. But this caused the "Could not fork" error instead. My wrong nsswitch.conf file was:

passwd: files
group: files

So I restored the file and problem solved. Now my [git_install_dir]/etc/nsswitch.conf is:

passwd: files db
group: files # db
db_enum: cache builtin
db_home: env windows cygwin desc
db_shell: env windows # cygwin desc
db_gecos: env # cygwin desc
1

Many answers here are suggesting different processes they need to kill in order to be able to open a new Git Bash terminal. In my case there were multiple conhost.exe processes running which I had to kill before I could open another window successfully.

Perhaps more importantly, is why it happened. I think I know exactly what I did which led to this state. I noticed that when typing git log, if I then resize my Git Bash window, it would hang. (Pressing q would not exit the log and I could no longer type commands.) I ended up closing the window and opening another one. I was doing some testing of this repeatedly to see if I could figure out a solution to the freezing after resizing, and after doing this multiple times (probably around 10 times), I received the error in this question. The results of my testing are:

Opening a new Git Bash Window starts the following processes:

  1. conhost.exe
  2. git-bash.exe
  3. git.exe
  4. mintty.exe

Now, when you type git log, 4 additional processes open:

  1. bash.exe
  2. conhost.exe
  3. git.exe
  4. less.exe (this will only stay open if your log cannot fit on one screen)

When you close Git Bash, those 8 processes all normally go away. However, due to a bug, (which I think is possibly in less.exe) when you resize the window while viewing the log, Git Bash hangs. If you now close the window only 6 of the 8 processes close. Both less.exe and conhost.exe stay active. In my case, eventually enough conhost.exe processes built up and caused whatever the issue is that leads Git Bash displaying the error and not starting.

That said, I tried to repeat the issue but gave up after 20+ tries, which was more conhost processes than I had to kill when I was in the problem state. I suspect it's not a process number but something about the state of one or more processes that leads to the error. Obviously since other answers mention closing different processes, the "thing" that isn't closing properly and fighting against Git Bash can vary, depending on what tools you're using.

Note, I'm using Git version: 2.37.1.windows.1.

1
I tried resolving the issue with the given answers but had no luck 
C:\Windows\System32>taskkill /F /IM bash.exe
ERROR: The process "bash.exe" not found.
C:\Windows\System32>taskkill /F /IM vim.exe
ERROR: The process "vim.exe" not found.

then I resolved it by killing ruby.exe process at command prompt and it worked for me
taskkill /F /IM ruby.exe
0

For windows, in task-manager kill sh.exe.

0

Tried the following solution which worked for me:

  1. Kill all existing git.exe
  2. Added my credentials for BitBucket in the Windows Credential manager under the generic credentials section. enter image description here
0

Nothing worked ,This is basically the last git-bash did not terminate properly , finally had to kill these all ,

Open CMD

taskkill /F /IM git-bash.exe
taskkill /F /IM git.exe
taskkill /F /IM git-remote-https.exe
taskkill /F /IM git-credential-manager.exe

Now git bash window works fine

Not the answer you're looking for? Browse other questions tagged or ask your own question.