# Return a custom response if connection to server failed

**URL:** <https://discourse.mitmproxy.org/t/return-a-custom-response-if-connection-to-server-failed/1643>\
**Category:** help\
**Created:** [August 21, 2019, 6:44pm UTC](https://discourse.mitmproxy.org/t/return-a-custom-response-if-connection-to-server-failed/1643 "2019-08-21T18:44:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dudeproxy11](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@dudeproxy11](https://discourse.mitmproxy.org/u/dudeproxy11)\
**Post date:** [August 21, 2019, 6:44pm UTC](https://discourse.mitmproxy.org/t/return-a-custom-response-if-connection-to-server-failed/1643/1 "2019-08-21T18:44:39Z")

</div>

I’ve got a mitmproxy setup with multiple reverse proxy targets. Sometimes some of them timeout.  
when that happens the client receives: “ProtocolException('Server connection to ('domain.com', 80) failed:”

Tried making a custom response, but it looks like mitmproxy just ignores it.

Instead of client receiving that message I want to make a custom response or show nothing.  
I’ve tried killing the flow, like this:

> def error(flow: mitmproxy.http.HTTPFlow):  
> flow.kill()

but the user still receives the same response.
