Nginx+PHP-FPM intermittent blank page

  • Posted on October 29, 2014
  • I3litzAsked by Ritchie

Hello, I been suffering with this problem for a few days on a new server, some times like 1 or 2 times a day the Home page of wordpress shows a blank page with a 500 error (only visible from Chrome console) and it stays like that for a couple of minutes where not even a hard refresh (ctrl+shift+R) seems to work, but eventually it comes back to normal. the only way to quickly fix it is to stop nginx, delete nginx cache at /var/cache/nginx/ and start nginx again.

The server is a CentOS 6.5, nginx/1.6.2, php 5.3.3 (php-fpm). my site conf: (maybe is a little tweaked from fail fix attempts but still functional 99% of the time)

The same error happens on a few selected pages but not in the post pages inside wordpress, so even when the homepage is blank the rest of the site works ok.

I use the same conf on other servers and websites but this is the only one causing me trouble, the main difference is this website has a lot more traffic (2k+ per hour).

I been looking around for days but nothing seems to solve it, now about the pages where the error occur this pages read a TXT file with a “cached version of the page” which is refreshed/rewritten every 2 minutes, this help us to load super fast the homepage (and some internal pages) which usually take a few seconds more to load without the “cache” text file.

Note: We use CloudFlare but the error shows even if I use my hosts file to connect directly to the server (no caching in the middle) my PC <–> Nginx

Any ideas or suggestions would be really helpful. Thanks.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

please, you can share the solution, what are the files that you need change? ty. Excuse me my english.

First of all, I’m not too familiar with Nginx as a reverse cache, but the configuration seems pretty straight forward.

Seems like you’re caching all requests for 8 minutes in fastcgi_cache_valid, which will cache a 500-error for that entire time. You’re also caching all 500-error responses for 2 seconds in Nginx. I’m a little unsure why you’re doing that, but I suspect it’s to let the server recover or something?

I bet you’re running out of PHP processes, which makes requests time out, giving you a 502 Bad Gateway or 500 Internal Server Error. This is then cached, and served up for the next 8 minutes according to fastcgi_cache_valid. Restarting and deleting the Nginx cache will naturally solve this.

Proposed solution, which will only cache requests that has returned 200 OK:

fastcgi_cache_valid any 8m;
fastcgi_cache_valid 200 8m;