11

Occasionally, nginx doesn't send any data back to the browser (ERR_EMPTY_RESPONSE in Chrome).

Upon checking the server error.log, I find these weird messages:

2013/10/20 23:57:40 [alert] 29146#0: *35 pread() read only 4653 of 4656 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2013/10/20 23:57:45 [alert] 29146#0: *36 pread() read only 4653 of 4656 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2013/10/20 23:58:18 [alert] 29146#0: *38 pread() read only 4650 of 4653 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2013/10/20 23:58:18 [alert] 29146#0: *39 pread() read only 4650 of 4653 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2013/10/20 23:58:19 [alert] 29146#0: *40 pread() read only 4650 of 4653 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2013/10/21 00:02:21 [alert] 29146#0: *41 pread() read only 4629 of 4641 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2013/10/21 00:02:21 [alert] 29146#0: *42 pread() read only 4629 of 4641 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2013/10/21 00:02:23 [alert] 29146#0: *43 pread() read only 4629 of 4641 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2013/10/21 00:02:31 [alert] 29146#0: *44 pread() read only 4629 of 4641 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2013/10/21 00:02:46 [alert] 29146#0: *45 pread() read only 4629 of 4641 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"

Does anyone have any idea why this happens? After a while everything is served correctly again.

3 Answers 3

5

I found this russian forum thread that says it's related to open_file_cache directives.

Makes sense, as I am using Sublime Text and it doesn't do atomic file saves.

1
  • 1
    This sounds correct. The index.html file is being modified as clients are trying to read it. Oct 21, 2013 at 2:54
1

I have been the same issue, after many searches, its resolved by open_log_file_cache

open_log_file_cache      max=20000 inactive=30s min_uses=2;

It's not related to your question but for other visitors who searching for best practice of nginx file caching, this is my full file cache config after many searches and take many benchmarks.

# cache information about FDs, frequently accessed files
aio                      threads; # linux kernel > 2.6.22
open_file_cache          max=10000 inactive=120s; # removed from the cache if it has not been accessed during `inactive` time
open_file_cache_valid    120s; # Sets a time after which open_file_cache elements should be validated.
open_file_cache_min_uses 2; # Sets the minimum number of file accesses during the period configured by the inactive parameter
open_file_cache_errors   off; # Enables or disables caching of file lookup errors by open_file_cache.
open_log_file_cache      max=20000 inactive=30s min_uses=2;
0

Whoever comes across this next, the issue is related to Open file Cache.

In most cases it is caused by the File being modified while being read by Nginx for caching as David mentioned earlier.

This will cause a loop and to solve it, simply reload Nginx with

sudo nginx -t && sudo nginx reload

Always test before Reloading or Restarting Nginx to make sure everything is a'okay and you won't take your Web server down with a misconfiguration.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .