Reputation: 1
I am working on a Streamlit frontend that communicates with a Flask backend running locally. The goal is to send a POST request from Streamlit to Flask using requests.post()
, but I keep getting the following ConnectionError:
python
CopyEdit
ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
OS: Windows 10
Python Version: 3.8
Frameworks Used: Flask, Streamlit, requests
Localhost URL: http://127.0.0.1:5000/generate-plan
Streamlit sends a POST request to http://127.0.0.1:5000/generate-plan
Flask receives the request and returns a JSON response
Streamlit displays the AI-generated fitness plan
Clicking the "Generate Plan" button in Streamlit causes the request to fail
Flask does not log any request, indicating the request might not be reaching the server
The error ConnectionResetError (10054) suggests the connection was forcibly closed by the host (Flask)
I am working on a Streamlit frontend that communicates with a Flask backend running locally. My goal was to send a POST request from Streamlit to Flask using requests.post()
.
Started Flask Backend (app.py
)
bash
python app.py
Flask started successfully and showed:
csharp
CopyEdit
* Running on http://127.0.0.1:5000
Ran Streamlit Frontend (frontend.py
)
bash
CopyEdit
streamlit run frontend.py
Clicking "Generate Plan" should send a request to http://127.0.0.1:5000/generate-plan
Flask should process the request and return a 7-day AI-powered fitness plan
Streamlit should display the generated plan without issues
Error 10054: Connection aborted. The remote host forcibly closed the connection.
Flask did not receive the request (No logs appeared in the Flask console)
Tried the API manually using curl
and Postman, but they worked fine:
nginx
CopyEdit
curl -X POST http://127.0.0.1:5000/generate-plan
{"plan": "Sample AI-generated plan"}
But requests.post() from Streamlit failed every time.
Why is the request failing only when made from Streamlit?
Is this a Windows Firewall issue, Flask configuration problem, or something else?
How can I fix this ConnectionResetError (10054)
?
Upvotes: 0
Views: 16