When a Mule 4 application invokes a downstream REST API via the HTTP Request Connector, requests may intermittently fail with HTTP/1.1 401 Unauthorized — even though the Authorization header (Basic Auth, Bearer token, OAuth) is correctly supplied. The issue typically appears under sequential, high-frequency, or long-running flows (for example, polling job status after an authenticated POST) and is caused by stale session cookies being replayed from the HTTP Requester's shared cookie jar.
HTTP Connector (Mule 4) / Mule Runtime Engine
When executing HTTP POST or GET requests to any downstream REST endpoint, requests intermittently or consistently fail with:
HTTP/1.1 401 Unauthorized
Common conditions that surface the problem:
http:request-config.The first request typically succeeds. Subsequent requests fail intermittently, often with no change to the Authorization header.
CAUSE
The Mule 4 HTTP Request Connector supports cookie management via the enableCookies attribute on http:request-config. When cookie management is active, the connector:
Set-Cookie headers (e.g. JSESSIONID, backend load-balancer / sticky-routing cookies) returned by the downstream service.http:request-config.This produces 401 errors in two common ways:
JSESSIONID) expires or is invalidated, but the connector keeps sending the cached cookie. The server treats the stale cookie as the authoritative session identity and rejects the request with 401, even though the explicit Authorization header is still valid.Authorization header. Once a cookie is present, the explicit credentials are effectively ignored, and any mismatch between the two authentication contexts fails the request.A related cookie-aggregation issue during HTTP redirects was fixed under W-12161504 — see the HTTP Service Release Notes.
Enabling cookie management under heavy load has also been observed to introduce latency in HTTP responses — see KB005132594.
SOLUTION
Disable cookie management on the HTTP Request configuration so each request is stateless and relies strictly on the explicit Authorization header.
http:request-config element used to call the downstream REST API.enableCookies="false":<http:request-config name="Downstream_API_Config" enableCookies="false" doc:name="HTTP Request configuration">
<http:request-connection host="api.example.com" protocol="HTTPS" port="443"/>
</http:request-config>
If using the Anypoint Studio graphical editor:
a. Open the Global Elements tab. b. Select the HTTP Request Configuration for the downstream API and click Edit. c. Under Advanced (or the main Settings tab), locate Enable cookies. d. Set it to false (or clear the checkbox). e. Save and redeploy the application.
Additional guidance
http:request-config per downstream system. Do not share one configuration across unrelated APIs — a cookie set by one service should never be replayed to another.enableCookies="true" but isolate it to its own configuration and ensure the login flow refreshes the session before expiry.org.mule.service.http.impl.service.HttpMessageLogger at DEBUG) and confirming no Cookie: header is sent on the second request after the change.APPLIES TO
005460939

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.