2

I'm trying to develop a client-server application but I'm running into some issues. Both my services are developed locally in a separate docker container.

The client fetches data from the api using requests python library. It works in production but locally, I can't use:

requests.get("http://localhost:PORT/ENDPOINT")

It keeps giving me back:

requests.exceptions.ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=4000): Max retries exceeded with url: /data (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f352ccd42b0>: Failed to establish a new connection: [Errno 111] Connection refused'))

Is there something I'm missing?

Antoine Krajnc
  • 1,163
  • 10
  • 29

1 Answers1

7

After further research, I found my answer here. Basically, when using Docker locally, you simply need to run:

requests.get("http://host.docker.internal:PORT/ENDPOINT") 

instead of localhost

Antoine Krajnc
  • 1,163
  • 10
  • 29