Apache2 randomly stops working

July 3, 2019 196 views
Apache Ubuntu 16.04

I’m fairly new to Apache2, and I’ve been using it for my website. Most of the time it works flawlessly, however at random times throughout the day it stops working and attempting to access the site returns ERR_TIMED_OUT on Chrome. This happens globally and is not specific to my IP or browser.

The access log mostly contains 502 codes and the error log is flooded with Error reading status line from remote server and The timeout specified has expired

I can’t find any solution to this issue despite how hard I look and it’s been driving me mad for months. It’s also worth mentioning that I have letsencrypt set up, which could be the problem.

Help would be greatly appreciated. Please tell me if there’s any other details I should share.

1 Answer

Hello,

According to the error, it seems like that it’s not an Apache issue but an issue with your backend.

Would you mind posting the full error that you see in the error logs?

Also can you let me know what are you using as a backend? And how exactly do you fix this issue when it occurs?

Regards,
Bobby

  • Hi Bobby!

    I use Node JS as a backend, but also have a few basic html files in /var/www/html - which stop working as well.
    Despite the system saying that Apache2 is running fine, simply restarting it fixes all the issues (or sometimes just waiting).

    Here’s a little snippet of the error logs.
    I’m noticing that “failed to make connection to backend” pops up quite a bit, so you may be correct.

    • Hello,

      Thanks for providing me with the logs, I think that those connections to the remote servers are causing the issue for you.

      What I could suggest is that the next time your Apache starts timing out, just ssh to the server and run:

      netstat -plant
      

      That way you would check your connections and you would be able to determine what’s going on.

      Let me know how it goes!
      Bobby

Have another answer? Share your knowledge.