I enter ssh username@xxx.xxx.xxx.xxx and click enter, then enter password and got packet_write_wait: Connection to xxx.xxx.xxx.xxx port 22: Broken pipe

Sometimes I can login, but it then writes same thing after some time (also random time). I thought that it is something with my network, but I can login to another server without any issues.

What is the problem with the server and how to fix it? I also don't exclude the possibility that something is wrong with my network.

I'm on Ubuntu 18.

When ssh .... fails, I sometimes can login with ssh -o IPQoS=throughput ...


The scenario that you describe (first working, then suddenly breaking) is common if you exceed the MTU limits. It can happen if you connect through a VPN. To solve it, you have to lower the MTU, which is by default 1500.

This article describes how to change the MTU limits. Try reducing it to 1300. You can later try to increase it until it breaks again.

Note that if it is the MTU limit, the flakiness is expected. As long as packets are small enough, everything works, only if a request is big enough it will be dropped. That is why a login operation could succeed, although the connection would soon break once bigger packets are sent.

Related questions:

  • Why the problem is not consistent, i.e. from time to time? Can something be with server? – Andrew Fount Dec 30 '19 at 14:53
  • @AndrewFount If it caused by TCP segments exceeding the MTU limit, it means that some smaller packets will be delivered normally, while bigger packets will be dropped. That explains why it sometimes works but later breaks. For efficiency reasons, bigger packets are preferred (e.g. en.wikipedia.org/wiki/Nagle's_algorithm), so eventually you will end up hitting the limit. – Philipp Claßen Dec 30 '19 at 15:32
  • I mean that everything worked smoothly earlier and I didn't change anything. Suddenly it began to work as now. – Andrew Fount Dec 30 '19 at 16:48

Can't comment yet so.

First you should add verbose to get more information : ssh -v username@xxx.xxx.xxx.xxx

You can try those things that already worked from my experience :

  • Update openssh*
  • Delete /home/user/.ssh/known_hosts
  • Check if sshd daemon is enabled and restart it
  • 1. Doesn't help. 2. Doesn't help 3. Doesn't help. – Andrew Fount Dec 27 '19 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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