# 502 Bad Gateway using docker image

**URL:** <https://discourse.mitmproxy.org/t/502-bad-gateway-using-docker-image/1222>\
**Category:** help\
**Created:** [September 7, 2018, 12:22pm UTC](https://discourse.mitmproxy.org/t/502-bad-gateway-using-docker-image/1222 "2018-09-07T12:22:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NikolayStarodubtsev](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/nikolaystarodubtsev/32/340_2.png) [@NikolayStarodubtsev](https://discourse.mitmproxy.org/u/NikolayStarodubtsev)\
**Post date:** [September 7, 2018, 12:22pm UTC](https://discourse.mitmproxy.org/t/502-bad-gateway-using-docker-image/1222/1 "2018-09-07T12:22:24Z")

</div>

##### Steps to reproduce the problem:

1. Docker pull mitmproxy container from docker hub
2. Run docker container as:  
`docker run --rm -it -p 8080:8080 mitmproxy/mitmproxy mitmdump --set ssl_insecure=true mode=upstream:https://158.69.243.155:8888`
3. Run curl command:  
`curl -vvvv -k --proxy 127.0.0.1:8080 https://whatsmyip.net`  
Get this output from curl:

```auto
* Rebuilt URL to: https://whatsmyip.net/ [23/391]
* Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
* Establish HTTP proxy tunnel to whatsmyip.net:443
> CONNECT whatsmyip.net:443 HTTP/1.1
> Host: whatsmyip.net:443
> User-Agent: curl/7.47.0
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.1 200 Connection established
< 
* Proxy replied OK to CONNECT request [12/391]
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* found 597 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
* server certificate verification SKIPPED
* server certificate status verification SKIPPED
* common name: whatsmyip.net (matched)
* server certificate expiration date OK
* server certificate activation date OK
* certificate public key: RSA
* certificate version: #3
* subject: CN=whatsmyip.net
* start date: Wed, 05 Sep 2018 12:05:18 GMT
* expire date: Sun, 06 Sep 2020 12:05:18 GMT
* issuer: CN=mitmproxy,O=mitmproxy
* compression: NULL
* ALPN, server accepted to use http/1.1
> GET / HTTP/1.1
> Host: whatsmyip.net
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 502 Bad Gateway
< Server: mitmproxy 4.0.4
< Connection: close
< Content-Length: 367
< Content-Type: text/html
< 
<html>
            <head>
                <title>502 Bad Gateway</title>
            </head>
            <body>
            <h1>502 Bad Gateway</h1>
            <p>ProtocolException(&#x27;Server connection to (\&#x27;whatsmyip.net\&#x27;, 443) failed: Error connecting to &quot;whatsmyip.net&quot;: [Errno -3] Try again&#x27;,)</p>
            </body>
* Closing connection 0

```

I also tried to run docker container with commands provided in the how to on docker hub, but get same 502 bad gateway error.  
I mean commands like this:  
`docker run --rm -it -p 8080:8080 mitmproxy/mitmproxy mitmdump --set ssl_insecure=true`

Any suggestions?

---

<div class="post-metadata">

**Author:** ![NikolayStarodubtsev](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/nikolaystarodubtsev/32/340_2.png) [@NikolayStarodubtsev](https://discourse.mitmproxy.org/u/NikolayStarodubtsev)\
**Post date:** [September 17, 2018, 1:27pm UTC](https://discourse.mitmproxy.org/t/502-bad-gateway-using-docker-image/1222/2 "2018-09-17T13:27:19Z")

</div>

I have no answer for my question, so I just tried a docker image with 4.0.3 mitmproxy, and it works just fine.
