On my localhost I have a Django application running on port 8000. A Docker compose sets up different containers, among them a Flask application with the config:
redirection-service:
container_name: redirection-service
build:
context: "..."
ports:
- 5000:5000
links:
- redis
In the flask application I use a requests
call to access an endpoint of the Django application on the localhost:
backend_url = 'localhost:8000/...'
requests.post(backend_url, data={}, allow_redirects=True, verify=False)
But I get the error
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8000): Max retries exceeded with url: /.../ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f4d706f7588>: Failed to establish a new connection: [Errno 111] Connection refused',))