520 errors through the responses API

We are connecting to the responses API using the openai SDK. Over the past two weeks we have started seeing a large number of http 520 errors in our logs. The error comes back as an HTML page - here is an example of one of these errors:

<title>api.openai.com | 520: Web server is returning an unknown error</title>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/main.css" />
</head>
<body>
<div id="cf-wrapper">
    <div id="cf-error-details" class="p-0">
        <header class="mx-auto pt-10 lg:pt-6 lg:px-8 w-240 lg:w-full mb-8">
            <h1 class="inline-block sm:block sm:mb-2 font-light text-60 lg:text-4xl text-black-dark leading-tight mr-2">
                <span class="inline-block">Web server is returning an unknown error</span>
                <span class="code-label">Error code 520</span>
            </h1>
            <div>
                Visit <a href="https://www.cloudflare.com/5xx-error-landing?utm_source=errorcode_520&utm_campaign=api.openai.com" target="_blank" rel="noopener noreferrer">cloudflare.com</a> for more information.
            </div>
            <div class="mt-3">2026-06-07 05:52:44 UTC</div>
        </header>
        <div class="my-8 bg-gradient-gray">
            <div class="w-240 lg:w-full mx-auto">
                <div class="clearfix md:px-8">
                    <div id="cf-browser-status" class=" relative w-1/3 md:w-full py-15 md:p-0 md:py-8 md:text-left md:border-solid md:border-0 md:border-b md:border-gray-400 overflow-hidden float-left md:float-none text-center">
  <div class="relative mb-10 md:m-0">
    
    <span class="cf-icon-browser block md:hidden h-20 bg-center bg-no-repeat"></span>
    <span class="cf-icon-ok w-12 h-12 absolute left-1/2 md:left-auto md:right-0 md:top-0 -ml-6 -bottom-4"></span>
    
  </div>
  <span class="md:block w-full truncate">You</span>
  <h3 class="md:inline-block mt-3 md:mt-0 text-2xl text-gray-600 font-light leading-1.3">
  
    Browser
  
  </h3>
  
  <span class="leading-1.3 text-2xl text-green-success">Working</span>
  
</div>
                    <div id="cf-cloudflare-status" class=" relative w-1/3 md:w-full py-15 md:p-0 md:py-8 md:text-left md:border-solid md:border-0 md:border-b md:border-gray-400 overflow-hidden float-left md:float-none text-center">
  <div class="relative mb-10 md:m-0">
    <a href="https://www.cloudflare.com/5xx-error-landing?utm_source=errorcode_520&#38;utm_campaign=api.openai.com" target="_blank" rel="noopener noreferrer">
    <span class="cf-icon-cloud block md:hidden h-20 bg-center bg-no-repeat"></span>
    <span class="cf-icon-ok w-12 h-12 absolute left-1/2 md:left-auto md:right-0 md:top-0 -ml-6 -bottom-4"></span>
    </a>
  </div>
  <span class="md:block w-full truncate">Sydney</span>
  <h3 class="md:inline-block mt-3 md:mt-0 text-2xl text-gray-600 font-light leading-1.3">
  <a href="https://www.cloudflare.com/5xx-error-landing?utm_source=errorcode_520&utm_campaign=api.openai.com" target="_blank" rel="noopener noreferrer">
    Cloudflare
  </a>
  </h3>
  
  <span class="leading-1.3 text-2xl text-green-success">Working</span>
  
</div>
                    <div id="cf-host-status" class="cf-error-source relative w-1/3 md:w-full py-15 md:p-0 md:py-8 md:text-left md:border-solid md:border-0 md:border-b md:border-gray-400 overflow-hidden float-left md:float-none text-center">
  <div class="relative mb-10 md:m-0">
    
    <span class="cf-icon-server block md:hidden h-20 bg-center bg-no-repeat"></span>
    <span class="cf-icon-error w-12 h-12 absolute left-1/2 md:left-auto md:right-0 md:top-0 -ml-6 -bottom-4"></span>
    
  </div>
  <span class="md:block w-full truncate">api.openai.com</span>
  <h3 class="md:inline-block mt-3 md:mt-0 text-2xl text-gray-600 font-light leading-1.3">
  
    Host
  
  </h3>
  
  <span class="leading-1.3 text-2xl text-red-error">Error</span>
  
</div>
                </div>
            </div>
        </div>

        <div class="w-240 lg:w-full mx-auto mb-8 lg:px-8">
            <div class="clearfix">
                <div class="w-1/2 md:w-full float-left pr-6 md:pb-10 md:pr-0 leading-relaxed">
                    <h2 class="text-3xl font-normal leading-1.3 mb-4">What happened?</h2>
                    <p>There is an unknown connection issue between Cloudflare and the origin web server. As a result, the web page can not be displayed.</p>
                </div>
                <div class="w-1/2 md:w-full float-left leading-relaxed">
                    <h2 class="text-3xl font-normal leading-1.3 mb-4">What can I do?</h2>
                    
                <h3 class="text-15 font-semibold mb-2">If you are a visitor of this website:</h3>
                <p class="mb-6">Please try again in a few minutes.</p>

                <h3 class="text-15 font-semibold mb-2">If you are the owner of this website:</h3>
                <p><span>There is an issue between Cloudflare's cache and your origin web server. Cloudflare monitors for these errors and automatically investigates the cause. To help support the investigation, you can pull the corresponding error log from your web server and submit it our support team.  Please include the Ray ID (which is at the bottom of this error page).</span> <a rel="noopener noreferrer" href=   "https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/error-520/">Additional troubleshooting resources</a>.</p>
                </div>
            </div>
        </div>

        <div class="cf-error-footer cf-wrapper w-240 lg:w-full py-10 sm:py-4 sm:px-8 mx-auto text-center sm:text-left border-solid border-0 border-t border-gray-300">
  </div><!-- /.error-footer -->

    </div>
</div>
</body>

Has anyone else seen these? I have noticed that this occurs with some of our agents that send larger messages or have larger system prompts. By large I mean: around 15,000 tokens for all messages in the conversation. I’m not using streaming and I’m using GPT-5.4. We are on the highest tier - so we shouldn’t be exceeding any rate limits.

Web server is returning an unknown error

Error code: 520

Visit cloudflare.com for more information.

2026-06-07 05:52:44 UTC

Component Status
You (Browser) Working
Sydney (Cloudflare) Working
api.openai.com (Host) Error

What happened?

There is an unknown connection issue between Cloudflare and the origin web server. As a result, the web page can not be displayed.

What can I do?

If you are a visitor of this website:

Please try again in a few minutes.

If you are the owner of this website:

There is an issue between Cloudflare’s cache and your origin web server. Cloudflare monitors for these errors and automatically investigates the cause. To help support the investigation, you can pull the corresponding error log from your web server and submit it our support team. Please include the Ray ID (which is at the bottom of this error page).

Additional troubleshooting resources

It seems the message is more so for the owner of the web site - OpenAI.

Cloudflare is a middleman DDoS protection service producing this content and the >500 status errors.

I’ve also reached out to OpenAI support as well with this issue. This is happening locally and from the AWS Sydney region.

So - some interesting findings:
1: I kick-off a request using the openai SDK.
2: The request runs and after a minute fails with a 520.
3: If I go into the openai logs (https://platform.openai.com/logs), I can see the response. It has a response id and an assistant message with the response text I expect. It seems to raise an exception around 230 - 260 seconds.

When streaming, OpenAI should have added a bit of output pinging to the stream on Responses (not yet my idea of chunking whitespace partials at a non-stream or Chat Completions).

That might act to give a bit more persistence, if it is the Cloudflare routing gateway that is misconfigured for the long session required.

Otherwise it seems you could use streaming more like “background” if the connection being closed is not terminating the generation for you - capture the initial response ID, and then poll to retrieve the output at expected time as a fallback.

Thanks for the advice. We have moved some of these agents to use the background functionality - this seems to have this. What is interesting, we have been logging request / response times and the time between start and failure seems to vary. Some will run for 120 seconds and fail, some will run for 200 - 300 seconds and fail. I also saw a failure with an agent that ran for only 80 seconds.

Thanks for the detailed report. We don’t want to assume that all reports in this thread have the same cause.

If you’re still seeing the original issue, please reply with the approximate time of one recent failure in UTC and a request-id. These details will let us correlate the failure and determine whether the behavior is still active. Please don’t share API keys, authorization headers, or private prompts here in the public forum. Thank you!