# Unable to run Diffusers while offline

**URL:** <https://discuss.huggingface.co/t/unable-to-run-diffusers-while-offline/50968>\
**Category:** 🧨 Diffusers\
**Created:** [August 16, 2023, 1:41pm UTC](https://discuss.huggingface.co/t/unable-to-run-diffusers-while-offline/50968 "2023-08-16T13:41:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BoltMonkey](https://avatars.discourse-cdn.com/v4/letter/b/919ad9/32.png) [@BoltMonkey](https://discuss.huggingface.co/u/BoltMonkey)\
**Post date:** [August 16, 2023, 1:41pm UTC](https://discuss.huggingface.co/t/unable-to-run-diffusers-while-offline/50968/1 "2023-08-16T13:41:30Z")

</div>

I am running into the error below when I try to run my Diffusers model completely offline (without any internet connection). However, my code works perfectly if I have internet.

I work in very remote locations for a few weeks out of every month and I don’t always have access to the internet while I am away. How can I avoid this error?

Traceback (most recent call last):  
File “C:\Users\User\PycharmProjects\runinf\venv\lib\site-packages\urllib3\connection.py”, line 174, in \_new\_conn  
conn = connection.create\_connection(  
File “C:\Users\User\PycharmProjects\runinf\venv\lib\site-packages\urllib3\util\connection.py”, line 72, in create\_connection  
for res in socket.getaddrinfo(host, port, family, socket.SOCK\_STREAM):  
File “C:\Users\User\AppData\Local\Programs\Python\Python310\lib\socket.py”, line 955, in getaddrinfo  
for res in \_socket.getaddrinfo(host, port, family, type, proto, flags):  
socket.gaierror: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File “C:\Users\User\PycharmProjects\runinf\venv\lib\site-packages\urllib3\connectionpool.py”, line 703, in urlopen  
httplib\_response = self.\_make\_request(  
File “C:\Users\User\PycharmProjects\runinf\venv\lib\site-packages\urllib3\connectionpool.py”, line 386, in \_make\_request  
self.\_validate\_conn(conn)  
File “C:\Users\User\PycharmProjects\runinf\venv\lib\site-packages\urllib3\connectionpool.py”, line 1042, in \_validate\_conn  
conn.connect()  
File “C:\Users\User\PycharmProjects\runinf\venv\lib\site-packages\urllib3\connection.py”, line 358, in connect  
self.sock = conn = self.\_new\_conn()  
File “C:\Users\User\PycharmProjects\runinf\venv\lib\site-packages\urllib3\connection.py”, line 186, in \_new\_conn  
raise NewConnectionError(  
urllib3.exceptions.NewConnectionError: \<urllib3.connection.HTTPSConnection object at 0x00000257B6781EA0\>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File “C:\Users\User\PycharmProjects\runinf\venv\lib\site-packages\requests\adapters.py”, line 489, in send  
resp = conn.urlopen(  
File “C:\Users\User\PycharmProjects\runinf\venv\lib\site-packages\urllib3\connectionpool.py”, line 787, in urlopen  
retries = retries.increment(  
File “C:\Users\User\PycharmProjects\runinf\venv\lib\site-packages\urllib3\util\retry.py”, line 592, in increment  
raise MaxRetryError(\_pool, url, error or ResponseError(cause))  
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘[raw.githubusercontent.com](http://raw.githubusercontent.com)’, port=443): Max retries exceeded with url: /CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml (Caused by NewConnectionError(‘\<urllib3.connection.HTTPSConnection object at 0x00000257B6781EA0\>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File “C:\Users\User\PycharmProjects\runinf\main.py”, line 8, in   
import gen\_img  
File “C:\Users\User\PycharmProjects\runinf\gen\_img.py”, line 17, in   
pipe = StableDiffusionImg2ImgPipeline.from\_single\_file(pretrained\_model\_link\_or\_path=model\_id\_or\_path, torch\_dtype=torch.float16, local\_files\_only=True)  
File “C:\Users\User\PycharmProjects\runinf\venv\lib\site-packages\diffusers\loaders.py”, line 1924, in from\_single\_file  
pipe = download\_from\_original\_stable\_diffusion\_ckpt(  
File “C:\Users\User\PycharmProjects\runinf\venv\lib\site-packages\diffusers\pipelines\stable\_diffusion\convert\_from\_ckpt.py”, line 1253, in download\_from\_original\_stable\_diffusion\_ckpt  
original\_config\_file = BytesIO(requests.get(config\_url).content)  
File “C:\Users\User\PycharmProjects\runinf\venv\lib\site-packages\requests\api.py”, line 73, in get  
return request(“get”, url, params=params, \*\*kwargs)  
File “C:\Users\User\PycharmProjects\runinf\venv\lib\site-packages\requests\api.py”, line 59, in request  
return session.request(method=method, url=url, \*\*kwargs)  
File “C:\Users\User\PycharmProjects\runinf\venv\lib\site-packages\requests\sessions.py”, line 587, in request  
resp = self.send(prep, \*\*send\_kwargs)  
File “C:\Users\User\PycharmProjects\runinf\venv\lib\site-packages\requests\sessions.py”, line 701, in send  
r = adapter.send(request, \*\*kwargs)  
File “C:\Users\User\PycharmProjects\runinf\venv\lib\site-packages\requests\adapters.py”, line 565, in send  
raise ConnectionError(e, request=request)  
requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘[raw.githubusercontent.com](http://raw.githubusercontent.com)’, port=443): Max retries exceeded with url: /CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml (Caused by NewConnectionError(‘\<urllib3.connection.HTTPSConnection object at 0x00000257B6781EA0\>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed’))

Process finished with exit code 1

I am using the following code to establish my pipeline:

model\_id\_or\_path = “./model/diff\_model\_3.safetensors”

pipe = StableDiffusionImg2ImgPipeline.from\_single\_file(pretrained\_model\_link\_or\_path=model\_id\_or\_path, torch\_dtype=torch.float16, local\_files\_only=True)  
print(pipe.config.values())

pipe.scheduler = EulerAncestralDiscreteScheduler.from\_config(pipe.scheduler.config)

pipe = pipe.to(device)

---

<div class="post-metadata">

**Author:** ![BoltMonkey](https://avatars.discourse-cdn.com/v4/letter/b/919ad9/32.png) [@BoltMonkey](https://discuss.huggingface.co/u/BoltMonkey)\
**Post date:** [August 26, 2023, 5:32pm UTC](https://discuss.huggingface.co/t/unable-to-run-diffusers-while-offline/50968/2 "2023-08-26T17:32:16Z")

</div>

For anyone encountering the issue of the Huggingface diffusers library not working with local models when there’s no internet connection, I’ve identified a solution.

I initially intended to submit a Pull Request to GitHub but noticed that another contributor has already submitted a similar fix. I can confirm that the proposed changes effectively resolve the issue.

If you are currently having the same issue and want a quick fix, you can make the following changes to the loaders.py file:

1. Modify `from_single_file()` function

Add a keyword argument to the function definition as follows:  
`original_config_file = kwargs.pop("original_config_file", None)`

1. Modify `download_from_original_stable_diffusion_ckpt()` function at the end of the ‘from\_single\_file()’ function

Pass the new keyword argument like this:  
`original_config_file=original_config_file`

This will allow you to specify a local `.yaml` file for the original configuration of the model.

You can find the URLs for the `.yaml` files in the `convert_from_ckpt.py` file. This is what the library attempts to download, causing the error.

As of the time of writing, relevant URLs are located as follows:

- For model\_type = “v1”: [https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml](https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml)
- For model\_type = “v2”: [https://raw.githubusercontent.com/Stability-AI/stablediffusion/main/configs/stable-diffusion/v2-inference-v.yaml](https://raw.githubusercontent.com/Stability-AI/stablediffusion/main/configs/stable-diffusion/v2-inference-v.yaml)
- For model\_type = “sd\_xl\_base”: [https://raw.githubusercontent.com/Stability-AI/generative-models/main/configs/inference/sd\_xl\_base.yaml](https://raw.githubusercontent.com/Stability-AI/generative-models/main/configs/inference/sd_xl_base.yaml)
- For model\_type = “sd\_xl\_refiner”: [https://raw.githubusercontent.com/Stability-AI/generative-models/main/configs/inference/sd\_xl\_refiner.yaml](https://raw.githubusercontent.com/Stability-AI/generative-models/main/configs/inference/sd_xl_refiner.yaml)

Or, you can use the .yaml’s packaged in Automatic1111’s stable-diffusion-webui/configs if you are already using their GUI.

---

<div class="post-metadata">

**Author:** ![pcuenq](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pcuenq/32/32135_2.png) [@pcuenq](https://discuss.huggingface.co/u/pcuenq)\
**Post date:** [August 26, 2023, 6:37pm UTC](https://discuss.huggingface.co/t/unable-to-run-diffusers-while-offline/50968/3 "2023-08-26T18:37:15Z")

</div>

Hi @BoltMonkey! Is this the PR you were referring to? [add config\_file to from\_single\_file by zuojianghua · Pull Request #4614 · huggingface/diffusers · GitHub](https://github.com/huggingface/diffusers/pull/4614)

If so, then I think the problem would be resolved, right?

---

<div class="post-metadata">

**Author:** ![BoltMonkey](https://avatars.discourse-cdn.com/v4/letter/b/919ad9/32.png) [@BoltMonkey](https://discuss.huggingface.co/u/BoltMonkey)\
**Post date:** [August 26, 2023, 6:43pm UTC](https://discuss.huggingface.co/t/unable-to-run-diffusers-while-offline/50968/4 "2023-08-26T18:43:40Z")

</div>

Yes, that is the one.
