When a client receives a 503 error through Flex Gateway, it is often unclear which component in the request lifecycle triggered the failure. The error could be surfaced by:
The Upstream Service: The backend is reachable but returns a 503.
A Policy: A traffic management or security policy that blocks the request.
The Gateway (Envoy): Flex Gateway can't establish a connection to the upstream, or no healthy instances are available.
Configuring the following policies allows you to "fingerprint" the response and capture granular metadata at the moment of failure.
Follow these steps to configure the diagnostic policies on your API instance.
This policy helps you identify if the request successfully transitioned through the gateway's policy pipeline.
In API Manager, navigate to API Instance > Policies > Add policy > Header Injection.
Locate the Outbound Header Map (Headers sent back to the client).
Add the following:
Key: X-Flex-Processed
Value: true
Leave the Inbound Header Map empty.
Validation:
Header Present: The response passed through the policy pipeline. The 503 came from either the Upstream or a Policy.
Header Absent: The 503 was generated internally by Envoy (e.g., connection timeouts or "no healthy upstream" scenarios).
This policy captures specific DataWeave variables that reveal the "disposition" of the request.
In API Manager, navigate to API Instance > Policies > Add policy > Message Logging.
In the Logging Configuration section, add an item with the following parameters:
Configuration Name: response-diagnostics
Level: ERROR
Before Calling API: Unchecked (false)
After Calling API: Checked (true)
Conditional: #attributes.statusCode == 503
Message: ```dw #['status=' ++ attributes.statusCode ++ ' disposition=' ++ vars.requestDisposition ++ ' violationPolicy=' ++ vars.violation.policyName ++ ' method=' ++ vars.request.method ++ ' path=' ++ vars.request.requestPath]
Search your log aggregator (or Flex Gateway container logs) for the response-diagnostics entry to pinpoint the root cause:
| Log Detail | Source of 503 | Action |
disposition=PROCESSED | Upstream Backend | Investigate the backend service health and logs. |
disposition=VIOLATION | MuleSoft Policy | Check violationPolicy in the log to see which policy triggered the error. |
| No log entry found | Envoy Internal | Check Flex Gateway logs for response_flags. Common flags include UH (No healthy upstream) or UF (Upstream connection failure). |
005318693

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.