504 Timeout when accessing site after extended periods of time

Problem

It seems that I’m getting 504 Timeout errors if I try to access the site after a period of idle time (seems ike 5 minutes or so)**; i.e. if the site receives no traffic for an extended period, the visitor will receive a 504 timeout.

  • What’s your URL?
  • What version of Ghost are you using?
    • 2.23.3 2.25.1 (problem has persisted since installation)
  • What configuration?
    • Nginx hosted on AWS server, MySQL DB hosted in private colo.
  • What browser?
    • Firefox, Chome, IE (any)
  • What errors or information do you see in the console?
    • 504 Timeout
  • What steps could someone else take to reproduce the issue you’re having?
    • Access the site after 5 minutes of inactivity…

Workaround

I’ve found that if I send the request 2-3 times in rapid succession, the site loads fine; i.e. click in URL bar of browser (or press CTRL+L) and then hit enter 2-3 times.

Details & Data

The nginx error log reports an upstream timeout, but the upstream is http://127.0.0.1:2368 (the local host); reference config and log files below. I’m wondering if this is because the MySQL DB is hosted on a server elsewhere. However, I’m running the same setup for the WP version of my site (on a diff AWS server) and am not getting these timeouts, albeit using Apache2 in that environment.

/etc/nginx/sites-enabled/shnosh.io.conf

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name shnosh.io;
    root /var/www/ghost/system/nginx-root;

    ssl_certificate /etc/letsencrypt/live/shnosh.io/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/shnosh.io/privkey.pem;
    include /etc/nginx/snippets/ssl-params.conf;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2368;

    }

    location ~ /.well-known {
        allow all;
    }

    location ^~ /content/images/ {
        root /var/www/ghost;
    }

    client_max_body_size 50m;
}

/var/log/nginx/access.log

x.x.x.x - - [07/Jun/2019:21:46:51 -0700] "GET /freeztp-iosxe-upgrade/ HTTP/1.1" 504 192 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
y.y.y.y - - [07/Jun/2019:21:52:18 -0700] "GET / HTTP/2.0" 504 192 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0"
y.y.y.y - - [07/Jun/2019:21:52:19 -0700] "GET /favicon.ico HTTP/2.0" 302 34 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0"
y.y.y.y - - [07/Jun/2019:21:52:19 -0700] "GET /favicon.png HTTP/2.0" 200 22152 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0"

/var/log/nginx/error.log

/var/www/nginx/error.log
2019/06/07 21:52:18 [error] 1047#1047: *1003 upstream timed out (110: Connection timed out) while reading response header from upstream, client: y.y.y.y, server: shnosh.io, request: "GET / HTTP/2.0", upstream: "http://127.0.0.1:2368/", host: "shnosh.io"

I wonder if this post (that never got replies) is related… Ghost blogs fail to load - probably DB connection issues on AWS EC2 + RDS

Just to provide an update here; I have upgraded to v2.25.1, issue persists.

I’m not suggesting that anything should’ve been resolved by this upgrade, just stating that the upgrade took place.

Curious if anyone else has experienced this, any tips?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.