Help Center/ Elastic Cloud Server/ Troubleshooting/ SSH Connection Issues/ Why Are Connections to a Linux ECS Using SSH or to Applications on the ECS Interrupted Occasionally?
Updated on 2023-03-30 GMT+08:00

Why Are Connections to a Linux ECS Using SSH or to Applications on the ECS Interrupted Occasionally?

Scenarios

This section applies to the scenario where the connection to a Linux ECS using SSH or the access to applications on the ECS is interrupted occasionally.

Constraints

  1. Modifying kernel parameters may render kernel unstable.
  2. To ensure the system running stability, restart the system at a proper time after modifying kernel parameters.

Possible Causes

  1. Check whether the net.ipv4.tcp_tw_recycle and net.ipv4.tcp_tw_reuse options are enabled to quickly reclaim and reuse TIME_WAIT connections:

    # sysctl -a |grep tcp_tw

    As shown in Figure 1, the options have been enabled.

    Figure 1 TIME_WAIT
  2. With these two options enabled, TIME_WAIT connections will be quickly reclaimed and reused, resulting in disconnections. By default, these two options are disabled.

    In the NAT environment, multiple terminals use the same public IP address, and one-to-one connection between the server and client cannot be implemented. If these two options are enabled, the server will reclaim and reuse TCP connections in the TIME_WAIT state, resulting in disconnections.

Procedure

  1. Disable the preceding two kernel parameters by adding the following content to the /etc/sysctl.conf file:
    net.ipv4.tcp_tw_recycle = 0
    net.ipv4.tcp_tw_reuse = 0
  2. Run the following command for the modification to take effect:
    # sysctl -p

    If kernel parameters are modified at runtime, the kernel may fail to load the parameters stably. You are advised to restart the system at a proper time.