# HuggingFace offline error

**URL:** <https://discuss.huggingface.co/t/huggingface-offline-error/89170>\
**Category:** Models\
**Created:** [May 29, 2024, 10:41am UTC](https://discuss.huggingface.co/t/huggingface-offline-error/89170 "2024-05-29T10:41:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andysg2211](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@andysg2211](https://discuss.huggingface.co/u/andysg2211)\
**Post date:** [May 29, 2024, 10:41am UTC](https://discuss.huggingface.co/t/huggingface-offline-error/89170/1 "2024-05-29T10:41:10Z")

</div>

```auto
OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like custom-model
 is not the path to a directory containing a file named config.json.
Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.

```

I have ensure to set:

HUGGINGFACE\_HUB\_CACHE to the dir /models

inside /models:  
contains custom-model which is a folder containing:

blobs config.json refs snapshots

---

<div class="post-metadata">

**Author:** ![linlinlin](https://avatars.discourse-cdn.com/v4/letter/l/e9bcb4/32.png) [@linlinlin](https://discuss.huggingface.co/u/linlinlin)\
**Post date:** [October 17, 2024, 9:31am UTC](https://discuss.huggingface.co/t/huggingface-offline-error/89170/2 "2024-10-17T09:31:16Z")

</div>

When using .from\_pretrained(), try to specify the param `trust_remote_code=True` and not to set `local_file_only=True`. In addition, set the HF\_ENDPOINT with ‘[https://hf-mirror.com](https://hf-mirror.com)’. For example:

```python
# Set the hub_cache dir
os.environ['HF_HOME'] = '/data/shared_models/'
# can also be done by 
# os.environ['TRANSFORMERS_CACHE'] = '/data/shared_models/'

# set mirror
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'

# load model by model_id
model_id = "Qwen/Qwen2-72B-Instruct"
model = AutoModelForCausalLM.from_pretrained(
    model_name, 
    device_map="auto", 
    torch_dtype=torch.bfloat16, 
    trust_remote_code=True, # without specify local_file_only
)

```
