How to debug 500 Error in Symfony 2 and above
Asked Answered
H

4

25

I am struggling with Symfony 2 error reporting because I can't find out what really is happing when a 500 Error is triggered.

I have XDebug correctly installed, but it seems like Symfony rules everything.

The custom pages just says:

Oops! An Error Occurred

The server returned a "500 Internal Server Error".

Something is broken. Please e-mail us at [email] and let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.

That's pretty much funny! Something is broken, but, the fact is that I need to fix my code, but can't know what or where it is the problem! And sure, If I send an email for the Symfony team will they be able to solve my problem once I not even know what to say them?

Some clue on what I am missing here?

Hankering answered 2/9, 2013 at 15:56 Comment(3)
In your url you should have hostname/web/app_dev.php/.... , in order to see the explicit error messageKoral
Possible duplicate of symfony assetic gives 500 error when requesting filesPreindicate
Sometimes it happens after moving from dev to prod. In those cases, make sure to do a bin/console cache:cl and rm -rf var/cache/*. In my case there was no log errors anywhere, but this solved the problem.Saintly
R
51

For Symfony 2 and below,

First, look at the logs in app/logs depending on your environment — dev.log for development, prod.log for production, etc.

If the code crashes before Symfony has a chance to run, check the logs of your web server — e.g. nginx.

Ratiocinate answered 2/9, 2013 at 17:17 Comment(1)
Also, make sure that the app/logs folder is writeable and has the right owner.Newsstand
T
2

If you have a symfony flex project, it is also possible that you forgot to install monolog ;) Run:

composer req log
Trixi answered 29/12, 2017 at 13:11 Comment(0)
B
1

For Symfony versions 3.x, 4.x, 5.x, 6.x and above,

The logs will be found depending on the environment

  • For dev env - var/logs/dev.log
  • For prod env- var/logs/prod.log

Also, as the accepted answer suggests, you might have to check the server logs if your app crashes before even reaching Symfony.

Usual location for server logs is listed below -

  • For apache server - ls /var/log/apache2
  • For Nginx server - ls /var/log/nginx
Blubberhead answered 29/3, 2022 at 8:56 Comment(0)
P
0
sudo chmod -R o+w var/cache/

from inside the project's folder, solved the problem for me, at least this time :)

There were no errors in Symfony's or web server's logs.

What caused the problem

It turned out that the problem was caused by me previously removing the cache folder, and regenerating the cache, i.e.

rm -fr var/cache/
./bin/console cache:clear

After that, var/cache became drwxr-xr-x.

Pathfinder answered 30/3, 2022 at 7:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.