Tips / Nginx

Upstream timed out (110: Connection timed out) while reading response header from upstream

Today I was investigating a weird nginx upstream timed out error I found on the server logs:

Upstream timed out (110: Connection timed out) while reading response header from upstream

This nginx timeout error was located in an nginx – apache proxy server, where nginx is serving all static content and apache all the dynamic.

Nginx Upstream Timed Out Scenarios

Investigating the error and after trying a few fixes, I found this error can happen in two scenarios:

1) Nginx as Proxy, like the one happened to me.

Try adding proxy_read_timeout option into your virtual host configuration, it should look like this:

proxy_read_timeout 150;

Place it inside your root location config:

location / {
        proxy_read_timeout 150;

2) Nginx as standalone server with php-fpm or another upstream application.

If this is your case, try adding fastcgi_read_timeout option:

fastcgi_read_timeout 150;

With your php-fpm configuration it should look like this:

location ~* .php$ {
    include         fastcgi_params;
    fastcgi_index   index.php;
    fastcgi_read_timeout 150;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;

On both cases, just restart nginx to apply the changes.

Note: some scripts may need to increase/decrease the “150” value I posted here.

Additional Resources

Popular search terms:

  • upstream request timeout
  • nginx upstream timed out
  • upstream timed out (110: Connection timed out) while reading response header from upstream
  • upstream timed out

Esteban Borges

Linux Geek, Webperf Addict, Nginx Fan. CTO @Infranetworking

  • David

    thank you, it has fixed my problem.

  • Vik

    Backround of the issue:
    When I try to upload a file over http or https, it seems to go okay and after 60 seconds it dies with a message,
    Timeout sending the file:
    perhaps your browser does not send files correctly,
    your session has expired,
    or there was a server error.
    Please try again.


    What backend uploader we are using?
    gwt file uploader

    Centos 6.5


    What did i try so far in last 48-72 hours ? Why are we certain its nginx configuration issue?
    1. httpd (Apache/2.4.4), another web server works perfect (just for upload) but we dont want to do it for obvious benefits of nginx
    2. if we remove web server altogether, upload works flawlessly.
    3. played with nearly all timeouts on nginx without luck
    4. tried nginx v1.6 (and 1.5x too) without luck
    5. multiple browsers same result – firefox/chrome windows, firefox/chrome linux
    6. tcpdump and wireshark show data movements for first 60 seconds.
    7. nginx http log – *381 client timed out (110: Connection timed out) while waiting for request, client: IPADD, server:
    8. nginx https log – *480 client prematurely closed connection, client: IPADDR, server: SERVERNAME, request: “POST /servlet.gupld HTTP/1
    .1”, host: “SERVERNAME”, referrer: “https://SITE/desktopmain.htm”

    nginx version: nginx/1.6.0
    built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)
    TLS SNI support enabled
    configure arguments: –prefix=/apps/nginx –user=nginx –group=nginx –with-file-aio –with-ipv6 –with-http_ssl_module –with-http_realip_module –with-http_addition_module –with-http_xslt_module –with-http_image_filter_module –with-http_geoip_module –with-http_sub_module –with-http_dav_module –with-http_flv_module –with-http_mp4_module –with-http_gzip_static_module –with-http_random_index_module –with-http_secure_link_module –with-http_degradation_module –with-openssl=/apps/nginx/openssl –with-pcre=/apps/nginx/pcre –with-zlib=/apps/nginx/zlib –with-http_stub_status_module –with-http_perl_module –with-debug –pid-path=/apps/nginx/ –error-log-path=/apps/nginx/logs/error.log –http-log-path=/apps/nginx/logs/access.log –http-client-body-temp-path=/apps/nginx/tmp/client_body –http-proxy-temp-path=/apps/nginx/tmp/proxy –http-fastcgi-temp-path=/apps/nginx/tmp/fastcgi –lock-path=/apps/nginx/lock/subsys/nginx

    ————————-nginx.conf, START————————-

    worker_processes 1;

    worker_rlimit_nofile 200000;

    events {
    worker_connections 1024;

    http {
    include mime.types;
    default_type application/octet-stream;

    log_format main ‘$remote_addr – $remote_user [$time_local] “$request” ‘
    ‘$status $body_bytes_sent “$http_referer” ‘
    ‘”$http_user_agent” “$http_x_forwarded_for”‘;
    access_log logs/access.log main;
    error_log logs/error.log;

    sendfile on;
    send_timeout 10;
    keepalive_timeout 30;
    keepalive_requests 100000;
    reset_timedout_connection on;
    client_body_timeout 10;
    client_header_timeout 10;
    gzip on;
    gzip_min_length 10240;
    gzip_proxied expired no-cache no-store private auth;
    gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
    gzip_disable “MSIE [1-6].”;

    upstream appcluster {
    # least_conn;
    server localhost:8080 fail_timeout=20s;
    keepalive 8;

    server {
    listen 80;
    if ($ssl_protocol = “”) {
    rewrite ^ https://$server_name$request_uri? permanent;

    server {
    listen 443 default ssl;
    root /apps/nginx/html;
    ssl on;
    ssl_certificate /apps/nginx/conf/mycerts/site.crt;
    ssl_certificate_key /apps/nginx/conf/mycerts/site.key;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root html;

    location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
    proxy_pass https://appcluster;
    # proxy_pass https://localhost:8080;

    ————————-nginx.conf, END————————-

    Thanks in advance for your suggestions/comments!

  • Rashid Iqbal


    We have one java applet application with dynamic contents. I configure the nginx as reverse proxy to forward the logs to java application server.

    but I am getting “Upstream timed out (110: Connection timed out) while reading response header from upstream”

    how can I solve that

  • fela

    hi,all,I have the same question, we all know the performance of the nginx is rather nice, when I use the nginx as the backend, the upstream timed out still happened, I set the proxy_connect_timeout is 400ms, I don’t want to change because of some reasons. I can not understand why it connect time out and why the backend can not response timely???

  • Chris Dill

    Thanks for this! I had a VPS on BlueHost running on straight Apache with this error, which happened any time I tried to upload a PNG graphic file (didn’t matter the size). I moved over to private dedicated hosting which is running on a NGINX proxy, and the problem continued. I implemented this fix and it seems to have resolved the problem- my last png file uploaded normally.

  • Claus Guttesen

    I had an issue where I couldn’t upload more than 21 files at a time via the nginx-ssl-proxy to an apache-server. Turned out I had prematurely optimized nginx and had configured ssl with spdy. When I removed spdy all is fine.


  • At times I’m seeing connection refused for upstream & the health checks are not getting worked perfectly as the nginx is till sending traffic

  • Dmitry Averin

    Thank you, Esteban! Your website is very helpful to me.

  • Doesn’t increasing read time out to 150 have negative impact on performance of nginx like increase of queue length etc.

    • Not necessarily, it depends on your app and how much time it takes to be processed by Nginx

  • FilipDev

    Thank you! Searched a long time to resolve my issue, and you had the right answer.

  • Does 0 make it unlimited?

  • gansbrest

    While you can “hide” the error using fastcgi_read_timeout and proxy_read_tiemout in most cases there is a problem with upstreams that need to be addressed:

  • Edward Karlsson

    Thanks! This resolved an issue that has been bugging me for several days! Thanks for taking the time to post!