angelorigo's avatar

Reactjs 16 Laravel 5.6 app intermitent responses

Hi,

I have intermitent responses from a Reactjs 16 app using Laravel 5.6 as API, sometimes one api gives a response sometimes a HTTP 500 is the response.

If i wait a little and try again i receive the response.

I was looking at the console and network tab to see any response, or the apache log.

There is a load balancer and two servers.

Is there other ways ?

0 likes
6 replies
LaryAI's avatar
Level 58

Intermittent HTTP 500 errors can be tricky to diagnose, but here are some steps you can take to identify and resolve the issue:

  1. Check Laravel Logs: Laravel logs detailed error messages in the storage/logs/laravel.log file. Check this file for any error messages that correspond to the times you receive the HTTP 500 errors. This can provide insight into what might be causing the issue.

    tail -f storage/logs/laravel.log
    
  2. Increase Error Reporting: Ensure that your Laravel application is set to display detailed error messages. In your .env file, set APP_DEBUG to true:

    APP_DEBUG=true
    

    This will provide more detailed error messages in the response, which can help you identify the problem.

  3. Check Server Logs: In addition to Laravel logs, check your web server logs (e.g., Apache or Nginx) for any errors that might not be captured by Laravel. These logs can sometimes provide additional context.

  4. Inspect Network Requests: Use the browser's developer tools to inspect the network requests. Look for patterns in the requests that fail, such as specific endpoints or payloads that might be causing the issue.

  5. Database Connection: Intermittent issues can sometimes be related to database connection problems. Ensure your database server is running smoothly and check for any connection errors in the logs.

  6. Resource Limits: Check if your server is hitting any resource limits, such as memory or CPU usage. High resource usage can cause intermittent failures.

  7. Code Review: Review the code for the endpoints that are failing. Look for any potential issues such as unhandled exceptions, infinite loops, or resource-intensive operations.

  8. Caching Issues: If you are using caching, ensure that it is configured correctly and not causing stale or incorrect data to be served.

  9. Third-Party Services: If your application relies on third-party services, ensure they are available and not causing the issue.

By following these steps, you should be able to gather more information about the cause of the intermittent HTTP 500 errors and work towards a solution. If the problem persists, consider providing more specific details about the errors you find in the logs for further assistance.

martinbean's avatar

@angelorigo If you’re getting 500 errors then by default they will be written to the Laravel error log (storage/logs/laravel.log); not the Apache log.

And please upgrade your Laravel application as soon as possible. Laravel 5.6 is has not received security updates for over half a decade now.

1 like
angelorigo's avatar

@martinbean there is a way to store a script on the public folder to read the laravel logs? because currently i have no access to the server

angelorigo's avatar

@martinbean I can publish files only via git and pipelines, unfortunally for the apache logs i have to open an issue to the server team.

martinbean's avatar

@angelorigo Then this is a business problem. You need to access your error logs to understand why your application is failing in production, and you employer needs to either give you access or surface them so that you can view them (i.e. by sending them to something like Sentry).

There’s nothing any one here can do to help. We’d be guessing just as much as you are right now.

1 like

Please or to participate in this conversation.