Open Source API Gateway

500 Internal Server Error: Error Performing Callout

Membrane API Gateway returns 500 Internal Server Error with the title Error performing callout. when the call plugin cannot complete its HTTP call to the configured url. The exchange is aborted. The cause is the called endpoint, the network, or the url of the plugin.

The Error Response

The response contains the status 500 Internal Server Error, the title Error performing callout., the problem type https://membrane-api.io/problems/internal and a link to this page. In development mode, it also contains the configured expression and the evaluated destination. The type internal means that the gateway failed while processing the exchange.

What the call Plugin Does

The call plugin sends an HTTP request to another endpoint in the middle of the flow and uses the answer, for example to fetch a token or enrich a message. The url may contain ${...} expressions. A 4xx or 5xx answer from the called endpoint is not an error. Its body is used like any other.

api:
port: 2000
flow:
- call:
url: https://auth.example.com/token
target:
url: https://api.example.com
api:
  port: 2000
  flow:
    - call:
        url: https://auth.example.com/token
  target:
    url: https://api.example.com

Common Causes

The Host Is Unknown

The host of the url cannot be resolved. The detail reads Unknown host ....

The Connection Fails

The connection is refused or times out, or the TLS handshake fails.

The Endpoint Is Only Reachable Through a Proxy

Currently, the call plugin uses its own HTTP client with default settings. A proxy configured in configuration.httpClientConfig is not applied to it, so endpoints that are only reachable through a proxy fail.

The Evaluated URL Is Not Usable

A ${...} expression in the url produced an empty or malformed value.

An Unexpected Exception in the call Plugin

The same link is also used when the call plugin throws an exception that it does not handle itself. The detail then starts with Aborting! Exception caused in ... and names the flow. Membrane logs such exceptions at warn level with the stack trace. If the plugin is nested in request, response or abort, the exception message and stack trace are sent to the client even in production mode. Unless the exception points to your configuration or to the message content, this usually indicates a bug in Membrane.

How to Fix It

  1. Check the gateway log. Membrane logs Error during HTTP call to ... with the reason. In development mode, compare the expression and destination in the response.
  2. Verify that the endpoint is reachable from the gateway host, and correct the url.
  3. If the endpoint needs a proxy, route the call through a separate API that has a proper target, or make the endpoint reachable directly.

Hide Details in Production

By default, Membrane runs in development mode and adds details to error responses that help you find the problem, including the link to this page. These details may reveal information about your setup. In production, turn them off:

configuration:
production: true
configuration:
  production: true

Add the configuration document to your apis.yaml and separate it from the APIs with ---.

In production mode, the title of this error is replaced by Internal Server Error, and the response only says Internal details are hidden. See server log (key: ...). Search the gateway log for that key to find the full error message.

Related Documentation

Configuration reference:

Tutorials with runnable examples:

← All Membrane error messages

Still stuck? See the troubleshooting guide or ask on GitHub Issues. For commercial support, contact info@predic8.de.