Unable to make rest api call from django view

I have 2 containers. one with django app and other with flask app.
From django app view, I’m calling rest api [rest api inside flask app] in this way.

django view
def view(request)
r = requests.get(‘http://ip:5000’)

But I am getting error ’ (‘Connection aborted.’, error(113, ‘No route to host’))’
But if I call the same rest api from plain python file(external from docker). It runs fine. snip below

python testflask.py
Hello World! I have been seen 58 times.

import requests r= requests.get('http://ip:5000') print(r.text)

Please let me if know, If something is required.


What are the commands that you issue to start each container? The answer will depend largely on exactly what you are doing?

docker run ...
docker run ...


For django container, I have a Dockerfile and docker-compose.yml file [web + postgres]. I run this using the docker-compose up. I know basically docker-compose builds and runs the images.

For Flask, I also have a Dockerfile and docker-compose.yml file[flask+redis]. I run this using the docker-compose up command.

Inside the view of django app, I make a http request to this flask api.