Hi there,
I am trying to run a JupyterLab template using HuggingFace’s Spaces, but as soon as the lab finishes building and starts, the space just gives a 404 error and doesn’t allow me to open the JupyterLab space.
Hi there,
I am trying to run a JupyterLab template using HuggingFace’s Spaces, but as soon as the lab finishes building and starts, the space just gives a 404 error and doesn’t allow me to open the JupyterLab space.
Hmm… The most common reason for a private space returning a 404 error when it should be accessible is the browser or browser settings. However, if it’s limited to Jupyter spaces, there might be some other cause…
A Hugging Face “404” right after a Space finishes building usually does not mean your repo is missing. In Spaces it often means either:
/lab and not /), so the proxy returns a real 404.Below is the background and the highest-probability fixes.
A Space has two “layers”:
https://huggingface.co/spaces/<owner>/<space>https://<space-subdomain>.hf.spaceThe Hub page shows the app inside an iframe, and the iframe is on a different domain. Hugging Face documents that modern browsers often restrict cookies in this exact “different-domain iframe” setup. (Hugging Face)
For private Spaces, Hugging Face needs cookies/session to prove you are allowed to see the app. If the browser blocks those cookies, the app can appear as “not found” (404) even to you.
This is the #1 pattern in community reports: private Space works when you allow third-party cookies, fails (404) when you block them.
[*.]huggingface.co). (Hugging Face Forums)There are repeated reports that private Spaces may not work on Safari/iOS unless you disable cross-site tracking prevention, because cookies must be shared between huggingface.co and *.hf.space. (Hugging Face Forums)
Apple’s own Safari settings description matches this: “Prevent Cross-Site Tracking” limits third-party cookies by default. (Apple Support)
If you are testing on iPhone/iPad Safari, assume this is the cause until proven otherwise. (Hugging Face Forums)
Even if auth is fine, Docker Spaces must expose the correct port and serve the right initial path.
app_portHugging Face states:
app_port in the README YAML. (Hugging Face)If JupyterLab is running on 8888 (Jupyter default) while the Space proxies 7860, you can get “build succeeded, Space started, but App is 404.”
Check this:
README.md YAML includes:
sdk: dockerapp_port: 7860 (or match whatever you run) (Hugging Face)Your startup command binds to 0.0.0.0 and that same port.
/ unless you set base_pathDocker Spaces load / by default. If your service returns 404 at / (even though it works at some other path), the Space will show 404. The config reference documents base_path, and community debugging threads call out that this is a common reason people see a 404 on the Space homepage. (Hugging Face)
For typical JupyterLab, / should redirect to /lab, so this usually only matters if you changed Jupyter’s base URL or reverse-proxy config.
Even after the 404 is fixed, two Jupyter-on-Spaces details matter:
JUPYTER_TOKEN. If you do not, Hugging Face says it defaults to huggingface, and they recommend setting it especially for public or org Spaces. (Hugging Face)/data. (Hugging Face)HF_HOME=/data/.huggingface to persist caches across restarts. (Hugging Face)This does not cause a 404, but it is the next common “surprise.”
Use this quick branching test:
Treat it as cookie/auth first.
Treat it as port/path.
app_port and that your process listens on that port. (Hugging Face)/ is served (or set base_path). (Hugging Face)Treat it as cross-site tracking prevention.
app_port, base_path): https://huggingface.co/docs/hub/en/spaces-config-reference (Hugging Face)HF_HOME=/data/.huggingface: https://huggingface.co/docs/hub/en/spaces-storage (Hugging Face)app_port (default 7860) and serving / (or base_path). (Hugging Face)Thank you, this fixed it
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.