Every time I run run_glue.py I get stuck in the "sock.connect(sa)" of the code at several places. Why? Is it a network problem?
Author: LLIKKE
Pull request: no

### System Info

check_min_version("4.33.0.dev0")

### Who can help?

_No response_

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [X] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction


python run_glue.py \
  --model_name_or_path bert-base-cased \
  --task_name mrpc \
  --do_train \
  --do_eval \
  --max_seq_length 128 \
  --per_device_train_batch_size 32 \
  --learning_rate 2e-5 \
  --num_train_epochs 5 \
  --overwrite_output_dir \
  --save_steps 50000 \
  --output_dir checkpoint

### Expected behavior

python run_glue.py \
  --model_name_or_path bert-base-cased \
  --task_name mrpc \
  --do_train \
  --do_eval \
  --max_seq_length 128 \
  --per_device_train_batch_size 32 \
  --learning_rate 2e-5 \
  --num_train_epochs 5 \
  --overwrite_output_dir \
  --save_steps 50000 \
  --output_dir checkpoint

I run this code, which is slow when I load it earlier, and when I force the end, it says "connection.py", line 85, in create_connection
sock.connect(sa)
"KeyboardInterrupt" but waiting for a while still works for model training, what's the reason? Is it a network problem?

Comments:
Hmmm it seems like it could be a connection issue, yes! Do you have the full error code? Do you have the same issue if running in google colab?

> Hmmm it seems like it could be a connection issue, yes! Do you have the full error code? Do you have the same issue if running in google colab?

I am in China and it seems that a lot of people have this problem recently, it should be the Internet problem. Could you please tell me why transformers keeps visiting the website instead of first reading the downloaded model and dataset in the cache? Thank you!

We do this to see if there was an update to the model/tokenizer files on the Hub.

If you already have them in your cache, you can bypass this with the [offline mode through an environment variable](https://huggingface.co/docs/transformers/v4.33.3/en/installation#offline-mode) or through individual calls to `from_pretrained` with the `local_files_only` kwarg on each `from_pretrained` method (maybe this could be added to the offline-mode docs? cc @stevhliu @MKhalusova)

> We do this to see if there was an update to the model/tokenizer files on the Hub.
> 
> If you already have them in your cache, you can bypass this with the [offline mode through an environment variable](https://huggingface.co/docs/transformers/v4.33.3/en/installation#offline-mode) or through individual calls to `from_pretrained` with the `local_files_only` kwarg on each `from_pretrained` method (maybe this could be added to the offline-mode docs? cc @stevhliu @MKhalusova)

thank you!

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.

Fixed in https://github.com/huggingface/transformers/pull/26478

If you stuck at sock.connect, probably it because the middleware server inr your company has blocked the transfromer url request to huggingface or whatever. There could be some proxy address or setting in your company that allows outbounding connection

You need to set these proxy variable correctly if you need them for outbound request, check what `env` prints out in terminal against these variables
```
export no_proxy=your_setting
export http_proxy=your_proxy
export https_proxy=your_proxy
export all_proxy=your_proxy
export ftp_proxy=your_proxy
export NO_PROXY=your_setting
export HTTP_PROXY=your_proxy
export HTTPS_PROXY=your_proxy
export ALL_PROXY=your_proxy
export FTP_PROXY=your_proxy
```

or making transformer go offline by https://github.com/huggingface/transformers/issues/10379

```
HF_DATASETS_OFFLINE=1
TRANSFORMERS_OFFLINE=1
```