Connection reset by peer

S.net 1 Reputation point
2025-01-04T20:44:35.4266667+00:00

Hi

I have Asp.net 6 (MVC) application running on Docker.

Sometimes I get error recv() failed (104: Connection reset by peer) while reading response header from upstream.

I have no idea, how I can fix it, if anyone know, please help

Developer technologies | ASP.NET | ASP.NET Core
{count} votes

1 answer

Sort by: Most helpful
  1. Raymond Huynh (WICLOUD CORPORATION) 3,955 Reputation points Microsoft External Staff Moderator
    2025-07-29T09:12:10.47+00:00

    Hi S.net,

    What you’re experiencing relates to the "connection reset by peer" error, which is a network-level issue indicating that the remote host closed the connection unexpectedly. This typically occurs when there is a disruption in the communication between your ASP.NET 6 (MVC) application running in Docker and the upstream server, possibly due to timeouts, resource limits, or network interruptions.

    Here’s how you can troubleshoot and resolve it:

    • Check your application and upstream server logs for any signs of errors, timeouts, or resource exhaustion around the time the issue occurs.
    • Review your Docker container resource allocations (CPU, memory, network) to ensure they are sufficient for your application's workload.
    • Inspect your network configuration, including firewalls and proxies, to rule out any interruptions or dropped connections.
    • If you are using a reverse proxy (like NGINX or Apache), verify its timeout and buffer settings to ensure they are appropriate for your application's response times.
    • Consider enabling more detailed logging or network tracing to help pinpoint where the connection is being closed.

    You can also find a detailed walkthrough in our documentation here:

    Connection reset by peer - Microsoft Q&A

    I hope this helps you get things back on track quickly! If you agree with my suggestion, feel free to interact with the system accordingly!


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.