Random initial NS_ERROR_CONNECTION_REFUSED but all OK after refresh?
AnsweredLately, I've been seeing this random issue occurring on many (if not all) our server's websites where like 15% to 20% of the resources will not load initially, but will then load after a refresh (mostly JPEG images and sometimes a CSS file, randomly). Note that when this occurs, the images not loading are random.
The error displayed by Firefox is always "NS_ERROR_CONNECTION_REFUSED" which is pretty weird, since 0.01 second after that, it successfully loads a few more JPEG resources from the exact same website.
It randomly happens once or twice a day (not often) and only after a website has not been refreshed for at least a couple hours and it also almost always occur if requested from a private tab (so: no cache). In both cases, when I refresh the tab, all the files load perfectly well and everything looks normal. The website is not slow or anything and the server is not experiencing any high resource usage at all (e.g. 10% of its CPU and less than 5% of its RAM in use but it still occurs).
Initially, I thought that this was caused by PHP-FPM because I'm fairly new to it and the default values that cPanel ships with make absolutely no sense whatsoever, so I had to fiddle with the configuration quite a lot to get decent performance out of it and aside from what is happening, PHP-FPM is now an improvement over suphp for us. But anyway, we disabled PHP-FPM for a couple websites to try and isolate the issue and saw that it still occurs in the same conditions no matter if PHP-FPM is enabled or not, so it's not PHP-FPM related.
Has anybody ever had to deal with this issue before? Any ideas what to check/how to debug this? I'm wondering if it has anything to do with ModSec, which is the next thing we will disable tomorrow to try and further isolate the problem. I've seen a lot of seriously badly programmed rules in ModSec that trigger a lot of false positives before, so I would not be surprised if it was ModSec, but we'll see tomorrow.
See below, the errored out resources are random and all of those will successfully load upon a refresh.
-
Hey hey! We don't have anything in our ticket system for "NS_ERROR_CONNECTION_REFUSED" so that would point me toward something outside of the server causing this.
Have you confirmed this behavior on multiple systems? That would be my first step. If the issue does end up being isolated to one client's machine, it seems like a DNS issue or local resolver issue possibly.
0 -
You know what? You're right. I skipped the obvious and I'm now beginning to think that it's something that's related to the network I'm using. I have seen Firefox do a connection refused error on other websites (completely unrelated to our server, not even in the same data centre) then I refresh and it shows just fine within a second. So I think something is up with the WiFi or the Internet here. I will keep this open for a few days and do further testing.
EDIT: No. Ah, I don't know anymore, because I just did 5 tests very thoroughly following this exact procedure:
1) Close all private windows/tabs.
2) Open 1 private tab with the network inspector open on the side.
3) Load a specific website and note the NS_ERROR_CONNECTION_REFUSED image paths.
I've repeated this 5 times with 1 minute between each try. The resources that don't load are almost exactly the same with 1 shifted row for one of the 3 tries. This is way too perfect to be related to my WiFi network. It's nowhere near random enough to be WiFi flukes.
One thing to note is that all the resources always load perfectly well until the 38th or 39th file. Then it randomly does not load files 39 through 73 and then it always loads all the way up to 152 files. Files 39 through 73 are randomly not loading, so among my 5 tries, all JPEG files got to load and not load.
You mention a DNS issue, which I believe is impossible in this scenario, since it loads most of the files. If Firefox would not resolve the DNS, then it would not load anything (all the files are on the same server).
0 -
If you have a server where you can reliably repeat the behavior could you make a ticket?
0 -
You know me. I can't do that. But hopefully, this will ring a bell to other users who might remember having to deal with this. If you want me to open a ticket, then surely you know where/what to look. I'm root. I appreciate your help.
0 -
It could be Firefox, have you tried other browsers? When searching for the error on Google, most of the results refer to Firefox:
https://www.google.com/search?q=NS_ERROR_CONNECTION_REFUSED&tbs=qdr:y
0 -
If you want me to open a ticket, then surely you know where/what to look.
If I had an idea I'd just tell you, but I don't have anything in our ticket system about this particular error.
0 -
MinervaH Sometimes, humans don't see the forest for the trees... or whatever the proverb is.
But I just tried with Safari and it does the exact same thing!
Does anybody know a configuration variable somewhere in Apache that would cut the connection after X requests in a row or X request within a second? I'm sure it's security or configuration related.
0 -
I FOUND IT AND FIXED IT! You may close this thread. The solution is to increase the "Max Keep-Alive Requests" value under Apache Configuration.
0 -
Did the Apache logs not show anything related to that while you tested?
0 -
All I saw were 404 and 200 lines, but nothing about Apache closing the connection abruptly on the browsers were 40-ish requests were made. I'm not an Apache expert so maybe I looked in the wrong log files.
0
Please sign in to leave a comment.
Comments
10 comments