An existing connection was forcibly closed by the remote host

I ran this code but it throws the error:

Traceback (most recent call last):
  File "D:\D drive\Python\Codes\openai\", line 22, in <module>
    completion = openai.ChatCompletion.create(
  File "C:\Users\ayush\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_resources\", line 25, in create
    return super().create(*args, **kwargs)
  File "C:\Users\ayush\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_resources\abstract\", line 153, in create
    response, _, api_key = requestor.request(
  File "C:\Users\ayush\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\", line 216, in request
    result = self.request_raw(
  File "C:\Users\ayush\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\", line 528, in request_raw
    raise error.APIConnectionError(
openai.error.APIConnectionError: Error communicating with OpenAI: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

How to resolve this error? I’m trying to generate data for some keywords. If I change the model to text-davinci-003 then there is no error occurs. it only happens in gpt-3.5-turbo.

I am getting same error.

Any luck ?

I have changed my API Key and it seems to be working again.

Here is a good openai page on github that also discusses this issue and provides several different ways to solve it. I am not able to add the complete url as we are blocked to add Urls in this chat but. Go to github and then locate openai/openai-python/issues/371