# Connection Error on Inference Endpoint for Bart-Large-Cnn

**URL:** <https://discuss.huggingface.co/t/connection-error-on-inference-endpoint-for-bart-large-cnn/41519>\
**Category:** Models\
**Created:** [May 30, 2023, 5:03pm UTC](https://discuss.huggingface.co/t/connection-error-on-inference-endpoint-for-bart-large-cnn/41519 "2023-05-30T17:03:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ujjawal0911](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ujjawal0911/32/16453_2.png) [@ujjawal0911](https://discuss.huggingface.co/u/ujjawal0911)\
**Post date:** [May 30, 2023, 5:03pm UTC](https://discuss.huggingface.co/t/connection-error-on-inference-endpoint-for-bart-large-cnn/41519/1 "2023-05-30T17:03:29Z")

</div>

Hey so I had this code which I was using to make an inference request to the huggingface server. It used to work fine but just now it started giving this error

```python
def bart_inference(text: str, percent: int) -> str:
        total_length = len(text.split(" "))
        min_length = (total_length * percent) // 100

        headers = {"Authorization": f"Bearer {HF_API_KEY}"}
        url = "https://api-inference.huggingface.co/models/google/pegasus-xsum"

        data = json.dumps(
            {
                "inputs": text,
                "parameters": {
                    "min_length": min_length,
                    "max_length": (min_length + 60),
                    "do_sample": False,
                },
            }
        )
        print("dafs")

        response = requests.request("POST", url, headers=headers, data=data)
        print(response.status_code)
        print(response.json())
        return json.loads(response.content.decode("utf-8"))

```

The error:-

```json
{'error': "Can't load tokenizer using from_pretrained, please update its configuration: Connection error, and we cannot find the requested files in the cached path. Please try again or make sure your Internet connection is on."}

```
