How to debug Laravel error 500 with no logs, no information
Asked Answered
H

12

41

I'm working on an existing Laravel application in order to develop new feature but after installing the app on my computer, I have an error 500 and no clue to resolve it.

In my app.php file I have set :

'env' => env('APP_ENV', 'local'),
'debug' => env('APP_DEBUG', true),

But still I have no information, no logs are generated in storage/logs . I have no idea of what could be the problem.

The previous developer was on windows and I'm working on Linux but I'm not sure this is revelant.

EDIT:

I also have those variable in my config/app.php

'log' => env('APP_LOG', 'daily'),
'log_level' => env('APP_LOG_LEVEL', 'debug'),
Hadsall answered 5/7, 2017 at 9:17 Comment(5)
Firstly, check your .env file. Then check log_level setting in config/app.phpImbibition
I have the same variables config in my .env : APP_ENV=local APP_DEBUG=true APP_LOG_LEVEL=debugHadsall
Have you checked permission ?Terenceterencio
How can you work with something that throws error after fresh isntallation ...Sestina
Cause you get money for itHadsall
M
26

Next to looking into your .env file, make sure permissions are correctly set (and good practice to create the storage/logs folder(s) manually - at least on windows that causes problems).

Mohur answered 5/7, 2017 at 9:21 Comment(2)
Nice done, I changed the permission and now I have some errors displaying. thanks. I'll validate your answer in 8 minuts ;)Hadsall
Could you (or someone else) please provide EXAMPLES in code of how/where to change those permissions? Those details would be the very useful part. ThanksAutopilot
M
17

I had simiar issue (saw error 500, but logs were present).

In order to be able to see errors directly on the page, I did following changes:

  1. enable debug mode: APP_DEBUG=true
  2. reload configuration: php artisan config:cache
Melville answered 20/12, 2020 at 9:17 Comment(0)
B
7

Some PHP exceptions are not possible to catch, so Laravel cant handle them. For example syntax errors, or maximum memory limit errors.

The following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the file where set_error_handler() is called.

Ref.: http://php.net/manual/en/function.set-error-handler.php

Beehive answered 19/8, 2018 at 15:53 Comment(0)
C
5

I tried to everything to find out the issue like enabling error reporting to report all like :

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

Also i tried to add my custom error handler as well but nothing worked for me. So finally i found the actual issue in php error log file in apache error logs folder (Applications/MAMP/logs as am using Mac).

Corbel answered 3/11, 2019 at 18:25 Comment(0)
S
3

Check your .htaccess file in your public folder! - This hot-fix is host dependent!!!

Change line from:

RewriteRule ^ index.php [L]

To:

RewriteRule ^ /index.php [L]
Skyward answered 24/8, 2020 at 21:2 Comment(0)
V
2

If you still getting same after trying all of the above solutions, same was here !!. Finally found solution using apache log.

Check apache log by

tail -f  /usr/local/apache/logs/error_log

If you can see something like '...index.php is writable by group'. then change permission

chmod 0644 public/index.php
Vidovik answered 6/3, 2021 at 6:22 Comment(0)
M
2

my problem was solved with, php artisan config:cache

Monteux answered 15/10, 2023 at 6:31 Comment(0)
D
1

I had this issue, and setting debug on told me the true issue.

For me, it was permission related, the running process didn't have permission to write to the log files, very hard to debug when the files you are relying on to tell you the problem don't arrow write!

Dirkdirks answered 23/3, 2021 at 11:27 Comment(1)
Same thing here, /storage/ didn't have write permission, so the app silently failed. Lost a few hours trying to find it.Disintegrate
T
0

I had the same issue. Apparently an error came through that was not an exception at all. This did get me pointed in the right direction though

in app/Exceptions/Handler.php:

    public function report($e)
    {
        dd($e);

        ...
    }


Theodicy answered 13/3, 2023 at 20:25 Comment(0)
A
0

There is a way to set right permissions in web server.
go to your app folder and execute these commands:
find . -type f -exec chmod 0644 {} \;
find . -type d -exec chmod 0755 {} \;

Alvar answered 23/11, 2023 at 14:7 Comment(0)
M
0

I use Laragon for my local development, and it allows me to easily switch between different PHP versions. I got this error, and it turned out I was just using a different version of PHP rather than the one my app required. I was using 7.4 and my app required 8. Weird why it wrote no error about it but knowing that helped me solve it.

Mardis answered 27/11, 2023 at 16:26 Comment(0)
P
0

I've had this problem when I used the abort function directly in my code, e.g. abort(500). Nothing gets logged and I only see the generic 500 page even in dev/debug mode.

The solution in my case was to add a call to the Laravel report function, like this:

report('The error message...');
abort(500);

This way, the error is logged before halting execution.

Part answered 24/7 at 15:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.