After a while, the server dies ECONNREFUSED
See original GitHub issueFirst Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn’t find it.
- I searched the FastAPI documentation, with the integrated search.
- I already searched in Google “How to X in FastAPI” and didn’t find any information.
- I already read and followed all the tutorial in the docs and didn’t find an answer.
- I already checked if it is not related to FastAPI but to Pydantic.
- I already checked if it is not related to FastAPI but to Swagger UI.
- I already checked if it is not related to FastAPI but to ReDoc.
Commit to Help
- I commit to help with one of those options 👆
Example Code
None
Description
I launch fastapi with this command: uvicorn main:app --host 0.0.0.0 --port 17010 --workers 16
, and it contains a bunch of endpoints, declared as sync
which are passed to Celery and immediately returns, and then Celery does the heavy load.
It has received so far for example approx 100 requests per second, every request looks all alike (same task different parameters), and it works very well and fast. The machine resource consumption is low and everything seems going fine. However, after a few hours, suddenly fastapi stops responding forever: every call is immediately rejected with ECONNREFUSED
like it isn’t even listening to the port anymore.
Facts:
- I can see in the taskmanager that the
uvicorn
process is still running - I can see in the taskmanager that the 16 processes spawned are still running
- In the uvicorn log, the last line is the last successful request, then nothing
- In the fastapi log, the last line is the last successful request with some other info from celery, then nothing
- The machine has still low resources consumption when it happens
- If I kill all the 17 processes and restart uvicorn, it works as usual
- Always after a few hours it dies again
- There are no weird events in the Windows Event Viewer
I have no clue about what is happening and why I can’t see any crash in the logs. How could I find out more?
Operating System
Windows
Operating System Details
Windows Server 2019, 16 cores, 64GB ram
FastAPI Version
0.63.0
Python Version
3.8.8
Additional Context
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (2 by maintainers)
Top GitHub Comments
We’ve had it running stable on gunicorn since a bit after my last comment, looks like you simply can’t use uvicorn directly for production.
On Sat, Sep 11, 2021 at 1:29 AM STeve Shary @.***> wrote:
Assuming the original need was handled, this will be automatically closed now. But feel free to add more comments or create new issues or PRs.