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
How can I fix this or catch the place in code where problem located?
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With