502 Bad Gateway [Homestead] Hi all,
I'm trying to upload an excel file but after a couple of seconds I get a
502 Bad Gateway
Using the nginx/homestead local server.
Anyone have any idea's on this?
I do have the following in /etc/nginx/nginx.conf file
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 360;
types_hash_max_size 2048;
# server_tokens off;
server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
fastcgi_read_timeout 300;
fastcgi_buffers 8 32k;
fastcgi_buffer_size 64k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
client_max_body_size 25M;
}
How big is the file? Does it exceed the 25MB limit in Nginx or PHP?
Any errors in error log?
@bashy No the file is only 6.7MB but is likely to grow to about 10-12MB over time hence why I set to 25MB.
Which logs should I look in?
I've looked in both
php5-fpm.log
syslog
With nothing really standing out why this is. Clearly got to do with file size because if I try upload a different lower size document, it throws an error, as the fields don't match the table.
Have you updated php.ini to increase the maximum upload in bytes?
You can check with this
grep -E "upload_max_filesize|memory_limit|post_max_size" /etc/php5/fpm/php.ini
I normally set mine like this (125M = total POST size and 100M for files)
And of course, with any change
sudo service php5-fpm restart
Mine is
memory_limit = 512M
post_max_size = 125M
upload_max_filesize = 100M
It must be the file format, as I have changed the 6.7MB file to just 3 rows which is less then 1KB to test and still get a 502 Bad Gateway, whereas If i try to upload a word doc that then shows the Whoops! page
Okay, that's fine, has the service been restarted since that change?
Also, now is the time to check the error log for the particular site you're working on. Normally set in /etc/nginx/sites-available/somevhost
And any PHP error logs you have. May need to get the debug higher.
This returns:
server {
listen 80;
server_name bookstore.app;
root /home/vagrant/code/bookstore/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/bookstore.app-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;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
location ~ /\.ht {
deny all;
}
}
Check error_log /var/log/nginx/bookstore.app-error.log
I would also remove this part "error_page 404 /index.php;"
Error log shows:
2015/02/02 13:49:15 [error] 2942#0: *13 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.10.1, server: bookstore.app, request: "POST /admin/books/upload HTTP/1.1", upstream: "fas$
2015/02/02 13:51:16 [error] 2942#0: *13 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.10.1, server: bookstore.app, request: "POST /admin/books/upload HTTP/1.1", upstream: "fas$
sudo service nginx restart shows as fail too now
Have you looked into connection timeout settings?
Where would this be? and what should it be set to?
It must be file related this, because any other file uploads then I get a Whoops! page because it does match the fields within the table. But trying to upload any type of Excel file shows this 502 error.
Try upload empty excel file?
Still gives 502 error, already tried that.
I'm using the League\Csv package and it's nothing code related (i don't think) as this is some code I have used before.
You should of stated you'd already narrowed it down to the file type.... would of saved a lot of time.
Checked laravel.log?
Not sure what to suggest other than that.
Yes, these have resolved it, kinda, plus there was a few errors in the code too (sorry guys guess I won't copy/paste from another app again) but it's kinda working now.
Please sign in or create an account to participate in this conversation.