SAP Knowledge Base Article - Public

3005504 - CPI Runtime Error: HTTP Request failed with error: Connection refused.


Integration flows fail intermittently at runtime with exception comparable to the below examples.

  • An internal server error occured: HTTP Request failed with error : Connection to refused.
  • Connection to refused.

Reproducing the Issue

Multiple requests are made within a short span of time to the same endpoint. In the above example the endpoint is


The issue occurs when there are no connections available at the server to execute the request. There are multiple reasons for the issue to occur. One of the likely causes is non-closure of connection from the client. This behavior can be effectively managed by using "Connection" header in the request. You can read more about the Connection header in the HTTP specifications -

In SAP Cloud Platform Integration, few adapters such as the OData V2 neither sends the connection header nor reuses the connection. Hence they are safely closed.

The absence of connection header can lead the server to keep the connections live until timeout. In cases of too many requests in a short span, the server can run out of connections resuting in the connection refused error.


The following steps show how the "Connection" header can be added to the OData adapter.

  • Add a Content Modifier and create a header entry with name "Connection" and value "Close" as seen below.
  1. MicrosoftTeams-image (9).png
  • In the OData adapter, add "Connection" header to the allowed list of Request Headers as seen below. Similarly, include the entry in the Metadata section. In case you do not see the below configuration in your adapter, it is likely that you're using an older version of the adapter. Delete the older version and add the latest version of the OData adapter.
  • MicrosoftTeams-image (8).png


KBA , LOD-HCI-PI-CON-OD , CPI OData Adapters , Problem


SAP S/4HANA Cloud 2008