20

When I try to access a non-existing route or make a mistake inside a Twig template, instead of getting the Symfony error page with debug information, I get redirected to a default nginx 502 Bad Gateway.

The log shows an interesting line:

013/07/17 16:11:41 [error] 16952#0: *187 upstream sent too big header while reading
response header from upstream, client: 127.0.0.1, server: ftwo.localhost, request: "GET    
/heasd HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "ftwo.localhost"

Any ideas?

Daniel Ribeiro
  • 10,156
  • 12
  • 47
  • 79

4 Answers4

38

Increase your buffer size in nginx configuration and restart nginx afterwards as suggested here.

proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;

Further increase the fastcgi buffer in the php section of your configuration ( location ~ .php$ )

fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;

Referenced answer to a question from a CodeIgniter user here.

Community
  • 1
  • 1
Nicolai Fröhlich
  • 51,330
  • 11
  • 126
  • 130
  • That actually solved the issue. Thanks a lot. One quick question: the error page now doesn't load the layout correctly? Could that be related? – Daniel Ribeiro Jul 17 '13 at 19:22
  • hm maybe a css/js issue ? what does your firebug/devtools netpanel say? – Nicolai Fröhlich Jul 17 '13 at 19:24
  • Just a note to say that reloading should suffice. (sudo service nginx reload) - Regarding the error pages not rendering, do you have problems elsewhere? Have you ran the assets install command? – Alex L Jul 17 '13 at 22:05
  • 1
    I would like to say that it's really important you set the proxy buffer in nginx.conf and also the fastcgi settings in your vhost file. – Sam Aug 08 '14 at 12:57
  • if you have this error your browser most likely is Chrome. FF shows error pages OK. at least for me. so I guess both answers here are right. accepted one fixes the problem by increasing server buffers, another by disabling extra debugging feature. – coviex Jun 23 '15 at 14:20
17

You may also try to disable ChromePHP at app/config/config_dev.yml

Just comment out these lines:

chromephp:
    type:   chromephp
    level:  info

This plugin generates a large header and forces nginx to response with 502 Bad Gateway.

More info at:

https://github.com/symfony/symfony/issues/8413

Enable Debug Component in Symfony 2.3

Community
  • 1
  • 1
Alexey Morozov
  • 1,259
  • 10
  • 12
1

I ran into a similar problem in 2023. I just install monolog

composer require symfony/monolog-bundle

After that, the 502 error disappeared, and debugging information began to be saved to /var/log in the project folder.

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
  • I also had nginx 502 errors when accessing the Symfony profiler and it fixed the problem. – COil Jul 21 '23 at 13:58
0

Also make sure you have a dev environment set up in .env, it was a problem in my case.

jnd
  • 51
  • 5