Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

penguinfeet's avatar

502 Bad Gateway - nginx/1.6.1

Hi guys,

I have a Laravel 4 and a Laravel 5 project running on Homestead with Vagrant on my local machine. I was able to get them both working, but when I tried to add packages, I had to update php. I updated the php on my machine, and now when I type php -v in the shell, it is: PHP 5.6.9.

Now when I vagrant up and navigate to my projects, the Laravel 4 project is working fine, but for the Laravel 5 project, I am getting:

502 Bad Gateway nginx/1.6.1

This was working just fine before this upgrade/change.

Is there anything I need to change or do to fix this? Thank you!

0 likes
9 replies
PedroM's avatar

ssh to homestead and do sudo ls /etc/nginx/sites-enable/ then you should have several config files, open the one related to L5 and check the error_log location.

After that open the error_log and check the last lines of that file.

penguinfeet's avatar

So I got into sites-enabled on the path you showed. However, I'm not seeing several config files. I am seeing the proxy names of the two sites I have (thislaravel4site.dev and thislaravel5site.dev). I can't cd into either.

When I use the vi command to open thislaravel5site.dev, I get:

vi thislaravel5site.dev

server {
listen 80;
server_name thislaravel5site.dev;
root /home/vagrant/code/thislaravel5site/public;

index index.html index.htm index.php;

charset utf-8;

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt  { access_log off; log_not_found off; }

access_log off;
error_log  /var/log/nginx/thislaravel5site.dev-error.log error;

error_page 404 /index.php;

sendfile off;

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

location ~ /\.ht {
    deny all;
}

}

PedroM's avatar

So do sudo nano /var/log/nginx/thislaravel5site.dev-error.log or sudo tail -f /var/log/nginx/thislaravel5site.dev-error.log -n150 and check for the last lines.

you need to add sudo at beginning due filesystem permissions.

penguinfeet's avatar

2015/06/23 01:19:51 [error] 1692#0: *1 FastCGI sent in stderr: ") /home/vagrant$ PHP message: PHP 22. call_user_func_array:{/home/vagrant/code/thislaravel5site/vendor$ PHP message: PHP 23. Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->ha$ PHP message: PHP 24. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closur$ PHP message: PHP 25. call_user_func:{/home/vagrant/code/thislaravel5site/vendor/larav$ PHP message: PHP 26. Illuminate\Foundation\Http\Kernel->Illuminate\Foundation$ PHP message: PHP 27. Illuminate\Routing\Router->dispatch() /home/vagrant/code/$ PHP message: PHP 28. Illuminate\Routing\Router->dispatchToRoute() /home/vagran$ PHP message: PHP 29. Illuminate\Routing\Router->runRouteWithinStack() /home/va$ PHP message: PHP 30. Illuminate\Pipeline\Pipeline->then() /home/vagrant/code/v$ PHP message: PHP 31. call_user_func:{/home/vagrant/code/thislaravel5site/vendor/larav$ 2015/06/23 01:19:51 [error] 1692#0: *1 upstream sent too big header while readi$

PedroM's avatar
 upstream sent too big header while readi...

Try to clear you routes.php file (do a backup first) and then see if that error still show

penguinfeet's avatar

Hmm, so it seems that when I use the default "welcome" view that comes with a fresh install of Laravel 5 it works fine. But when I try to use my route (landing.blade.php), it gives me the bad gateway. My route is using HTML, but I added HTML in the composer.json and the providers/aliases arrays. Not sure why it wouldn't be working

PedroM's avatar

did you use the illuminate/html or laravelcollective/html (for 5.x you need to use laravelcollective/html as the other one was not supported)

njames180's avatar

an old post and probably not worthy of the bump but I resolved this by destroying my homestead box and recreating it

There was something out of sorts and all the other hints offered here and on Stack Overflow were not cutting the mustard.

homestead destroy 
homestead up 

did the trick

Please or to participate in this conversation.