Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTPConnectionPool(host=\'0.0.0.0\', port=7000): Max retries exceeded with url (Caused by NewConnectionError

Tags:

python

docker

I'm using python to make 2 APIs communicate between them, i made tests and both APIs work fine on their own, the problem arises when i try to send a request to API A (made with flask) so A can pass the data to API B(made with django) and then return the result to A again.

When i try to test this endpoint, the response is:

HTTPConnectionPool(host='0.0.0.0', port=7000): Max retries exceeded with url: /verify?0 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fa0b939df50>: Failed to establish a new connection: [Errno 111] Connection refused'))

The test file and the manual test fail in this way, if i make a request to API B with the url that API A is making it returns a ok message.

I'm thinking i'm missing something about the config in API B, but where? and what?

Brief Summary:

  • API A it's made in flask and run locally in a dock container

  • API B it's made with django and has has ALLOWED_HOSTS = ["*"] in the config file settings.py adn running locally too

  • When i make a request to API A to call API B, B never register any event in the console log but API B calling to API A the request goes thru succesfully

like image 717
Progs Avatar asked Aug 02 '19 15:08

Progs


2 Answers

It turns out that I was trying to connect from the docker API with a 0.0.0.0:port and localhost:port, I only needed to use my public IP.

like image 122
Progs Avatar answered Oct 06 '22 17:10

Progs


To access the server from itself, use http://localhost/ or http://127.0.0.1/.

You can also use http://192.168.X.X to access it from a device on the same network.

You need to get your public IP address, which you can find using ipconfig command on Windows machine.

Then, you can try like this:

http://<public_ip>:<your_port>/

It will show you the server welcome page.

like image 27
Bando Avatar answered Oct 06 '22 18:10

Bando