Ubuntu clone with git ‘hung up unexpectedly’ problem solved

Ubuntu clone with git ‘hung up unexpectedly’ problem solved
Photo by John Moeses Bauan / Unsplash

I was experiencing a very strange issue where I was unable to clone or pull from some repositories on Github. It would only be for some (larger) repositories, and I could sometimes pull them fine using the https:// protocol, but not using the git:// or ssh:// protocols.

What I would see in the output, is that git would contact the remote server, and just hang for several minutes, before giving, rather cryptically, the 'remote end hung up unexpectedly' message. Doing a ‘git pull’ on an existing repo would give me 'error: RPC failed; result=56, HTTP code = 0'

I could clone the same repos fine on my OSX workstation, and on other Ubuntu linux boxes, so something weird was definitely up.

I suspected it was some sort of low-level networking issue, and after trying many things, came upon the solution:

My MTU size was set to ‘automatic’, and had defaulted to 1500. Apparently this can sometimes cause TCP connections to hang in some network environments!

I set my MTU size to 1492 on my network adapter (Under Edit Connections… in the UI) and everything started to work as expected! Huzzah.