diff --git a/jupyterhub/handlers/base.py b/jupyterhub/handlers/base.py index 024f4a9e..0f40b477 100644 --- a/jupyterhub/handlers/base.py +++ b/jupyterhub/handlers/base.py @@ -1330,7 +1330,7 @@ class UserUrlHandler(BaseHandler): **Changed Behavior as of 1.0** This handler no longer triggers a spawn. Instead, it checks if: - 1. server is not active, serve page prompting for spawn (status: 503) + 1. server is not active, serve page prompting for spawn (status: 424) 2. server is ready (This shouldn't happen! Proxy isn't updated yet. Wait a bit and redirect.) 3. server is active, redirect to /hub/spawn-pending to monitor launch progress (will redirect back when finished) @@ -1349,7 +1349,11 @@ class UserUrlHandler(BaseHandler): self.log.warning( "Failing suspected API request to not-running server: %s", self.request.path ) - self.set_status(404) + + # If we got here, the server is not running. To differentiate + # that the *server* itself is not running, rather than just the particular + # resource *in* the server is not found, we return a 424 instead of a 404. + self.set_status(424) self.set_header("Content-Type", "application/json") spawn_url = urlparse(self.request.full_url())._replace(query="") @@ -1514,15 +1518,14 @@ class UserUrlHandler(BaseHandler): self.redirect(pending_url, status=303) return - # if we got here, the server is not running - # serve a page prompting for spawn and 503 error - # visiting /user/:name no longer triggers implicit spawn - # without explicit user action + # If we got here, the server is not running. To differentiate + # that the *server* itself is not running, rather than just the particular + # page *in* the server is not found, we return a 424 instead of a 404. spawn_url = url_concat( url_path_join(self.hub.base_url, "spawn", user.escaped_name, server_name), {"next": self.request.uri}, ) - self.set_status(503) + self.set_status(424) auth_state = await user.get_auth_state() html = await self.render_template(