# Value error : Connection error

**URL:** <https://discuss.huggingface.co/t/value-error-connection-error/3583>\
**Category:** 🤗Transformers\
**Created:** [February 10, 2021, 1:55pm UTC](https://discuss.huggingface.co/t/value-error-connection-error/3583 "2021-02-10T13:55:42Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Katarina](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@Katarina](https://discuss.huggingface.co/u/Katarina)\
**Post date:** [February 10, 2021, 1:55pm UTC](https://discuss.huggingface.co/t/value-error-connection-error/3583/1 "2021-02-10T13:55:42Z")

</div>

Hello,  
I am new in this forum and Hugging face models. Could someone help with this:  
I want to use model ‘Helsinki-NLP/opus-mt-en-sla’. I am using code from the site:

from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

tokenizer = AutoTokenizer.from\_pretrained(“Helsinki-NLP/opus-mt-en-sla”)

model = AutoModelForSeq2SeqLM.from\_pretrained(“Helsinki-NLP/opus-mt-en-sla”)

but I get this error: ValueError: Connection error, and we cannot find the requested files in the cached path. Please try again or make sure your Internet connection is on.

I have installed all necessary libraries and my internet connection is good…could someone help with this?  
Thanks

---

<div class="post-metadata">

**Author:** ![lewtun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lewtun/32/30995_2.png) [@lewtun](https://discuss.huggingface.co/u/lewtun)\
**Post date:** [February 10, 2021, 2:01pm UTC](https://discuss.huggingface.co/t/value-error-connection-error/3583/2 "2021-02-10T14:01:40Z")

</div>

Hello @Katarina, I was able to run your code snippet without any problems on my machine, so I wonder whether there is some firewall / proxy you need to configure on your end?

A simple test that your connection is fine would be to spin up a Google Colab notebook and see if your code works there. Alternatively, you could try upgrading to the latest version of `transformers` just to be sure it’s not an old bug that got fixed recently.

---

<div class="post-metadata">

**Author:** ![Katarina](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@Katarina](https://discuss.huggingface.co/u/Katarina)\
**Post date:** [February 10, 2021, 2:17pm UTC](https://discuss.huggingface.co/t/value-error-connection-error/3583/3 "2021-02-10T14:17:59Z")

</div>

Hi Lewis, thank you on answer. I checked on Google Colab and there is working fine.  
I am traying from Watson Studio, so probably then I have some blockades. Do you maybe know how is possible to incorporate that part - defining a proxy into this code?

---

<div class="post-metadata">

**Author:** ![lewtun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lewtun/32/30995_2.png) [@lewtun](https://discuss.huggingface.co/u/lewtun)\
**Post date:** [February 10, 2021, 2:25pm UTC](https://discuss.huggingface.co/t/value-error-connection-error/3583/4 "2021-02-10T14:25:21Z")

</div>

Hmm I am not familiar with Watson Studio so perhaps you need to do some special login to establish a connection?

If you’re running on a Linux machine, you can edit the `no_proxy` environment variable in the same shell that you’re running your code from, e.g. [bash - Set a network range in the no\_proxy environment variable - Unix & Linux Stack Exchange](https://unix.stackexchange.com/questions/23452/set-a-network-range-in-the-no-proxy-environment-variable)

However, my guess is that you might have more luck getting in touch with the IBM support to help you solve the problem 🙂

---

<div class="post-metadata">

**Author:** ![Katarina](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@Katarina](https://discuss.huggingface.co/u/Katarina)\
**Post date:** [February 10, 2021, 2:27pm UTC](https://discuss.huggingface.co/t/value-error-connection-error/3583/5 "2021-02-10T14:27:17Z")

</div>

Ok, I will try first with no proxy ev…thank you very much! Many regards…🙂

---

<div class="post-metadata">

**Author:** ![Katarina](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@Katarina](https://discuss.huggingface.co/u/Katarina)\
**Post date:** [February 19, 2021, 11:37am UTC](https://discuss.huggingface.co/t/value-error-connection-error/3583/6 "2021-02-19T11:37:12Z")

</div>

Hi, I just have update on this topic…I found a solution. See code below:  
import os

#proxy = ‘http://:@:’  
proxy = “[https://x.x.xx.x](https://x.x.xx.x):xxxx”

os.environ[‘http\_proxy’] = proxy  
os.environ[‘HTTP\_PROXY’] = proxy  
os.environ[‘https\_proxy’] = proxy  
os.environ[‘HTTPS\_PROXY’] = proxy

---

<div class="post-metadata">

**Author:** ![yangliu2](https://avatars.discourse-cdn.com/v4/letter/y/aeb1de/32.png) [@yangliu2](https://discuss.huggingface.co/u/yangliu2)\
**Post date:** [July 20, 2021, 9:55pm UTC](https://discuss.huggingface.co/t/value-error-connection-error/3583/7 "2021-07-20T21:55:47Z")

</div>

I have a related question. I have an environment that doesn’t have internet. I downloaded the model inside of a docker container and moved the docker imaged into the no-internet environment.  
It’s still giving me the Connection Error even if I pointed to the cached\_dir. Is there anyway to stop the code from requiring a internet connection and just use the cached\_dir?

```auto
        model_name = f'Helsinki-NLP/opus-mt-mul-en'
        # Download the model and the tokenizer
        cache_dir = "/root/.cache/huggingface/transformers"
        model = MarianMTModel.from_pretrained(model_name, cache_dir=cache_dir)
        tokenizer = MarianTokenizer.from_pretrained(model_name, cache_dir=cache_dir)

```

---

<div class="post-metadata">

**Author:** ![lewtun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lewtun/32/30995_2.png) [@lewtun](https://discuss.huggingface.co/u/lewtun)\
**Post date:** [August 2, 2021, 6:20pm UTC](https://discuss.huggingface.co/t/value-error-connection-error/3583/8 "2021-08-02T18:20:16Z")

</div>

hey @yangliu2 what happens if you set the `TRANSFORMERS_OFFLINE=1` as an environment variable in your docker container?

see more info [here](https://huggingface.co/transformers/installation.html#offline-mode)

---

<div class="post-metadata">

**Author:** ![yangliu2](https://avatars.discourse-cdn.com/v4/letter/y/aeb1de/32.png) [@yangliu2](https://discuss.huggingface.co/u/yangliu2)\
**Post date:** [August 4, 2021, 7:03pm UTC](https://discuss.huggingface.co/t/value-error-connection-error/3583/9 "2021-08-04T19:03:07Z")

</div>

@lewtun What you suggested seems to work. Although this has to be set before  
`from transformers import MarianMTModel, MarianTokenizer` if I want to use os package to set environmental variables.  
Other than it doesn’t follow PEP8, models seem to be loading okay.
