3

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?

1 Answer 1

8

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.