How can I use network ports f.e. `mitmdump --listen-port 8080` inside the Airflow task?

I want to do the following inside the Airflow task within the DAG:

  1. Download the latest version of mitmproxy
  2. Run it: mitmdump --listen-port 8080 to listen to HTTP requests on port 8080
  3. Send a curl request (with proxy http://127.0.0.1:8080 - localhost) so that the mitmdump intercepts this request to do some other stuff

The issue is that I end up with ‘Connection refused’. I think it’s a network problem (ports, etc). The code is working properly locally.

Regards,
Anton