How can I solve the issue of “ remote side unexpectedly closed network connection” while trying to connect with a remote network?

193    Asked by CharlesParr in AWS , Asked on Jan 18, 2024

 When I was trying to connect with a particular remote server for one of the important tasks I encountered a scenario where I was getting an error message which was showing “ remote side unexpectedly closed network”. What should be an appropriate approach for me to resolve this particular issue? 

In the context of AWS, during the process of establishing a connection with a remote server if you are getting the error message “ remote side unexpectedly closed network connection” then here are the solutions given to troubleshoot this particular issue:-

Check the network connection

Verify that the network connection between your local machine and the remote server should be good. You can use tools like ‘ping’ for the identification of the issues related to the network.

Review server logs

You should verify the logs on the remote server for any error message which is related to the problem of network.

SSH server configuration

Ensure also that the SSH server is actively running on the remote side.

Firewall settings

Ensure that your firewall settings are not blocking the path or function of the SSH connection.

SSH client Configuration

Ensure that the client is using the appropriate method of authentication or not.

Server Resource utilisation

Verify that the resource utilisation on the remote server is not overloading or not. It should be not overloaded.

Update software

Ensure that you have the updated local and remote system.

Checking SSH key permission

Also try to ensure that the SSH private and public keys on the client side have the appropriate permissions.

Temporary network issues

If the network issues are temporary then try to connect after some time.

SSH connection options

You can adjust the SSH connection options. You can adjust by increasing the “ServerAliveInterval” to prevent the connection from being closed.

Here is the command given of how you can increase “ServerAliveInterval”:-

  Echo “ServerAliveInterval 60” >> ~/.ssh/config

This command appends the line ServerAliveInterval 60 to the ~/.ssh/config file. Adjust the interval value (here set to 60 seconds) based on your requirements

Your Answer


Parent Categories