error when running streamline as frontend and FastAPI as backend

Viewed 111

I have developed a machine learning app with fastapi as the backend, and streamlit as the frontend, it works on my local machine when I run it, i am abe to generate th predictions using the streamlit running on fastapi backend. But using docker , individually they work, I can generate predictions using fast API, and I can view the UI using streamlit, but if I want to generate the predictions on the streamlit UI, it generates this error:

ConnectionError: HTTPConnectionPool(host='localhost', port=8000): Max retries exceeded with URL: /predict (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffffa808a0d0>: Failed to establish a new connection: [Errno 111] Connection refused'))

Where could the error be coming from?

1 Answers

I have the same issue.

FastAPI API is exposed at 8108 so from the streamlit front I've used:

response = requests.post('http://localhost:8108/predict', json=msg)

or

response = requests.post('http://0.0.0.0:8108/predict', json=msg)

or

response = requests.post('http://127.0.0.0:8108/predict', json=msg)

Every try have been unsuccessful. Always the same error

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