Search code examples
httphttp-status-codes

HTTP status code for not resolved url


Maybe this is an opinion based question, maybe not, I am not sure so I'll ask.

I am implementing a simple proxy server. Which is the most appropriate error code for the proxy to return when a url that does not resolve to anything is requested?

After some search I came to the understanding that there is not a standard http code for this occasion, maybe this is due to the fact that for a server it's hard to determine what is the cause of not being able to resolve a url.

The closest to meaningful status codes I have found are the

  • 502 The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.

and

  • 504 The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request.

but in my understanding both imply that the url was found in the dns.


Solution

  • I would use 404 status code:

    404 Not Found:

    • The requested resource could not be found but may be available in the future.

    But I am not sure, this is what you whant.