1

Few days ago I faced an interview and one of the questions was what would I do if I get a 404 error from a webserver. My answer was check the logs. The interviewer said that first I have to ping and check whether I have connectivity to the server .I don't regularly work with web servers at my current work place. My question is will we get a 404 error if we do not have connectivity to a web server?

eranga
  • 164
  • 1
  • 11
  • the interviewer had little clue, a 404 happens after you have already connected so makes little sense to ping or do any network test after that. – ezra-s Jan 10 '17 at 10:13

2 Answers2

3

Will we get a 404 error if we do not have connectivity to a web server?

No! :-)

The question said "a 404 error from a webserver". If it actually said that then the fact you got the error from the server implies that you have connectivity to it.

Regardless of the wording of the question, 404 means that the resource could not be found by the web server. It is an HTTP error code sent from the web server to the browser. So if you receive a 404 error from the web server, you already have proven connectivity to it. It often means you have the correct hostname/domain name, but the wrong directory name/page name.

E.g. www.this-bit-is-correct.com/this-bit-is-mistyped

When the interviewer mentioned ping, either they didn't know what they were talking about, or they were double bluffing!

Exceptions:

Some web servers return 404 for any error (e.g. 500 internal server error etc). However, this still means you have connectivity to the web server.

Another exception could be a load balancer or proxy returning 404 when they can't see the web server they are trying to refer you to.

bao7uo
  • 1,664
  • 11
  • 24
  • I guess he was double bluffing. Few occasions he tested me asking whether I was sure about my answer when it obviously was the right answer. I just fell in to that trap. – eranga Jan 08 '17 at 06:28
2

Obviously, not. A 404 error is a a response from the server to the request made by the client, which means that there is connectivity.

You can read the details on-line:

The 404 or Not Found error message is a Hypertext Transfer Protocol (HTTP) standard response code, in computer network communications, to indicate that the client was able to communicate with a given server, but the server could not find what was requested.

dawud
  • 14,918
  • 3
  • 41
  • 61