
Does this error occur while you are connecting to your instance? If yes, then don’t worry, we will help you resolve it. Read this blog to know how you can resolve this error like a pro!
If you are connecting to your instance with Putty and receive the error “Server unexpectedly closed network connection”, then you can resolve it with two solutions and we are going to discuss these two solutions in this blog.
This is the error –

If this error message appears, there is possibility that
- You are not using the correct username when connecting to your instance
- You are not using the correct key when connecting to your instance”
- PuTTy options –> Connection problem
- You have accidentally applied Chmod 777 on the root folder
Since it might be an SSH issue, we have found the following link on troubleshooting problems which will help you connect to your instance: https://repost.aws/knowledge-center/ec2-linux-ssh-troubleshooting
You can try connecting again by entering your correct username because it is possible that you entered the wrong username before. Try this and see if it works.
Just like this, try connecting again by entering the correct key and see if it works.
If both of these don’t work, then you need to try these two solutions for connecting to your instance. Let’s see what these solutions are and how they work.
Table of Contents
SOLUTIONS 1
Here is the first solution for you that can help you resolve this error
Go to PuTTy options –> Connection
- Change the default value for “Seconds between keepalives(0 to turn off)”: from 0 to 600 (10 minutes) — in my case taking 30 seconds That means it sends a “ping” every 30 seconds to prevent the connection from timing out
- Check the “Enable TCP_keepalives (SO_KEEPALIVE option)” check box.
- Finally, save the setting for the session
Youtube Video – https://www.youtube.com/watch?v=cFP4AsxvwNQ&feature=youtu.be

SOLUTIONS 2
Here is the 2nd solution to resolve this error
It might be possible that you have put Chmod 777 to remove chmod 777 permission on the root folder.
If you just want to remove the write permission to others, the command is given below and it has to be done from the root folder: chmod o-w /
This will remove others’ permission from / (root folder)
* o means others. * w means write permissions.
So o-w means remove written permission from others. You can also read online to know how this exactly works and how the permissions can be updated for Linux.
Here are some of the references to Forums and documents:
— https://forums.aws.amazon.com/thread.jspa?threadID=60938 — https://forums.aws.amazon.com/thread.jspa?threadID=212950 — https://forums.aws.amazon.com/thread.jspa?threadID=56946
Whenever the such error appears, these two solutions can be helpful for you to resolve the error and you will able to connect to your instance easily. So, if you come across this error, follow these two solutions and say goodbye to the error in a few minutes.
We hope you resolve this error successfully with the help of this blog. (Metizsoft Solutions Private Limited)
Read More:
How to disable TLS 1.0 in the windows server?
AboutManthan Bhavsar
Related Posts
Understanding Different Types of IT Service Business Models
Identifying and choosing a suitable business model is daunting in a rapidly evolving IT service landscape. However, opting...
Unveiling Metizsoft’s Best Moments at The AWS Community Day, Ahmedabad 2024!
AWS Community Days are global events organized by the AWS community to promote cloud education. They involve technical...