Welcome! Log In Create A New Profile

Advanced

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

February 22, 2018 08:12AM
Hey everybody,

I experienced this issue using nginx version 1.10.x and 1.13.x


given a basic configuration like:

upstream myupstream {
server internal01:80;
server internal02:80 backup;
}

server {
listen 81 default_server;
listen [::]:81 default_server;

server_name _;

location / {
proxy_pass http://myupstream;
post_action @hot_standby;
}

location @hot_standby {
proxy_pass http://internal02:80;
}
}


I receive the "sendfile() failed (9: Bad file descriptor) while sending request to upstream" error when trying to POST data exceeding 16k body size. The error does not occur for requests with less than 16k data.
As far as I can understand the code / documentation, 16k by default (for 64bit systems) is the limit when nginx starts to use a tempfile instead of a memory buffer. http://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_buffer_size

This makes me believe that the problem only kicks in when nginx decides to use a tempfile instead of an inmemory buffer.


For my setup I was able to fix the issue by an alignment between client_body_buffer_size and client_max_body_size.

client_max_body_size 1m;
client_body_buffer_size 1m;


Hope this can help anybody.

Best
Benny
Subject Author Posted

sendfile() failed (9: Bad file descriptor) while sending request to upstream

john2do August 12, 2010 07:00AM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

Maxim Dounin August 12, 2010 08:24AM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

papajoe February 22, 2018 08:12AM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

Maxim Dounin February 22, 2018 12:08PM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

papajoe February 23, 2018 02:36PM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

john2do August 12, 2010 11:09PM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

john2do August 12, 2010 11:37PM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

john2do August 13, 2010 02:07AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 265
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready