1. Bitbucket Website
  2. Public Issue Tracker
  3. master

Issues

Issue #6331 on hold

ssh_exchange_identification: Connection closed by remote host (BB-10785)

Peter Eisentraut
created an issue

I have a cron job that pulls from a bitbucket repository once an hour. Every so often, the cron job emails me

ssh_exchange_identification: Connection closed by remote host
fatal: The remote end hung up unexpectedly

This started a few weeks ago with this happening perhaps once every few days. Now it's getting worse, happening almost every hour.

To check, I set up the same cron job on a completely separate host, and it's showing the same behavior. So I suspect the problem is on the server's end.

Comments (255)

  1. Brian Nguyen

    Hey,

    Are you still seeing this problem? We have been experiencing some performance issues in the last couple of days that may be causing this.

    If you are still experiencing this, would you be able to run this?

    GIT_CURL_VERBOSE=1 git pull origin
    

    It should give us a better idea of where the problem is occurring.

    Cheers, Brian

  2. Brian Hrebec

    Just wanted to chime in that I've been seeing an identical error; it happened very frequently (almost every other request) a few weeks ago, but has decreased to the point where it only happens a couple of times per day.

    Curiously enough, I haven't been able to trigger the problem while running git manually. It only seems to occur in a cron job.

  3. Brian Nguyen

    Hi Peter,

    Unfortunately, I am not able to diagnose the issue with the information at hand. It would be handy to see exactly where in the process the connection is being severed. Does git pull --verbose work?

    Just to get a better idea of the environment, could you answer a few questions:

    • Does it happen for any of your other repositories?
    • How large is the repository, and how frequently is it updated?
    • Does the cron job pull from the repository or does it create a clone?

    Cheers, Brian

  4. Brian Hrebec

    I haven't turned up anything interesting with git (pull|fetch) --verbose (The error occurs first thing, and no additional messages are shown), so I've added ssh -vvv git@bitbucket.org to the crontab in hopes of getting more detail. Will report back if it triggers the same problem.

    To answer some of the above questions:

    • It happens randomly over every repository I've tried.
    • Some repositories are quite small and have only been updated once or twice since being moved to bitbucket, another is medium-sized and is updated many times per day.
    • For me, it happens with a pull; I don't use clone in crontab and haven't noticed it causing a problem.
    • Based on limited testing, https doesn't have any problems, but I won't be sure until it's ran a bit longer.
  5. Anadi Misra

    Hi!

    I am experiencing the same issue here, though not sure if it is misconfiguration on my side or anything else. port 22 is blocked in my office so this is what I did to

    ~/.ssh/confg
    

    file

      Host bitbucket.org
      User git
      Hostname altssh.bitbucket.org
      IdentityFile ~/.ssh/git_id_rsa
      IdentitiesOnly yes
      Port 443
    

    Saw this in bitbucket confluence site that we can use URL of the form

    ssh://git@altssh.bitbucket.org:443/username/gitrepo
    

    hence these changes

    here is the output

    $ ssh -vT git@bitbucket.org
    OpenSSH_6.2p2, OpenSSL 1.0.1e 11 Feb 2013
    debug1: Reading configuration data /home/misraa3/.ssh/config
    debug1: /home/misraa3/.ssh/config line 7: Applying options for bitbucket.org
    debug1: Connecting to bitbucket.org [131.103.20.168] port 443.
    debug1: Connection established.
    debug1: identity file /home/misraa3/.ssh/git_id_rsa type 1
    debug1: identity file /home/misraa3/.ssh/git_id_rsa-cert type -1
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_6.2
    debug1: ssh_exchange_identification: <html>
    debug1: ssh_exchange_identification: <head><title>400 Bad Request</title></head>
    debug1: ssh_exchange_identification: <body bgcolor="white">
    debug1: ssh_exchange_identification: <center><h1>400 Bad Request</h1></center>
    debug1: ssh_exchange_identification: <hr><center>nginx/1.5.3</center>
    debug1: ssh_exchange_identification: </body>
    debug1: ssh_exchange_identification: </html>
    ssh_exchange_identification: Connection closed by remote host
    
  6. JenkinsEgmont

    I am experiencing this same thing. My script resolves branches (using git ls-remote) every minute from github via ssh and this issue happens in interesting points of time:

    Date: Wed, 12 Mar 2014 14:00:02 +0000 (UTC)
    Date: Wed, 12 Mar 2014 15:00:02 +0000 (UTC)
    Date: Wed, 12 Mar 2014 16:30:03 +0000 (UTC)
    Date: Wed, 12 Mar 2014 18:00:03 +0000 (UTC)
    Date: Wed, 12 Mar 2014 18:00:03 +0000 (UTC)
    Date: Wed, 12 Mar 2014 22:00:02 +0000 (UTC)
    Date: Thu, 13 Mar 2014 00:00:02 +0000 (UTC)
    Date: Thu, 13 Mar 2014 02:30:02 +0000 (UTC)
    Date: Thu, 13 Mar 2014 03:00:02 +0000 (UTC)
    Date: Thu, 13 Mar 2014 03:00:02 +0000 (UTC)
    Date: Thu, 13 Mar 2014 04:20:02 +0000 (UTC)
    Date: Thu, 13 Mar 2014 04:30:02 +0000 (UTC)
    Date: Thu, 13 Mar 2014 05:00:02 +0000 (UTC)
    Date: Thu, 13 Mar 2014 05:30:02 +0000 (UTC)
    Date: Thu, 13 Mar 2014 06:00:02 +0000 (UTC)
    Date: Thu, 13 Mar 2014 06:00:02 +0000 (UTC)
    
  7. Mark Alexander

    I have cron-ed pulls every few minutes. This morning I came into over 1500 failure emails.

    These pulls are how our production deployments are triggered. The need to be much more reliable.

  8. Ethan Kaminski

    Looks like someone has opened issue #9685 for the new recurrence of this fault.

    I've seen this twice in manually-triggered script runs this week. We have a test server that's maintained using scripts, and those scripts have generated error messages about ssh_exchange_identification. I've not seen the issue (yet) when working locally.

  9. Krzysztof Niziol

    Same problem here. Details:

    Failed to update git@bitbucket.org:<name-of-repository>.git, package information from this repository may be outdated (ssh_exchange_identification: Connection closed by remote host
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    error: Could not fetch origin
    )
    

    When it wil be fixed?

  10. Shamasis Bhattacharya

    Hi,

    We at FusionCharts are experiencing the same problem too. Since last week we are having one in three automated builds fail with error ssh_exchange_identification: Connection closed by remote host while cloning submodules. (We have quite a few of them in a single repository. That's a different story!)

    No doubt that the frequency has reduced. But we are still facing this while cloning submodules during our CI builds at a rate of 1 in 10. Interestingly, not all submodules fail to clone. Random ones fail in builds.

  11. Hannes Ebner

    I am experiencing the same problem; several repositories fail to be pulled regularly and I have to retry several times before the operation completes successfully.

  12. ashley stovall

    im having the same issue, teamcity goes kaplooy at least 3 times a day.

    its hard for me to tell you what teamcity was doing at the times of failure...ill turn up logging to see if that helps.

    what i can tell you though is that i have a script that run git pull on 53 repos using 4 concurrent threads and it appears that 1 of these concurrent requests fails with this error (remote end hung up). if you change the script to pull the repos linearly, it almost never fails. from my end, it feels concurrent volume related.

    ill turn up the verbosity of my script to see what that yields at the ssh layer.

  13. Marcus Bertrand [Atlassian] staff

    For everyone following this issue, can we get a little more detail? We are struggling to reproduce this. Does it happen immediately or does the command run for a while then fail? Also, when it happens, do all connections then continue to fail until a period of time has passed with no attempts? Or does it feel random?

  14. Stan Hu

    I am using the SSH protocol (port 22) to pull from private repositories. The failure feels random, and the command fails pretty quickly when it does. Connections usually work after I retry again.

  15. Mark Alexander

    Marcus, It fails immediately because SSH is refusing the initial exchange. Retrying immediately almost always works. I suspect the association with cron means there's a bunch of connections at 5, 10, 15, etc, minute intervals so you're getting spikes of many ssh handshakes.

    I recommend reviewing the MaxSessions and MaxStartups SSHD options. The default of MaxSessions is only 10. It doesn't take many time-sync'ed cron jobs to max that out.

  16. Matt Diiorio

    Here's what I get from ssh with verbosity turned up:

    OpenSSH_6.0p1 Debian-4, OpenSSL 1.0.1e 11 Feb 2013
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 19: Applying options for *
    debug2: ssh_connect: needpriv 0
    debug1: Connecting to bitbucket.com [131.103.20.172] port 22.
    debug1: Connection established.
    debug1: permanently_set_uid: 0/0
    debug3: Incorrect RSA1 identifier
    debug3: Could not load "/root/.ssh/id_rsa" as a RSA1 public key
    debug1: identity file /root/.ssh/id_rsa type 1
    debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
    debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
    debug1: identity file /root/.ssh/id_rsa-cert type -1
    debug1: identity file /root/.ssh/id_dsa type -1
    debug1: identity file /root/.ssh/id_dsa-cert type -1
    debug1: identity file /root/.ssh/id_ecdsa type -1
    debug1: identity file /root/.ssh/id_ecdsa-cert type -1
    ssh_exchange_identification: Connection closed by remote host
    fatal: The remote end hung up unexpectedly
    
  17. ryuhei.ishibashi

    Here's the same problem in hg.
    Details :

    running ssh hg@bitbucket.org 'hg -R uzabase/speenya serve --stdio'
    sending hello command
    sending between command
    remote: ssh_exchange_identification: Connection closed by remote host
    abort: no suitable response from remote hg!
    
  18. ryuhei.ishibashi

    Here's the same problem in hg.
    Details :

    running ssh hg@bitbucket.org 'hg -R uzabase/speenya serve --stdio'
    sending hello command
    sending between command
    remote: ssh_exchange_identification: Connection closed by remote host
    abort: no suitable response from remote hg!
    
  19. Steve Muskiewicz

    Same issue here (ssh port 22). Not sure if the timing is significant but I appeared to be seeing more failures than usual running at around 3am ET (though my cron entry is limited to when it runs). Prior to June 6th, we never saw any of these issues at all.

  20. Chris Pook

    I've been seeing these periodically whilst running Composer install/update commands. The clones fail with

    [RuntimeException]
      Failed to execute git clone --no-checkout "git@bitbucket.org:company
      /project-dependency.git" "C:\wamp\www\project\vendor\company/dependency" && cd /D "C:\wamp\www\project\vendor\company/dependency"
      && git remote add composer "git@bitbucket.org:company/project-dependency.git" && git fetch composer
    
      ssh_exchange_identification: Connection closed by remote host
      fatal: Could not read from remote repository.
    
      Please make sure you have the correct access rights
      and the repository exists.
    
  21. Erik van Zijst staff

    That's discouraging, but thanks for letting me know. I'll dive back in.

    What errors are you seeing exactly (to confirm we're not looking at a different issue)? You're seeing ssh_exchange_identification errors?

  22. ericatienza

    same as Mark, better but still not resolved. and to answer to Erik : $git pull ssh_exchange_identification: Connection closed by remote host fatal: The remote end hung up unexpectedly

  23. Erik van Zijst staff

    Excellent! I was hoping to hear that. After the initial reports of some lingering issues last week we found another issue that we addressed. Since then we've been unable to reproduce the issue ourselves and so it's encouraging to read your feedback.

    I'm going to close this issue again, however if anyone is still seeing systemic issues, feel tree to reopen once more.

  24. Ethan Kaminski

    Erik - we may have experienced two recurrences of this issue, approximately 15 minutes and 30 minutes before jsashi commented. My evidence for this is some unexpected script failures - unfortunately, the script in question discards stderr, so I can't say for sure whether it's the same error, nor can I offer any specifics.

  25. jsashi

    Erik van Zijst I have edited my original comment saying it's not happening anymore now. But just for your info, it's the same error message with another variation at times:

    Permission denied (publickey). fatal: The remote end hung up unexpectedly

    However, most of the times, it's: ssh_exchange_identification: Connection closed by remote host fatal: The remote end hung up unexpectedly

  26. Dominik Bruhn

    Same problem here: $ git fetch --all Fetching origin ssh_exchange_identification: Connection closed by remote host fatal: The remote end hung up unexpectedly error: Could not fetch origin

  27. Mark Alexander

    Subtle difference this time. We've implemented 3 retries due to this issue and that was working around the problem before this last occurence. We've had 11 times overnight where 3 consecutive tries failed. All but 1 failure was the ssh_exchange_identification failure. The other was the "Permision denied" noted by jsashi.

    Good luck!

  28. George Milonas

    I am getting the exact issues everybody reported and its an intermittent issue. We have about 30 servers checking and pulling every 5mins. This is unbelievable. Our app is going crazy...Anyone has any idea about avoid this issue?

  29. Erik van Zijst staff

    I've got trouble reproducing these problems. We did have a little bit of an unrelated issue that caused some hiccups on the SSH front on Sunday, which has since been addressed.

    George Milonas if you are seeing persistent issues, can you paste some of the errors, including timestamps? If you'd rather not share that publicly here, you can email me at erik@bitbucket.org

  30. Bill Heisler

    This problem appears to be a capacity issue. Added an offset to our scripts so they don't hit exactly on the minute anymore and that resolved the problems for us. It seems like cron scripts are pushing something past connection limits on bitbucket side (server/firewall/...).

  31. Chris Pook

    Hi I started getting these again today at 13:00UTC, possibly related to the database high load from yesterday ?

    ssh_exchange_identification: read: Connection reset by peer
    fatal: Could not read from remote repository.
    
  32. Oliver Schwarz

    We are using bower in our CI environment to fetch other components from their repositories which in the last days very often result in build failures. We experience the same error message:

    Additional error details:
    ssh_exchange_identification: Connection closed by remote host
    fatal: The remote end hung up unexpectedly
    npm ERR! weird error 1
    npm ERR! not ok code 0
    Build step 'Execute shell' marked build as failure
    [...]
    

    If we can help with any more status info or tests, please tell me :) This message was from 12 a.m. European Time.

  33. Erik van Zijst staff

    Looking through my temp logging I can see there was 1 single hickup at 1:25am UTC that lasted less than 2 seconds. I don't see any errors besides that.

    Chris Pook is there any chance you could narrow down the exact timestamps whenever this happens?

  34. Jason Darwin

    Hi Erik, I think I just ran into this issue -- pushing to my bitbucket repo (git@bitbucket.org:jcdarwin/journalsurf-front.git) and received:

    Sun 31 Aug 2014 23:46:39 NZST
    hare:laravel jasondarwin$ git push bitbucket master
    Counting objects: 486, done.
    Delta compression using up to 2 threads.
    Compressing objects: 100% (420/420), done.
    Writing objects: 100% (472/472), 2.01 MiB | 0 bytes/s, done.
    Total 472 (delta 76), reused 0 (delta 0)
    Killed by signal 2.
    
  35. Hannes Schmidt

    Same here:

    $ ssh -vvv git@bitbucket.org
    OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
    debug1: Reading configuration data /Users/hannes/.ssh/config
    debug1: /Users/hannes/.ssh/config line 9: Applying options for bitbucket.org
    debug1: Reading configuration data /etc/ssh_config
    debug1: /etc/ssh_config line 20: Applying options for *
    debug1: /etc/ssh_config line 53: Applying options for *
    debug2: ssh_connect: needpriv 0
    debug1: Connecting to bitbucket.org [131.103.20.167] port 22.
    debug1: Connection established.
    debug1: identity file /Users/hannes/.ssh/id_rsa type -1
    debug1: identity file /Users/hannes/.ssh/id_rsa-cert type -1
    debug1: identity file /Users/hannes/.ssh/id_dsa type -1
    debug1: identity file /Users/hannes/.ssh/id_dsa-cert type -1
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_6.2
    ssh_exchange_identification: Connection closed by remote host
    
  36. 賜彦 封

    same

    ssh_exchange_identification: Connection closed by remote host fatal: Could not read from remote repository.

    Please make sure you have the correct access rights and the repository exists.

  37. michael montgomery

    I am also getting this issue ssh_exchange_identification: Connection closed by remote host fatal: Could not read from remote repository.

    Please make sure you have the correct access rights and the repository exists.

    has never happened before

  38. Junwen Xu

    "ssh_exchange_identification: Connection closed by remote host fatal: Could not read from remote repository.

    Please make sure you have the correct access rights and the repository exists. "

  39. Nik Garkusha

    Been hapenning for an hour.

    Cloning into 'test'...
    ssh_exchange_identification: Connection closed by remote host
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    
  40. Tom King

    same here. tried connecting with ssh -Tvvv to generate more info for Atlassian to debug

    ssh -Tvvv git@bitbucket.org
    OpenSSH_6.6, OpenSSL 1.0.1i 6 Aug 2014
    debug1: Reading configuration data /Users/name/.ssh/config
    debug1: /Users/name/.ssh/config line 5: Applying options for bitbucket.org
    debug1: /Users/name/.ssh/config line 39: Applying options for *
    debug3: ciphers ok: [aes256-cbc,aes256-ctr,aes128-ctr,aes128-cbc,blowfish-cbc]
    debug3: key names ok: [ssh-ed25519,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,ssh-rsa]
    debug3: kex names ok: [diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1]
    debug3: macs ok: [hmac-sha2-512,hmac-ripemd160,hmac-sha2-256]
    debug1: Reading configuration data /usr/local/etc/ssh/ssh_config
    debug1: auto-mux: Trying existing master
    debug1: Control socket "/tmp/ssh_mux_bitbucket.org_22_git" does not exist
    debug2: ssh_connect: needpriv 0
    debug1: Connecting to bitbucket.org [131.103.20.167] port 22.
    debug1: Connection established.
    debug3: Incorrect RSA1 identifier
    debug3: Could not load "/Users/name/.ssh/bbkey" as a RSA1 public key
    debug1: identity file /Users/name/.ssh/bbkey type 1
    debug1: identity file /Users/name/.ssh/bbkey-cert type -1
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_6.6
    ssh_exchange_identification: Connection closed by remote host
    

    Same key worked earlier today.

    ... and works again now.

  41. Antriksh Sareen

    Vahan your problem is not the same as mine.... i guess... And am a new bie to bitbucket... So may not be able to help you..... I was not able to clone from bitbucket Repository using SSH to which i proceeded with answer suggested by Anadi and now i am able to.... But i face the same error in heroku.... I have setup heroku Successfully. I am able to login and create the app by heroku app, which gets visible in heroku my apps. I am able to add keys, by heroku keys:add but i am not able to push my premade bitbucket repository on heroku and face this error-

    git push heroku master ssh_exchange_identification: Connection closed by remote host fatal: Could not read from remote repository.

    Please make sure you have the correct access rights and the repository exists See if you can help me with this. I am not able to push my app to the heroku repository.I have tried many solutions at stackoverflow and many other sites but nothing worked.

    My .git/config : [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] url = git@bitbucket.org:sellzie/sellziedevapp.git fetch = +refs/heads/:refs/remotes/origin/ [branch "master"] remote = origin merge = refs/heads/master [remote "heroku"] url = git@heroku.com:whispering-castle-4126.git {Also tried git_heroku } fetch = +refs/heads/:refs/remotes/heroku/

    Host git_heroku {Also tried git@heroku } ProxyCommand corkscrew proxy.usurt.ru 3128 %h %p HostName ssh.heroku.com {Also tried heroku.com } User git IdentityFile "~/.ssh/id_rsa.pub"

  42. Torben Knerr

    Getting it regularly when pulling multiple repos from within a script. It's about 5 Repos that are pulled every 5 Minutes and it fails ~10 times per day.

    Today it happened the first time also on push while our CI server was trying to push a release tag

  43. Andy Randall

    We have been tracking this same issue for the last couple of weeks and I thought I would give some info about what we have observed. When a pull fails, the script doing the pull hangs, or so we thought at first. It hangs around waiting for a response for precisely two hours at which time the script exits and the 'connection reset by peer' error is written to the logs. Using netstat I can see that for successful pulls the connection goes through a series of status's (ESTABLISHED -> SYN_SENT -> TIMED_WAIT). There are probably other status's that fly by that I don't see, but for pulls that fail the connection never goes past ESTABLISHED. Interestingly enough, maybe related, maybe a different issue or maybe not an issue at all, the connection enters the TIMED_WAIT status at the time the script exits and hangs around for another thirty seconds before going away.

    The error written to the logs is usually:

      ssh_exchange_identification: read: Connection reset by peer
      fatal: The remote end hung up unexpectedly
    

    but is occasionally accompanied by:

      fatal: ambiguous argument '..FETCH_HEAD': unknown revision or path not in the working tree.
      Use '--' to separate paths from revisions
      fatal: 'FETCH_HEAD' does not point to a commit
    

    We are using Ubuntu 12.04.5 LTS

    Hope this helps.

  44. Jeroen Thora

    I'm getting this error more and more frequently last few weeks. (and almost every evening 16:30 most of our builds fail because of the timeout)

    Fetching changes from the remote Git repository
    Fetching upstream changes from git@bitbucket.org:vendor/repo.git
    ERROR: Timeout after 10 minutes
    

    This is a log line from our automatic builds in jenkins

  45. Steve McCullough

    I can push/pull/fetch fine from my local (OpenSSH_6.6.1p1 Ubuntu-2ubuntu2, OpenSSL 1.0.1f 6 Jan 2014), but have been getting timeouts all week from a dev server (OpenSSH_5.3p1 Debian-3ubuntu7.1, OpenSSL 0.9.8k 25 Mar 2009). Might the problem be in the version of the ssh client?

  46. Andy Randall

    Torben Knerr that is interesting. The "ambiguous argument" message seems to accompany the "Connection reset" message approximately on quarter of the time. I have also seen this message:

     ssh_exchange_identification: Connection closed by remote host
     fatal: The remote end hung up unexpectedly
    

    but not nearly as often as the "Connection reset" message and the last time it appeared in the logs was on 10/1. The "Connection reset" message is still happening daily, though.

  47. heath

    Just FYI, if you are including the port in your git ssh:// connection string then remove it. This cleared up our problems that started yesterday. We had failures doing:

    git ls-remote ssh://git@bitbucket.org:443/company/repository.git HEAD ssh_exchange_identification: Connection closed by remote host fatal: Could not read the remote repository

    Out of the blue from a working state for months. You might want to drop the port out of that connection string and see if it works for you if you're in our boat. Doing just:

    git ls-remote ssh://git@bitbucket.org/company/repository.git HEAD

    came back with expected results. Hopefully will help someone...

  48. Jesse Yowell [Atlassian] staff

    Heath,

    If you're going to use SSH with port 443, you'll need to use the altssh URL:

    ssh://git@altssh.bitbucket.org:443/accountname/reponame/

    Also, it may be worth trying using the above link if you're still having issues.. some have reported better performance, but we're still monitoring the original issue when connecting to port 22.

  49. Steve McCullough

    I am still unable to connect on the one server (sadly not under my control) running SSH 5.x. My machines on 6.x connect fine.

    ~/.ssh/config: Host bitbucket.org User git Port 22

    OpenSSH_5.3p1 Debian-3ubuntu7.1, OpenSSL 0.9.8k 25 Mar 2009 debug1: Reading configuration data /home/XXXX/.ssh/config debug1: Applying options for bitbucket.org debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug1: Connecting to bitbucket.org [131.103.20.168] port 22. debug1: connect to address 131.103.20.168 port 22: Connection timed out debug1: Connecting to bitbucket.org [131.103.20.167] port 22. debug1: connect to address 131.103.20.167 port 22: Connection timed out

  50. Mmj Jonckheere-Hundhausen

    Often it is caused by a traffic-monitoring router on the ISP's network. Also it may be a faulty NAT implementation. Anyway the cause is the WGET that is using up all bandwidth and at a certain moment in time, traffic gets blocked/lost/Idontknow. Solution is limiting bandwidth with the TC command.

    $ sudo tc qdisc add dev eth0 handle 1: root htb default 11
    $ sudo tc class add dev eth0 parent 1: classid 1:1 htb rate 1kbps
    $ sudo tc class add dev eth0 parent 1:1 classid 1:11 htb rate 1kbps
    

    for a 1 kpbs (gives a 36KiB/s result in git)

    After that : clear all TC rules

    $ sudo tc qdisc del dev eth0 root
    

    Source : Mark S. Kolich - Manually Throttle the Bandwidth of a Linux Network Interface

  51. jeanpierrevg

    Hi, I had CN.NET setup with Bitbucket working perfectly for the past month but since yesterday around 1 PM I have noticed the following error. Nothing has changed on our build machine so I am assuming maybe something is going on in BitBucket? Any help would be great!

    $ git fetch origin ssh_exchange_identification: Connection closed by remote host fatal: Could not read from remote repository.

    Please make sure you have the correct access rights and the repository exists.

  52. Muklis Latif

    same error here, just installed Git..

    this happens: fatal: Not a git repository (or any of the parent directories): .git

    when i when i enter $ GIT_CURL_VERBOSE=1 git pull origin

  53. NissimGaber

    I'm trying to push a big library into bit-bucket with mercurial and I received " remote: Connection to bitbucket.org closed by remote host abort: unexpected response: empty string" I work on Linux (Ubuntu 12) and I success to push a small libraries to bit-bucket and I have the problem only with large data SOS

  54. absynthe minded

    I've been having this problem since about 3:30 Eastern time yesterday.

    ssh_exchange_identification: Connection closed by remote host fatal: Could not read from remote repository.

    Please make sure you have the correct access rights and the repository exists.

    So I tried

    git push -u origin --all The authenticity of host 'bitbucket.org (131.103.20.167)' can't be established. RSA key fingerprint is SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'bitbucket.org,131.103.20.167' (RSA) to the list of known hosts. ^C C02MN530FD57:sample_app mluzietti$ git push ^C

    It just hangs now.

  55. Nate Johnson

    Looks like there are some rouge SSH processes running or something.

    One of my sites (different bitbucket repo) deploys just fine but another one gives me this after about a minute of waiting:

    ssh_exchange_identification: Connection closed by remote host fatal: Could not read from remote repository.

    Please make sure you have the correct access rights and the repository exists.

  56. James Fleeting

    The status page would be helpful if everything didn't say operational and the only update says Bitbucket has recovered. I'm having the same problem as well. I'll keep checking the status page.

  57. Igor Kozhukhov(dilos)

    not only you:

    ssh_exchange_identification: read: Connection reset by peer
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    
  58. absynthe minded

    Still getting issue, whether from office or at home.

    Have this in my .gitconfig (same problem with it commented out)

    [url "ssh://git@altssh.bitbucket.org:443/"] insteadOf = git@bitbucket.org: [url "ssh://git@altssh.bitbucket.org:443/"] insteadOf = https://absynthe_minded@bitbucket.org/

    This is in the ssh config

    Host bitbucket.org User git Hostname altssh.bitbucket.org Port 443

    Deleted and re-added my ssh key.

    Don't know what else to do on my own.

  59. Chris Lin

    started getting this as well

    edit: looks like in my case the servers were having issues that day. Kept trying and it eventually went through. Now it's working fine. (12/16/2015)

  60. cmrodriguez25

    Same problem here. Our CI server polls our repository for changes. Every now and then, it'll fail on polling with this error

    Source control operation failed: ssh_exchange_identification: Connection closed by remote host fatal: Could not read from remote repository.

    It'll work again usually on the next try, but by then our CI server has sent us emails and notifications that something went wrong, so this would be great if it could be fixed.

  61. shan stave

    Same problem, How can I do?

    root@stave-VirtualBox:/home/MT7688_SDK# git push -u origin master 
    Counting objects: 101611, done.
    Connection to bitbucket.org closed by remote host.
    fatal: The remote end hung up unexpectedly
    Delta compression using up to 2 threads.
    Compressing objects: 100% (98370/98370), done.
    error: pack-objects died of signal 13
    error: failed to push some refs to 'git@bitbucket.org:usmartcare/sc_gateway_v2.git'
    root@stave-VirtualBox:/home/MT7688_SDK# ssh -vT git@bitbucket.org
    OpenSSH_5.9p1 Debian-5ubuntu1.7, OpenSSL 1.0.1 14 Mar 2012
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 19: Applying options for *
    debug1: Connecting to bitbucket.org [104.192.143.1] port 22.
    debug1: Connection established.
    debug1: permanently_set_uid: 0/0
    debug1: identity file /root/.ssh/id_rsa type 1
    debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
    debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
    debug1: identity file /root/.ssh/id_rsa-cert type -1
    debug1: identity file /root/.ssh/id_dsa type -1
    debug1: identity file /root/.ssh/id_dsa-cert type -1
    debug1: identity file /root/.ssh/id_ecdsa type -1
    debug1: identity file /root/.ssh/id_ecdsa-cert type -1
    debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
    debug1: match: OpenSSH_5.3 pat OpenSSH*
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.7
    debug1: SSH2_MSG_KEXINIT sent
    debug1: SSH2_MSG_KEXINIT received
    debug1: kex: server->client aes128-ctr hmac-md5 none
    debug1: kex: client->server aes128-ctr hmac-md5 none
    debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
    debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
    debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
    debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
    debug1: Server host key: RSA 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40
    debug1: Host 'bitbucket.org' is known and matches the RSA host key.
    debug1: Found key in /root/.ssh/known_hosts:1
    debug1: ssh_rsa_verify: signature correct
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug1: SSH2_MSG_NEWKEYS received
    debug1: Roaming not allowed by server
    debug1: SSH2_MSG_SERVICE_REQUEST sent
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug1: Authentications that can continue: publickey
    debug1: Next authentication method: publickey
    debug1: Offering RSA public key: /root/.ssh/id_rsa
    debug1: Remote: Forced command: conq username:stave
    debug1: Remote: Port forwarding disabled.
    debug1: Remote: X11 forwarding disabled.
    debug1: Remote: Agent forwarding disabled.
    debug1: Remote: Pty allocation disabled.
    debug1: Server accepts key: pkalg ssh-rsa blen 279
    debug1: read PEM private key done: type RSA
    debug1: Remote: Forced command: conq username:stave
    debug1: Remote: Port forwarding disabled.
    debug1: Remote: X11 forwarding disabled.
    debug1: Remote: Agent forwarding disabled.
    debug1: Remote: Pty allocation disabled.
    debug1: Authentication succeeded (publickey).
    Authenticated to bitbucket.org ([104.192.143.1]:22).
    debug1: channel 0: new [client-session]
    debug1: Requesting no-more-sessions@openssh.com
    debug1: Entering interactive session.
    debug1: Sending environment.
    debug1: Sending env LANG = zh_CN.UTF-8
    logged in as stave.
    
    You can use git or hg to connect to Bitbucket. Shell access is disabled.
    debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
    debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
    debug1: channel 0: free: client-session, nchannels 1
    Transferred: sent 2752, received 2872 bytes, in 0.7 seconds
    Bytes per second: sent 3920.8, received 4091.8
    debug1: Exit status 0
    
  62. thdoan

    I just want to report that I'm getting this error as well (whereas before I wasn't). I'm able to do a git pull and git push on existing repos -- I'm only getting this error when I do a git push -u origin master for the initial commit on a new repo. Here is some debug info if it helps any:

    ssh -vvvT git@bitbucket.org                                                                                                                                                   
    OpenSSH_6.6.1, OpenSSL 1.0.1i 6 Aug 2014                                                                                                                                        
    debug2: ssh_connect: needpriv 0                                                                                                                                                 
    debug1: Connecting to bitbucket.org [104.192.143.2] port 22.                                                                                                                    
    debug1: Connection established.                                                                                                                                                 
    debug3: Incorrect RSA1 identifier                                                                                                                                               
    debug3: Could not load "/home/user1/.ssh/id_rsa" as a RSA1 public key                                                                                                        
    debug1: identity file /home/user1/.ssh/id_rsa type 1                                                                                                                         
    debug1: identity file /home/user1/.ssh/id_rsa-cert type -1                                                                                                                   
    debug1: identity file /home/user1/.ssh/id_dsa type -1                                                                                                                        
    debug1: identity file /home/user1/.ssh/id_dsa-cert type -1                                                                                                                   
    debug1: identity file /home/user1/.ssh/id_ecdsa type -1                                                                                                                      
    debug1: identity file /home/user1/.ssh/id_ecdsa-cert type -1                                                                                                                 
    debug1: identity file /home/user1/.ssh/id_ed25519 type -1                                                                                                                    
    debug1: identity file /home/user1/.ssh/id_ed25519-cert type -1                                                                                                               
    debug1: Enabling compatibility mode for protocol 2.0                                                                                                                            
    debug1: Local version string SSH-2.0-OpenSSH_6.6.1                                                                                                                              
    ssh_exchange_identification: read: Connection reset by peer
    

    Maybe I'm not reading the error message correctly, or it is incorrectly written, but why is it trying to load id_rsa as a public key when this file contains the private key?

    FYI, I'm using Cntlm to access the internet through my company proxy on a Windows 7 system, so my .gitconfig in Git Bash shell contains this:

    [http]                                                                                                                                                                          
            proxy = http://127.0.0.1:3128
    

    UPDATE: After trying all sorts of solutions all over the place and failing in every case, I finally found a workaround. The workaround is to not follow the official instructions when creating a new repo from scratch:

    mkdir /path/to/your/project
    cd /path/to/your/project
    git init
    git remote add origin git@bitbucket.org:username/project.git
    echo "username" >> contributors.txt
    git add contributors.txt
    git commit -m 'Initial commit with contributors'
    git push -u origin master
    

    Since the last command resulted in the "ssh_exchange_identification: read: Connection reset by peer" error, you have to do it this way instead:

    git clone https://username@bitbucket.org/username/project.git 
    cd /path/to/your/project
    echo "username" >> contributors.txt
    git add contributors.txt
    git commit -m 'Initial commit with contributors'
    git push
    

    Hope this helps others who found themselves in the same situation!

  63. Eron Lloyd

    I just created a basic repo with one file and was able to successfully push, but when I try to push a large new repo I get the following series of messages:

    Connection to bitbucket.org closed by remote host.
    fatal: The remote end hung up unexpectedly
    
    Delta compression using up to 8 threads.
    Compressing objects: 100% (24650/24650), done.
    error: pack-objects died of signal 13
    error: failed to push some refs to 'git@bitbucket.org:eronlloyd/<repo-name>.git'
    

    I haven't tried HTTPS yet, but because the test upload succeeded, I assume the issue is not related to a network timeout or some other block. This seems like a pretty major problem, why hasn't it been further acknowledged?

  64. Olga Bobrova

    Having this issue intermittently for the last 2 days, which totally screws up our CI/QA pipelines. Happens on a number of repos, regardless of the code volumes and commit frequencies.

    stderr: ssh_exchange_identification: Connection closed by remote host
    fatal: Could not read from remote repository.
    Please make sure you have the correct access rights
    and the repository exists.
    
  65. Log in to comment