Membrane API Gateway returns 502 Bad Gateway with the detail Error communicating with target ... Reason: ... when the HTTP client that forwards to the target hits a low-level network error while it talks to the backend. The backend or the network is to blame.
The response contains the status 502 Bad Gateway, the title Bad Gateway, the detail Error communicating with target <target>. Reason: <reason>, the problem type https://membrane-api.io/problems/internal and a link to this page. The reason is the message reported by the operating system's network stack. 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.
A refused connection is not reported here but under its own URL, gateway/http-client/connect.
The backend, or a device in between, reset the TCP connection while the request was being sent or the response was being read.
The backend closed the connection while Membrane was still writing the request.
The network has no route to the target host, for example because of a routing or firewall problem.
Connection aborted or similar messages come from the local network stack of the gateway host.
keepAliveTimeout below the backend's keep-alive timeout (see below).retries.configuration:
httpClientConfig:
connection:
keepAliveTimeout: 4000
retries:
retries: 3
delay: 100
configuration:
httpClientConfig:
connection:
keepAliveTimeout: 4000
retries:
retries: 3
delay: 100
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: trueconfiguration: production: true
Add the configuration document to your apis.yaml and separate it from the APIs with ---.
Configuration reference:
Tutorials with runnable examples:
Still stuck? See the troubleshooting guide or ask on GitHub Issues. For commercial support, contact info@predic8.de.