# Error occuring while trying the API

**URL:** <https://discuss.roboflow.com/t/error-occuring-while-trying-the-api/1617>\
**Category:** 🤝  Community Help\
**Created:** [March 7, 2023, 12:08am UTC](https://discuss.roboflow.com/t/error-occuring-while-trying-the-api/1617 "2023-03-07T00:08:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AhmetAksunger](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/ahmetaksunger/32/1354_2.png) [@AhmetAksunger](https://discuss.roboflow.com/u/AhmetAksunger)\
**Post date:** [March 7, 2023, 12:08am UTC](https://discuss.roboflow.com/t/error-occuring-while-trying-the-api/1617/1 "2023-03-07T00:08:12Z")

</div>

![Screenshot_4](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/2X/c/cde6cda693b472e5095451826070709048e3c06d.png)  
The error I get: Traceback (most recent call last):  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py”, line 703, in urlopen  
httplib\_response = self.\_make\_request(  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py”, line 398, in \_make\_request  
conn.request(method, url, \*\*httplib\_request\_kw)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py”, line 239, in request  
super(HTTPConnection, self).request(method, url, body=body, headers=headers)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\http\client.py”, line 1255, in request  
self.\_send\_request(method, url, body, headers, encode\_chunked)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\http\client.py”, line 1301, in \_send\_request  
self.endheaders(body, encode\_chunked=encode\_chunked)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\http\client.py”, line 1250, in endheaders  
self.\_send\_output(message\_body, encode\_chunked=encode\_chunked)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\http\client.py”, line 1049, in \_send\_output  
self.send(chunk)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\http\client.py”, line 971, in send  
self.sock.sendall(data)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\ssl.py”, line 1204, in sendall  
v = self.send(byte\_view[count:])  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\ssl.py”, line 1173, in send  
return self.\_sslobj.write(data)  
ConnectionResetError: [WinError 10054] Varolan bir bağlantı uzaktaki bir ana bilgisayar tarafından zorla kapatıldı

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py”, line 489, in send  
resp = conn.urlopen(  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py”, line 787, in urlopen  
retries = retries.increment(  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\retry.py”, line 550, in increment  
raise six.reraise(type(error), error, \_stacktrace)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\packages\six.py”, line 769, in reraise  
raise value.with\_traceback(tb)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py”, line 703, in urlopen  
httplib\_response = self.\_make\_request(  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py”, line 398, in \_make\_request  
conn.request(method, url, \*\*httplib\_request\_kw)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py”, line 239, in request  
super(HTTPConnection, self).request(method, url, body=body, headers=headers)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\http\client.py”, line 1255, in request  
self.\_send\_request(method, url, body, headers, encode\_chunked)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\http\client.py”, line 1301, in \_send\_request  
self.endheaders(body, encode\_chunked=encode\_chunked)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\http\client.py”, line 1250, in endheaders  
self.\_send\_output(message\_body, encode\_chunked=encode\_chunked)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\http\client.py”, line 1049, in \_send\_output  
self.send(chunk)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\http\client.py”, line 971, in send  
self.sock.sendall(data)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\ssl.py”, line 1204, in sendall  
v = self.send(byte\_view[count:])  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\ssl.py”, line 1173, in send  
return self.\_sslobj.write(data)  
urllib3.exceptions.ProtocolError: (‘Connection aborted.’, ConnectionResetError(10054, ‘Varolan bir bağlantı uzaktaki bir ana bilgisayar tarafından zorla kapatıldı’, None, 10054, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File “c:/Users/90538/Desktop/import cv2.py”, line 9, in   
prediction = model.predict(“C:/Users/90538/Desktop/OkeyData/20230305\_025932.jpg”)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\site-packages\roboflow\models\object\_detection.py”, line 157, in predict  
resp = requests.post(  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py”, line 115, in post  
return request(“post”, url, data=data, json=json, \*\*kwargs)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py”, line 59, in request  
return session.request(method=method, url=url, \*\*kwargs)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py”, line 587, in request  
resp = self.send(prep, \*\*send\_kwargs)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py”, line 701, in send  
r = adapter.send(request, \*\*kwargs)  
File “C:\Users\90538\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py”, line 547, in send  
raise ConnectionError(err, request=request)  
requests.exceptions.ConnectionError: (‘Connection aborted.’, ConnectionResetError(10054, ‘Varolan bir bağlantı uzaktaki bir ana bilgisayar tarafından zorla kapatıldı’, None, 10054, None))

It keeps saying **“A connection that existed was forcibly closed by a remote host”**  
I checked my project, I checked the versions of my project. I can see them all via python. But as soon as I try to predict by uploading an image, I get that error. Please help

---

<div class="post-metadata">

**Author:** ![Mohamed](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/mohamed/32/62_2.png) [@Mohamed](https://discuss.roboflow.com/u/Mohamed)\
**Post date:** [March 7, 2023, 1:36am UTC](https://discuss.roboflow.com/t/error-occuring-while-trying-the-api/1617/2 "2023-03-07T01:36:30Z")

</div>

Are you on a VPN or firewall that may be re-routing or blocking your traffic?

And what is the size of the image, in MB and in pixels (width and height) for the image in question that failed?

---

<div class="post-metadata">

**Author:** ![AhmetAksunger](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/ahmetaksunger/32/1354_2.png) [@AhmetAksunger](https://discuss.roboflow.com/u/AhmetAksunger)\
**Post date:** [March 7, 2023, 11:09am UTC](https://discuss.roboflow.com/t/error-occuring-while-trying-the-api/1617/3 "2023-03-07T11:09:11Z")

</div>

No, I’m not using any VPN. The file I am testing is 2016 x 980 in pixels and 100 KB in MBs.

---

<div class="post-metadata">

**Author:** ![Maneth\_Karunanayake](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/maneth_karunanayake/32/1294_2.png) [@Maneth\_Karunanayake](https://discuss.roboflow.com/u/Maneth_Karunanayake)\
**Post date:** [April 6, 2023, 7:10am UTC](https://discuss.roboflow.com/t/error-occuring-while-trying-the-api/1617/4 "2023-04-06T07:10:56Z")

</div>

I have been facing the same problem when trying to predict by uploading an image and when trying to infer on local images. I get the same error:

Exception has occurred: ConnectionError  
(‘Connection aborted.’, ConnectionResetError(10054, ‘An existing connection was forcibly closed by the remote host’, None, 10054, None))

@Mohamed is there anything I can do to address this?

---

<div class="post-metadata">

**Author:** ![Mohamed](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/mohamed/32/62_2.png) [@Mohamed](https://discuss.roboflow.com/u/Mohamed)\
**Post date:** [April 13, 2023, 12:38am UTC](https://discuss.roboflow.com/t/error-occuring-while-trying-the-api/1617/5 "2023-04-13T00:38:13Z")

</div>

I’m looking at this on another thread, too. I have a hunch as to what the problem may be - can you two email [help@roboflow.com](mailto:help@roboflow.com) with the scripts you’re using to run the API calls?

Additionally, please include the example image file(s) you tested when receiving the 500-errors.

> [@Deploying using api is giving 500 eroor](https://discuss.roboflow.com/t/deploying-using-api-is-giving-500-eroor/1688/7):
>
> @jackey @zong_wei Interesting - I’m having trouble reproducing this. Are hosted images the only images you are testing with, or have you both tried with local images, too? Additionally, what are the image sizes you’re testing with? (In Megabytes, and the width/height in pixels)

---

<div class="post-metadata">

**Author:** ![leo](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/leo/32/2228_2.png) [@leo](https://discuss.roboflow.com/u/leo)\
**Post date:** [June 29, 2023, 11:32pm UTC](https://discuss.roboflow.com/t/error-occuring-while-trying-the-api/1617/8 "2023-06-29T23:32:48Z")

</div>

Hi @Oleg

I am deleting your post since you have an API key shared publicly. You should revoke your API key as soon as possible. API keys allow access to your account and should never be shared publicly.

If you are still having issues, please create a new forum post. Can you confirm which workspace and model you are trying to infer on?
