When you see 'Failed to connect to server' or timeout errors, start by checking your internet connection stability. Open command prompt and type 'ping 8.8.8.8' to verify your connection works properly. If that's fine, restart your router and wait 30 seconds before turning it back on. Sometimes Windows Firewall blocks Java connections, so add an exception for Java Platform SE Binary in your firewall settings. Make sure you're using the correct server address without extra spaces or typos.
This happens when login servers can't verify your account. First, completely close the launcher through Task Manager to end all related processes. Clear launcher cache by deleting the 'launcher_profiles.json' file from your .minecraft folder. Log out and back into your Microsoft account. If error persists, reset your password on the official website and wait 10 minutes before attempting login again.
Outdated Java version causes most stability issues. Download latest Java 17 from official sources and uninstall older versions. Allocate more RAM to the game by editing JVM arguments in launcher settings, add '-Xmx4G' for 4GB allocation. Update graphics drivers directly from NVIDIA, AMD, or Intel websites. Disable mods one by one to identify problematic ones causing conflicts.
For direct connections, the host needs to configure port forwarding on router for port 25565. Check if you're both using same game version and edition. Realms subscriptions sometimes expire without notice, verify subscription status in account settings. Windows 10 edition requires all players to be Xbox Live friends with proper privacy settings allowing multiplayer.