6 Ways to Fix Connection Reset by peer - howtouselinux (2024)

Connection Reset by peer means the remote side is terminating the session. This error is generated when the OS receives notification of TCP Reset (RST) from the remote peer.

Understanding Connection Reset by peer

Connection reset by peer means the TCP stream was abnormally closed from the other end. A TCP RST was received and the connection is now closed. This occurs when a packet is sent from our end of the connection but the other end does not recognize the connection; it will send back a packet with the RST bit set in order to forcibly close the connection.

“Connection reset by peer” is the TCP/IP equivalent of slamming the phone back on the hook. It’s more polite than merely not replying, leaving one hanging. But it’s not the FIN-ACK expected of the truly polite TCP/IP.

Understanding RST TCP Flag

RST is used to abort connections. It is very useful to troubleshoot a network connection problem.

RST (Reset the connection). Indicates that the connection is being aborted. For active connections, a node sends a TCP segment with the RST flag in response to a TCP segment received on the connection that is incorrect, causing the connection to fail.

The sending of an RST segment for an active connection forcibly terminates the connection, causing data stored in send and receive buffers or in transit to be lost. For TCP connections being established, a node sends an RST segment in response to a connection establishment request to deny the connection attempt. The sender will get Connection Reset by peer error.

Understanding TCP Flags SYN ACK RST FIN URG PSH

Check network connectivity

The “ping” command is a tool used to test the availability of a network resource. The “ping” command sends a series of packets to a network resource and then measures the amount of time it takes for the packets to return.

If you want to ping a remote server, you can use the following command: ping <remote server>

In this example, “<remote server>” is the IP address or hostname of the remote server that you want to ping.

Ping the remote host we were connected to. If it doesn’t respond, it might be offline or there might be a network problem along the way. If it does respond, this problem might have been a transient one (so we can reconnect now)

If you are experiencing packet loss when pinging a remote server, there are a few things that you can do to troubleshoot the issue.

The first thing that you can do is check the network interface on the remote server. To do this, use the “ifconfig” command. The output of the “ifconfig” command will show you the status of all network interfaces on the system. If there is a problem with one of the interfaces, it will be shown in the output.

You can also use the “ip route” command to check routing information. The output of the “ip route” command will show you a list of all routes on the system. If there is a problem with one of the routes, it will be shown in the output.

If you are still experiencing packet loss, you can try to use a different network interface. To do this, use the “ping” command with the “-i” option. For example, the following command will use the eth0 interface:

ping -i eth0 google.com

Check remote service port is open

A port is a logical entity which acts as a endpoint of communication associated with an application or process on an Linux operating system. We can use some Linux commands to check remote port status.

Commands like nc, curl can be used to check if remote ports are open or not. For example, the following command will check if port 80 is open on google.com:

nc -zv google.com 80

The output of the above command should look something like this: Connection to google.com port 80 [tcp/80] succeeded!

This means that the port is open and we can establish a connection to it.

6 ways to Check a remote port is open in Linux

Check application log on remote server

For example, if the error is related with SSH. we can debug this on the remote server from sshd logs. The log entries will be in one of the files in the /var/log directory. SSHD will be logging something every time it drops our session.

Oct 22 12:09:10 server internal-sftp[4929]: session closed for local user fred from [192.0.2.33]

Check related Linux kernel parameters

Kernel parameter is also related to Connection Reset by peer error. The keepalive concept is very simple: when we set up a TCP connection, we associate a set of timers. Some of these timers deal with the keepalive procedure. When the keepalive timer reaches zero, we send our peer a keepalive probe packet with no data in it and the ACK flag turned on.

we can do this because of the TCP/IP specifications, as a sort of duplicate ACK, and the remote endpoint will have no arguments, as TCP is a stream-oriented protocol. On the other hand, we will receive a reply from the remote host (which doesn’t need to support keepalive at all, just TCP/IP), with no data and the ACK set.

If we receive a reply to we keepalive probe, we can assert that the connection is still up and running without worrying about the user-level implementation. In fact, TCP permits us to handle a stream, not packets, and so a zero-length data packet is not dangerous for the user program.

we usually use tcp keepalive for two tasks:

  • Checking for dead peers
  • Preventing disconnection due to network inactivity

Check Application heartbeat configuration

Connection Reset by peer error is also related to the application. Certain networking tools (HAproxy, AWS ELB) and equipment (hardware load balancers) may terminate “idle” TCP connections when there is no activity on them for a certain period of time. Most of the time it is not desirable.

We will use rabbitmq as an example. When heartbeats are enabled on a connection, it results in periodic light network traffic. Therefore heartbeats have a side effect of guarding client connections that can go idle for periods of time against premature closure by proxies and load balancers.

With a heartbeat timeout of 30 seconds the connection will produce periodic network traffic roughly every 15 seconds. Activity in the 5 to 15 second range is enough to satisfy the defaults of most popular proxies and load balancers. Also see the section on low timeouts and false positives above.

Check OS metric on peer side

Connection Reset by peer can be triggered by a busy system. we can setup a monitoring for our Linux system to the metrics like CPU, memory, network etc. If the system is too busy, the network will be impacted by this.

For example, we can use the “top” command to check the CPU usage. The output of the “top” command will show us the list of processes sorted by CPU usage. If there is a process which is using a lot of CPU, we can investigate this further to see if it is causing the network issues.

We can also use the “netstat” command to check network statistics. The output of the “netstat” command will show us a list of active network connections. If there are too many connections established, this could be causing the network issues.

We can use these commands to troubleshoot network issues on a Linux system. By using these commands, we can narrow down the root cause of the issue and fix it.

Monitoring Linux System with Telegraf Influxdb Grafana

Troubleshoot Network Slow Problems In Linux

6 Ways to Fix Connection Reset by peer - howtouselinux (2024)

FAQs

How do I fix connection reset by peer error? ›

Try these steps to resolve the issue.
  1. Enter “tail -f /var/log/auth. log” to read the latest log entries.
  2. Once you find clues, type and execute “sudo nano /etc/ssh/sshd_config”.
  3. Edit the file so your system can accept more connections.
  4. Save the file.
  5. Restart the sshd service.
Aug 31, 2022

How to bypass Connection reset by peer? ›

Depending on what's causing the “ERR_CONNECTION_RESET” error in your case, there are five ways you can go about fixing it:
  1. Check your VPN.
  2. Reset your TCP/IP settings.
  3. Disable your antivirus and firewall.
  4. Clear your browser cache.
  5. Disable your proxy server.
Jun 12, 2023

How do I fix connection closed by peers? ›

How to Fix “Connection Reset By Peer” Error
  1. Check Logs.
  2. Check Internet Connectivity and Routing.
  3. Check for IP Ban.
  4. Check Firewall and Network Security Filters.
  5. Restart Services and Daemons.
  6. Edit Hosts File.
  7. Increase Timeout or Send Keepalive Packets.
  8. Check sshd_config File.
Jul 30, 2022

Why am I getting connection reset by peer? ›

An application gets a connection reset by peer error when it has an established TCP connection with a peer across the network, and that peer unexpectedly closes the connection on the far end.

How do I get rid of connection error? ›

How to get rid of the “connection is not private” error
  1. Reload the webpage. ...
  2. Check your Wi-Fi. ...
  3. Check the date and time on your device. ...
  4. Go incognito. ...
  5. Clear your cookies and cache. ...
  6. Check your antivirus software. ...
  7. Update your operating system. ...
  8. Proceed with caution.
Mar 10, 2023

Why can't i connect to VPN error? ›

To fix VPN connection problems, you can try restarting your VPN client, resetting your network settings, changing the VPN server location, checking for updates, and contacting your VPN provider's support team for assistance. If the issue persists, you may need to troubleshoot your network configuration or hardware.

How do I clear my connection reset? ›

How to Fix the ERR_CONNECTION_RESET Error
  1. Check If the Website Is Working. ...
  2. Disconnect from VPN. ...
  3. Reboot Your Network Device. ...
  4. Clear the Browser Cache. ...
  5. Deactivate Antivirus and Firewall. ...
  6. Disable Proxy Server Access. ...
  7. Reset TCP/IP Settings.

How do I restore my connection? ›

Complete list of fixes if your internet is not working
  1. Restart your equipment. ...
  2. Connect with an Ethernet cable. ...
  3. Check for an internet outage. ...
  4. Try using a different device. ...
  5. Check your wires and cables. ...
  6. Run your computer's internet troubleshooter. ...
  7. Reposition your router/gateway. ...
  8. Update everything.
Jun 29, 2023

How do I restore network connections? ›

After your PC restarts, any network adapters are reinstalled, and the settings for them are set to the defaults.
  1. Select Start > Settings > Network & internet > Advanced network settings > Network reset. Open Network & Internet Status settings.
  2. On the Network reset screen, select Reset now > Yes to confirm.

What is the difference between connection reset by peer and broken pipe? ›

Difference between connection reset by peer and broken pipe

Usually, you get the connection reset by peer when you read from the connection after the server sends the RST packet, and when you write to the connection after the RST instead, you get the broken pipe error.

What is peer connection? ›

Peer connections is the part of the WebRTC specifications that deals with connecting two applications on different computers to communicate using a peer-to-peer protocol. The communication between peers can be video, audio or arbitrary binary data (for clients supporting the RTCDataChannel API).

What is 104 Connection reset by peer? ›

Error code: ('104' - 'Connection reset by peer') is coming from the OS. This occurs when a packet is sent from your end of the connection but the other end does not recognize the connection; it will send back a packet with the RST bit set in order to forcibly close the connection.

What are the main reasons why you suddenly Cannot connect to the Internet? ›

There could be a number of factors that affect your internet connection. First, and most likely, is problems with your equipment. Restarting your modem/router should resolve the issue. Other reasons why your internet may keep going out include inadequate speeds, network congestion and inclement weather.

Why am I having trouble connecting to the Internet? ›

There could be any number of reasons you can't reach the internet: The firewall might be malfunctioning, the wireless signal might be blocked or too weak to use, the router might be experiencing issues, there could be IP address conflicts . . . the list goes on.

Why do I keep getting connection timeout? ›

The error connection timed out means that your browser could not establish a connection to the website's server in time. The problem may be your internet connection, website server, browser, or firewall settings. Generally, a browser needs about 30 seconds to reach a website's server.

What causes connection reset error? ›

One of the most common reasons for the “ERR_CONNECTION_RESET” error is that a proxy server has been defined in the internet settings and this is blocking the connection setup. This can be entered automatically by plugins or add-ons that you have added to your browser.

What is Windows Sockets Error #10054 Connection reset by peer? ›

Cause. Error 10054 occurs when the connection is reset by the peer application, usually due to an incorrect firewall configuration. Find more information about this error on Microsoft Development Center.

How do I fix connection errors and network connectivity? ›

Check for local connectivity issues: The first step in troubleshooting network errors is to check cables, devices, switches, and routers for proper functioning. Teams can also try restarting devices such as the modem, PC, and router to resolve simple network issues. Another issue could be LAN connectivity.

How do I fix Steam connection error? ›

How to Fix the "Could Not Connect to the Steam Network" Error on...
  1. Check Your Internet Connection. ...
  2. Check if Your Network Adapter Is Working. ...
  3. Restart Your PC. ...
  4. Run Steam as Admin. ...
  5. Check if Steam Is Down. ...
  6. Change Steam's Internet Protocol. ...
  7. Allow Steam Through the Windows Firewall. ...
  8. Update Steam.
Apr 27, 2023

References

Top Articles
Latest Posts
Article information

Author: Dean Jakubowski Ret

Last Updated:

Views: 6322

Rating: 5 / 5 (50 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Dean Jakubowski Ret

Birthday: 1996-05-10

Address: Apt. 425 4346 Santiago Islands, Shariside, AK 38830-1874

Phone: +96313309894162

Job: Legacy Sales Designer

Hobby: Baseball, Wood carving, Candle making, Jigsaw puzzles, Lacemaking, Parkour, Drawing

Introduction: My name is Dean Jakubowski Ret, I am a enthusiastic, friendly, homely, handsome, zealous, brainy, elegant person who loves writing and wants to share my knowledge and understanding with you.