drupal-with-nginx icon indicating copy to clipboard operation
drupal-with-nginx copied to clipboard

502 Bad Gateway with unexpected fastcgi record

Open filmost opened this issue 10 years ago • 10 comments

I have been testing this configuration locally and I keep getting these 502 Bad Gateway. They appear to happen when there is a redirect to a URL with arguments. An example would be after user login the page redirects to "/node?q=/" which throws a 502 Bad Gate error. If I refresh the page, then it loads as it should.

Checking error logs reveals the following error message:

2014/02/25 15:34:09 [error] 18430#0: *12 upstream sent unexpected FastCGI record: 3 while reading response header from upstream, client: 127.0.0.1, server: d82.localhost, request: "GET /node?q=/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "d82.localhost", referrer: "http://d82.localhost/"

This happens with unix sockets as well.

If I revert to my old configuration then login redirects to a clean URL (/node) instead and there is no 502 error.

Can you shed some light on what area of config I should be looking at? I am using nginx 1.2.6

filmost avatar Feb 25 '14 06:02 filmost

I notice using your configs, my redirected URLS always end up like this "/admin/content?q=/admin/content" which where I get the 502s. What controls the URL structure?

filmost avatar Feb 27 '14 08:02 filmost

well I can confirm, something change in the past 3 or 4 month, because with new projects I'm getting this 502 bad gateways after posts for example. Things where getting better after commenting: include nginx_status_vhost.conf;

Some tip of what can be?

sebas5384 avatar Apr 17 '14 02:04 sebas5384

@perusio I made(not finished) a juju charm, using your configurations, but! the 502 thing is still happening, and I really don't know why :( Here's the code https://github.com/sebas5384/charm-drupal/blob/bash/hooks/install

Some help? please :)

sebas5384 avatar May 26 '14 18:05 sebas5384

@sebas5384 Did you ever resolve this? I'm getting it locally with a Drupal 8.0b1 install.

njt1982 avatar Oct 01 '14 12:10 njt1982

It also happened to one of my project. Error 502 often occurs at the beginning, but when in reloading, back to normal. and this happens at random but constant. I also tried various combinations of settings does not work, I finally found the discussion here: https://groups.drupal.org/node/283558#comment-1016818 and commenting out keepalive 5 in upstream_phpcgi_unix.conf fixed this 502 issue for me.

wismoyo avatar Feb 26 '15 04:02 wismoyo

I have turn on tcp and now all is ok!

ttenz avatar Jul 19 '15 17:07 ttenz

keepalive fixes this for me too

njt1982 avatar Oct 09 '15 14:10 njt1982

I commented the keepalive on Drupal 8 project and it solved my issues related to 502. Everyone know the origin of this issue? Should we implement it for Drupal 8 configurations? I think just comment it is not a good solution...

guiajlopes avatar Nov 24 '15 23:11 guiajlopes

I have no clue. It requires some delving into it. Let's see if by next month I can setup drupal 8 and try to debug the issue.

perusio avatar Nov 25 '15 00:11 perusio

I'm still seeing this for new installs as well, the keepalive workaround still works.

mustanggb avatar Nov 26 '15 13:11 mustanggb