Why does Minecraft instantly disconnect me from LAN servers?

When I try playing on LAN, it just says "failed to connect to server", and in bold underneath it says "disconnected". What could be the possible causes of this, and how could I fix it?


Here are the possible causes:

  1. Your friends are banning you (if it's their server)

  2. A glitch, bug

  3. The connection is weak

  4. If it's your friend's server, and the friend that made the server leaves, that will instantly disconnect you from the server

  5. If it's a public server, there's always an AI watching players, so maybe the AI thought you're cheating even though you were not. (That happened to me)