Web-server – How to troubleshoot a web server

networkingtroubleshootingweb-server

NOTE: This is being asked, not because it is a good question (in my personal opinion, it's not), but because I've noticed a lot of questions on here boil down to this question, and since I'm sick of downvoting and giving a form response in a comment explaining basic (server-agnostic) troubleshooting.

In other words, if someone linked you to this question, you are either new to systems administration and making a rookie mistake (which is okay; we've all been new to things and asked questions that seemed stupid to people who have forgotten what it's like to be new to something), or you've been doing this a while and you are simply incompetent (harsh, but sometimes the truth hurts).

The answer to this question should not mention specific webserver instructions. At most, give some information on how you'd do things under different common classes of operating system (Windows, Linux, OS X, and BSD). That's it. So, nothing specific to apache or mojolicious or whatever webserver is in use.

…Anyway, without further ado…

I set up webserver X on platform Y, and I tried accessing the homepage, but it's not loading. What gives? What's going wrong / how can I figure out what's going wrong?

Best Answer

The most important things to keep in mind are:

  • If it's a default configuration of the server, it's probably not a problem with the webserver code itself, or with the operating system. It's most likely network-related. It might not be, but that brings us to point 2...
  • Your time is valuable. When troubleshooting, you should always begin by checking the things that are easiest to check and fix. If the problem somehow really is in the codebase of Apache / nginx / lghttpd / node.js / whatever, trying to fix it would almost certainly take on the order of weeks. And that's assuming you already know a few programming languages. Otherwise, it may take anything from six months to half past never. If it's the operating system, well... Assume it isn't the operating system. At least for now.
  • Our time is valuable, too. If you don't know a term, google it. If you find a resource that explains that term well, great! Add the link in here. Don't ask a question until you've at least checked google and wikipedia.
  • Chances are you're new to computing, so here's a heads-up: Computing is about reading lots and lots of technical English text. Manuals, textbooks, tutorials, manuals, manuals, and more manuals. If that sounds awful to you, you are in the wrong industry. You will have to read a few tens of thousands of pages of documentation written in English to reach even a basic level of competence. To solve whatever problem you're experiencing right now, you're going to have to do a lot of looking things up yourself and then reading them carefully. That is not unusual. If everything about that sounds awful to you, you are in the wrong industry. Here's a more in-depth article to help you figure out whether computing is right for you.

Now...

Operating-System-agnostic Troubleshooting

There are multiple things that can go wrong when trying to connect to a website.

  • If you're using a domain name (so, a human-readable name; something like example.com or malware.info), the problem may be in DNS. So check that your domain resolves to the IP address of your server under DNS using something like dig.

  • Once you've determined DNS isn't the problem, make sure that pinging the IP address provided is successful, or at least that the IP address actually is associated with the machine you're trying to access (by logging into that server's console and checking NIC addresses).

  • Make sure the webserver's service is actually running. A lot of webservers will not run by-default; you have to actually start them. This is a good thing, because it ensures the server doesn't start until you're sure the configuration is right.

  • Make sure the webserver is listening on TCP port 80 the way you expect it should be (most operating systems provide an easy way to check which ports are being listened on, and which services are listening on those ports). Worth noting that, by default, a lot of webserver installations will run on some other port for testing purposes (e.g. 8080, 80801, etc.). If the webserver is running but not listening on port 80, you'll want to check the documentation for the server. Specifically you'll probably want to check the "Getting Started" guide for the server and see whether it says anything about port assignments. Most servers have a part of the documentation called "Getting Started" or "Quickstart" or something along those lines (if the authors are adventurous it might be called "Diving into <NAME OF SERVER>"), and it's usually near the beginning of the docs.

  • Check the firewall rules, and ensure they aren't preventing access to the webserver (webservers usually run on TCP port 80, so you'll want to make sure that's explicitly allowed, and is the first rule in the firewall). It's worthwhile to temporarily disable the firewall and try to connect with the firewall disabled, if you're not sure whether it might be the firewall. Once you've established it is the firewall, you should bring the firewall online again and tweak the ruleset until things work. Simply leaving the firewall disabled is easier, but it's also a very, very bad idea.

O/S-specific Troubleshooting

Linux

// TODO

Windows

// TODO

OS X

// TODO

BSD

// TODO

Related Topic