23

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?

Niket Pathak
  • 6,323
  • 1
  • 39
  • 51
Gilberto Albino
  • 2,572
  • 8
  • 38
  • 50
  • 1
    In your url you should have `hostname/web/app_dev.php/....` , in order to see the explicit error message – zizoujab Sep 02 '13 at 17:43
  • Possible duplicate of [symfony assetic gives 500 error when requesting files](http://stackoverflow.com/questions/17636025/symfony-assetic-gives-500-error-when-requesting-files) – Mohammad Fareed Jun 28 '16 at 09:02
  • 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. – Ricardo Martins Nov 20 '21 at 03:39

4 Answers4

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.

Niket Pathak
  • 6,323
  • 1
  • 39
  • 51
Elnur Abdurrakhimov
  • 44,533
  • 10
  • 148
  • 133
2

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

composer req log
onok
  • 271
  • 1
  • 2
  • 5
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
Niket Pathak
  • 6,323
  • 1
  • 39
  • 51
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.

iloo
  • 926
  • 12
  • 26