Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 randomly send 500 Internal Server Error on ajax requests

In my application Laravel 5 randomly send 500 Internal Server Error on ajax requests (for example, on ten 200 OK requests, one 500 Internal Server Error request). CSRF token is correctly set up:

$(function() {

    $.ajaxSetup({

        timeout: 3000,
        headers: {

            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
});

This is what Laravel says

enter image description here

How can I fix this or catch the place in code where problem located?

like image 475
Evgeniy Avatar asked Feb 18 '16 07:02

Evgeniy


People also ask

How do I fix 500 internal server error on laravel?

If you have a 500 Server Error, just rename the ". env. example" to ". env" and run: – php artisan key:generate – php artisan cache:clear – php artisan config:clear In my case, I pulled the project to Github repo to local machine.

What is 500 Internal Server Error Ajax?

The 500 Internal Server Error is a very general HTTP status code. It means something has gone wrong on the website and webserver is unable to specify what exactly, thus failing in fulfilling the request made by the client. Reload the web page. Clear your browser's cache.

How do I fix http error 500 in Linux?

Try to clear your browser cache. If the page that shows 500 error is cached, after the cache is cleared, the browser will request a new version of the page. Come back later. The webmaster may fix the server issue in the meantime.


1 Answers

Random Ajax request errors are mostly throwed by config issues. Check your laravel log in storage -> logs -> laravel.log for what is causing the issue.

You can cache your configs by running below artisan command. It will get rid of that random error popup.

php artisan config:cache
like image 76
shakee93 Avatar answered Oct 21 '22 17:10

shakee93