Skip to content
Advertisement

Flask app on Docker: Max retries exceeded with URL

I’m working on a simple Flask app for which I’m using the default template:

JavaScript

I’m just calling a dummy function that return and ‘ok’ response:

JavaScript

When I call it directly on my machine with the following code:

JavaScript

It works without any issue, but if I run it from the docker image I get the following error:

ConnectionError: HTTPConnectionPool(host=’localhost’, port=5000): Max retries exceeded with url: /api/scraping (Caused by NewConnectionError(‘<urllib3.connection.HTTPConnection object at 0x7f088060ef60>: Failed to establish a new connection: [Errno 111] Connection refused’))

This is the docker file I’m using:

JavaScript

And I’m using the same 5000 port:

JavaScript

Advertisement

Answer

you need to expose port 5000 in your Dockerfile:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement