2

I have an application that is trying to make ajax requests from a Javascript application to retrieve xml files from an nginx server. Normally everything is fine but I often see errors in the nginx log (and get errors from my applications error reporting) that nginx expriences a timeout during the get:

2015/11/16 21:15:21 [error] 1208#0: *4894044 upstream timed out (110: Connection timed out) while connecting to upstream, client: 209.95.138.54, server: www.servername.com, request: "GET /Shape%20Textures/Metal/Born%20to%20Shine.jpg?agentView=436314 HTTP/1.1", upstream: "http://127.0.0.1:3000/AQO/Shape%20Textures/Metal/Born%20to%20Shine.jpg?agentView=436314", host: "www.servername.com.com", referrer: "https://www.servername.com.com/?nid=39956&mode=edit"

We also sometimes get this similar error:

2015/11/17 19:03:16 [error] 1002#0: *54042 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 137.164.121.52, server: www.servername.com, request: "POST /projects/?q=node/36375/update_project_time_and_stats HTTP/1.1", upstream: "http://127.0.0.1:3000/projects/?q=node/36375/update_project_time_and_stats", host: "www.servername.com", referrer: "https://www.servername.com/AQO/?nid=36375&mode=edit"

I have seem similar posts with similar timeouts but all of those posts seemed reproducible. This issue never happens to me but running on the live server I will see 5-30 of these timeouts a day.

Here is my nginx config:

client_max_body_size 50M;

server {
    server_name servername.com;
    return 301 $scheme://www.servername.com$request_uri;
}

server {
    listen 80;
    listen 443 ssl;
    fastcgi_read_timeout 120;
    ssl_certificate /path/to/ssl/star_servername_com.pem;
    ssl_certificate_key /path/to/ssl/star_servername_com.key;

    # Redirect all non-SSL traffic to SSL.
    if ($ssl_protocol = "") {
      rewrite ^ https://$host$request_uri? permanent;
    }

    root /usr/share/nginx/html;
    index index.html index.htm;

    # Make site accessible from http://localhost/
    server_name www.servername.com;

    location / {
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_pass http://127.0.0.1:3000;
            proxy_read_timeout 120s;
    }
}

Since I can't reproduce it I wonder how might I be able to track down this issue?

4
  • Check your upstream server log? Commented Nov 18, 2015 at 1:35
  • I've never heard of the upstream server log and didn't find much with a Google search, is this something that you can enable through nginx? Commented Nov 18, 2015 at 1:52
  • I'm referring to the 127.0.0.1:3000 server log. Commented Nov 18, 2015 at 1:53
  • There is a node.js server running on port 3000. Nothing in there related to the timeouts. Commented Nov 18, 2015 at 3:03

2 Answers 2

1

upstream timed out (110: Connection timed out) while connecting to upstream

means that your upstream server didn't accept connection in time

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

means that your upstream server didn't respond with answer in time

So check your upstream server at 127.0.0.1:3000. It may have setup with small number of incoming connections or some sort of DDoS protection or really heavy loaded at the moment or something else.

Sign up to request clarification or add additional context in comments.

2 Comments

There is a node.js server running on port 3000 but as far as I can tell node.js doesn't put any limits on incoming connections. Ubuntu has a default incoming connections of 1024 shown by ulimit -n
if your Node.js server is heavy loaded or run really long tasks you can try to encrease nginx's proxy_connect_timeout and proxy_read_timeout. Their default values are 60 seconds and you may need to increase this settings
1

I would like to refer to this answer which shows how to optimize your settings.

Although not the best solution, but very dependent on what you'd like to achieve, you could simply increase proxy_read_timeout to for example 300.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.