# BadRequestError when loading a private model to space

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fbadrequesterror-when-loading-a-private-model-to-space%2F32360%3E%5C
**Category:** Spaces\
**Created:** [February 23, 2023, 12:02pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fbadrequesterror-when-loading-a-private-model-to-space%2F32360 "2023-02-23T12:02:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JaMe76](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@JaMe76](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJaMe76)%5C
**Post date:** [February 23, 2023, 12:02pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fbadrequesterror-when-loading-a-private-model-to-space%2F32360%2F1 "2023-02-23T12:02:48Z")

</div>

Hi,

while re-starting or rebooting my space I get a weird `BadRequestError` when a model from a private repo is supposed to be downloaded from the hub. There is a very similar topic Build Error - Bad Request that has been resolved a couple of days ago but the problem seems to persist in my situation.

I have no problem to execute my code and download the model locally.  
Tried to restart/reboot the space a couple of times the last two weeks but without success.

Space: [Deepdoctection - a Hugging Face Space by deepdoctection](https://huggingface.co/spaces/deepdoctection/deepdoctection)

This is the message I receive:

[0223 12:35.47 @file\_utils.py:33] INF PyTorch version 1.9.0 available.  
Traceback (most recent call last):  
File “/home/user/.local/lib/python3.8/site-packages/huggingface\_hub/utils/\_errors.py”, line 213, in hf\_raise\_for\_status  
response.raise\_for\_status()  
File “/home/user/.local/lib/python3.8/site-packages/requests/models.py”, line 1021, in raise\_for\_status  
raise HTTPError(http\_error\_msg, response=self)  
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url:  
The above exception was the direct cause of the following exception:

```auto
Traceback (most recent call last):
  File "app.py", line 43, in <module>
    layout_weights_path = dd.ModelDownloadManager.maybe_download_weights_and_configs(cfg.WEIGHTS.D2LAYOUT)
  File "/home/user/.local/lib/python3.8/site-packages/deepdoctection/extern/model.py", line 795, in maybe_download_weights_and_configs
    ModelDownloadManager.load_model_from_hf_hub(profile, absolute_path_weights, file_names)
  File "/home/user/.local/lib/python3.8/site-packages/deepdoctection/extern/model.py", line 822, in load_model_from_hf_hub
    size = ModelDownloadManager._load_from_hf_hub(repo_id, file_name, directory)
  File "/home/user/.local/lib/python3.8/site-packages/deepdoctection/extern/model.py", line 861, in _load_from_hf_hub
    f_path = cached_download(
  File "/home/user/.local/lib/python3.8/site-packages/huggingface_hub/file_download.py", line 737, in cached_download
    http_get(
  File "/home/user/.local/lib/python3.8/site-packages/huggingface_hub/file_download.py", line 479, in http_get
    hf_raise_for_status(r)
  File "/home/user/.local/lib/python3.8/site-packages/huggingface_hub/utils/_errors.py", line 250, in hf_raise_for_status
    raise BadRequestError(message, response=response) from e
huggingface_hub.utils._errors.BadRequestError: 

Bad request:

```

---

<div class="post-metadata">

**Author:** ![JaMe76](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@JaMe76](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJaMe76)%5C
**Post date:** [February 26, 2023, 8:23am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fbadrequesterror-when-loading-a-private-model-to-space%2F32360%2F2 "2023-02-26T08:23:25Z")

</div>

Upgrading to huggingface\_hub 0.12.0 resolved the problem.

Sorry for any inconvenience.
