How to fix 'packet_write_wait: Connection to ... Broken pipe' error in Git

Viewed 8577

How can I fix the problem when I git push files to my remote repositories and it throw the error 'packet_write_wait: Connection to 13.250.177.223 port 22: Broken pipe'?Before git push, I had clone the project from the remote and git add, git commit successfully.

I haved tried git pull, git config http.postBuffer 52428800, but it doesn't work.

HP@EverChan MINGW32 /d/ChromeDownload/jiaoben5049/meetingDemo (master)
$ git pull
packet_write_wait: Connection to 52.74.223.119 port 22: Broken pipe
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
HP@EverChan MINGW32 /d/ChromeDownload/jiaoben5049/meetingDemo (master)
$ git config http.postBuffer 52428800
HP@EverChan MINGW32 /d/ChromeDownload/jiaoben5049/meetingDemo (master)
$ git push -u origin master
Counting objects: 46, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (46/46), done.
packet_write_wait: Connection to 13.250.177.223 port 22: Broken pipe
Writing foabjecttals:   8:% The  (4/4remote end hung up u6nex)pectedly
fatal: sha1 file '<stdout>' write error: Broken pipe
fatal: The remote end hung up unexpectedly
HP@EverChan MINGW32 /d/ChromeDownload/jiaoben5049/meetingDemo (master)
$ git push -u origin master
packet_write_wait: Connection to 13.250.177.223 port 22: Broken pipe
fatal: Could not read from remote repository.

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


3 Answers

What worked for me in the context of pushing my repo to github was adding IPQoS=throughput to my config file in ~/.ssh/config. The other steps for making sure SSH is are set up correctly, added to your Github account etc. are detailed here

Make sure your SSH URL for your remote origin does work:

ssh -T yourServer

Its IP address should not change.

See if the issue persists with the latest Git for Windows (PortableGit-2.20.1-64-bit.7z.exe), uncompress in C:\Git, and set a simplified PATH in a CMD session.

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%

Note: you can see arror messages with packet_write() failing.
Before, we gave an extra error message unnecessarily, which has been corrected with Git 2.32 (Q2 2021).

See commit 332ec96 (15 Apr 2021) by Matheus Tavares (matheustavares).
(Merged by Junio C Hamano -- gitster -- in commit 279a2e6, 30 Apr 2021)

pkt-line: do not report packet write errors twice

Signed-off-by: Matheus Tavares

On write() errors, packet_write() dies with the same error message that is already printed by its callee, packet_write_gently().
This produces an unnecessarily verbose and repetitive output:

error: packet write failed 
fatal: packet write failed: <strerror() message>  

In addition to that, packet_write_gently() does not always fulfill its caller expectation that errno will be properly set before a non-zero return.
In particular, that is not the case for a "data exceeds max packet size" error.
So, in this case, packet_write() will call die_errno() and print an strerror(errno) message that might be totally unrelated to the actual error.

Fix both those issues by turning packet_write() and packet_write_gently() into wrappers to a common lower level function that doesn't print the error message, but instead returns it on a buffer for the caller to die() or error() as appropriate.

This helped me alot, try out this:

git config --global --add safe.directory /var/www/html/Your_Project_Folder
Related