php - laravel rest api sometimes throws socket hang up or ECONNRESET error

one text

We have developed laravel based rest API and hosted it on AWS EC2. The app is working fine and the API also mostly work fine. However, we are facing a strange issue. Somtimes, the API starts returning socket hang up or ECONNRESET error. It seems like the issue is somehow tied to a specific API because once we start getting the error, all the devices connected to the same router/global IP are not able to get any response from the API server. All devices get the same error that socket hangup or ECONNRESET

At the same time, other devices connected from other IPs work fine and get normal response from the API server. A solution we have used is to restart the router. If its a mobile phone, then switching the network or taking the phone to flight mode and turning it back on also solves the issue (in our opinion, it changes the IP address and then it starts working again)

This does not always happen but once we start getting the error, we have to reset the device connected to the internet.

I have searched on google but have not found any solution for this. Can someone please give some direction on how to get this fixed?

Regards Syed

Source