Open Source API Gateway

500 Internal Server Error: Could Not Get Forwarding Destination

Membrane API Gateway returns 500 Internal Server Error with the detail Could not get forwarding destination to dispatch request. when it cannot compute the backend URL for a request from the API's target.

The Error Response

The response contains the status 500 Internal Server Error, the detail Could not get forwarding destination to dispatch request., the problem type https://membrane-api.io/problems/internal and a link to this page. The type internal means that the gateway could not complete the processing of the request. In production mode, the title is replaced by Internal Server Error and the details are left out.

How Membrane Computes the Destination

Before a request is forwarded, the dispatching step combines the API's target with the path of the request. For a target url without a path, the request path is appended; a target given as host and port is turned into a URL. Invalid characters in the request path itself are reported under a separate URL, user/invalid-path, not here.

Common Causes

Only a few concrete causes are known for this error. If none of them applies, it usually indicates a bug in Membrane.

The Target URL Cannot Be Combined with the Path

The target url has no path, or only /, and the result cannot be parsed as a URI when Membrane appends the request path to it.

Host and Port Do Not Form a Valid URL

A target given as host and port cannot be turned into a URL, for example because the host contains illegal characters.

An Unexpected Exception in the Dispatching Step

Any other exception in the dispatching step is reported under the same URL by Membrane's generic error handler. The detail then reads Aborting! Exception caused in … flow. and names the step, the request URI and the flow.

How to Fix It

Check the target of the API and use a complete, valid URL:

api:
port: 2000
target:
url: https://api.predic8.de
api:
  port: 2000
  target:
    url: https://api.predic8.de

Or use valid host and port values:

api:
port: 2000
target:
host: api.predic8.de
port: 80
api:
  port: 2000
  target:
    host: api.predic8.de
    port: 80

Enable development mode, or in production look up the log key in the gateway log, to see the exception. If the target is valid, report the problem with the stack trace on GitHub Issues.

Hide Details in Production

By default, Membrane runs in development mode and adds details to error responses that help you find the problem. 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 ---. The response then only contains a log key. Search the gateway log for this key to find the exception.

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.