Connection to closed by remote host.

Seiji Horinouchi February 7, 2018

hi, get error when git push with ssh.

ssh -T is OK.

git remote -v is OK.

what is wrong?


following, shell trace when git push:

git push --progress -v A B

Pushing to
Counting objects: 31, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (17/17), done.
Writing objects: 100% (31/31), 4.73 KiB | 0 bytes/s, done.
Total 31 (delta 3), reused 0 (delta 0)
Connection to closed by remote host.
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

2 answers

1 vote
xpt September 25, 2022

Today I bumped into the exact same problem -- 


ssh -T is OK.

git remote -v is OK, and even git clone & push an empty repo OK!

yet, error when git push with ssh.


Found a similar report at:


I have pushed my repository to bitbucket master thousands of times.
Today for some reason I cannot push several commits to bitbucket.


and a related one at:

from which I've tried every single "working solution" in all the answers. But nothing worked.

And moreover, my git repo is only 1.5M in size, even including all the histories.


Now, 6 hours later, I did a git push again, and it worked without a hitch (at 1.13 MiB/s and my machine can do 9M/s download without a fuss), and I haven't changed a thing since.


So I'd say it is the git server was stressed when I was doing my push, and the "working solution" like the following,

"Tried all the solution posted here, but this one solution only worked!"

is nothing but the server stress happened to be over.


BTW, here is the `GIT_TRACE=1 GIT_CURL_VERBOSE=1 GIT_SSH_COMMAND="ssh -vvv" git push --progress -v` log:


. . .
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 2097152 rmax 32768
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
debug3: send packet: type 1
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
#0 client-session (t4 r0 i0/0 o0/0 e[write]/0 fd 4/5/6 sock -1 cc -1)

debug1: fd 0 clearing O_NONBLOCK
debug3: fd 1 is not O_NONBLOCK
Connection to closed by remote host.
Transferred: sent 2800, received 1956 bytes, in 59.3 seconds
Bytes per second: sent 47.2, received 33.0
debug1: Exit status -1
fatal: Could not read from remote repository.


0 votes
Caterina Curti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 3, 2018

Hi Seiji,  

The message "The Remote End Hung Up Unexpectedly" would indicate a timeout occurred, most likely in one of the components of the network.

Can you check the network components involved on your end?


Running the same command with the additional logging enabled will provide more details on the exact issue. Can you try running this?

GIT_TRACE=1 GIT_CURL_VERBOSE=1 GIT_SSH_COMMAND="ssh -vvv" git push --progress -v A B


Thanks, Caterina - Atlassian 

Sharath Mekkottil November 13, 2019

GIT_CURL_VERBOSE=1 GIT_SSH_COMMAND="ssh -vvv" git clone A

trace: built-in: git 'clone' 'A'

Cloning into 'A'...

trace: run_command: 'ssh' '' 'git-upload-pack '\''A'\'''

trace: run_command: 'index-pack' '--stdin' '-v' '--fix-thin' '--keep=fetch-pack 345 on git2consul4nodeagents-58c46cfbc4-xvw8d'

trace: exec: 'git' 'index-pack' '--stdin' '-v' '--fix-thin' '--keep=fetch-pack 345 on git2consul4nodeagents-58c46cfbc4-xvw8d'

trace: built-in: git 'index-pack' '--stdin' '-v' '--fix-thin' '--keep=fetch-pack 345 on git2consul4nodeagents-58c46cfbc4-xvw8d'

remote: Counting objects: 14094, done.

remote: Compressing objects: 100% (4531/4531), done.

packet_write_wait: Connection to port 22: Broken pipe 

fatal: The remote end hung up unexpectedly

fatal: early EOF

fatal: index-pack failed

amir_meshkin February 8, 2020

You probably have large files. I've removed my large files but I am still having the same issue.

James Stevens
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 16, 2024

Yep - I get "Connection to closed by remote host" ridiculously often with BITBUCKET, its WAY worse than github - my best solution is to wait until morning. As I'm on UK time I can push OK in the mornings when all the americans are still in bed

But come on guys - bandwidth & servers are DIRT cheap these days - there's absolutely no excuse for this kind of shoddy service

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events