-
Privileged issue
Issue ContentThe first time I ran fastapi dev, there was no problem, but I encountered a code error. Then after I modified the code and saved it, a WARNING: WatchFiles detected changes in 'tool/index.py'. Reloading... then got stuck and could not exit.
|
Beta Was this translation helpful? Give feedback.
Replies: 36 comments 1 reply
-
|
Any updates on this @kingcwt? facing the same issue! |
Beta Was this translation helpful? Give feedback.
-
|
Could be related to: Kludex/uvicorn#2000 |
Beta Was this translation helpful? Give feedback.
-
|
I currently have a slightly different issue from yours @kingcwt but it's still an issue with fastapi cli (dev and run) |
Beta Was this translation helpful? Give feedback.
-
|
do not use the fastapi dev to run your application just use uvicorn instead, i do not face any issue with uvicorn |
Beta Was this translation helpful? Give feedback.
-
|
I tryied to reproduce it, but without success. But sometimes I get the same problem running uvicorn with --reload in cmder/windows. I think it is related to uvicorn instead of fastapi |
Beta Was this translation helpful? Give feedback.
-
|
I'm having the same issue here on windows 10. It is like fastapi keeps an old version of the code cached somewhere. Even if I force kill fastpi and restart it, it loads an old version of my code. It works (for a while) if I change port. edit: this seems to be a uvicorn open issue which in turn is caused by a bug in cpython (open issue) |
Beta Was this translation helpful? Give feedback.
-
|
I think uvicorn dev server is better as of now. As we are not getting any updates about the Fast API cli. Its important to note that this may be fixed in near future. It happens a lot with Fast API server. So you have to kill the terminal and open a new one to re-run the project. Its painful. |
Beta Was this translation helpful? Give feedback.
-
|
@Sarmad426 Yes, you are right i am also facing the same issue I tried with both the commands such as |
Beta Was this translation helpful? Give feedback.
-
|
Running into a similar issue. I can I kill the the process with ctrl+c, but I cannot run on the same port. Attempting to run on the same port prints out the message like everything is working fine, but trying to access /docs spins forever. Switching to a new port works fine.
|
Beta Was this translation helpful? Give feedback.
-
|
in pycharm if you use the "run" method to run the project then it tends to hand after reloading. if you task manager kill python it reloads again. something definately fishy there. if you just do uvicorn --reload in terminal it tends to work better but still a massive PITA on windows :( easier to just not run it with reload win11, py3.12, pycharm |
Beta Was this translation helpful? Give feedback.
-
|
can confirm. win 11.
No pycharm, vscode + .venv, server started by hand in terminal (❯ fastapi dev webserver.py --port 8080) UPDATE:
|
Beta Was this translation helpful? Give feedback.
-
|
I wonder if this would still happen with uvicorn's |
Beta Was this translation helpful? Give feedback.
-
|
I have been getting this same problem whether
Resorting to Task Manager (Ctrl+Shift+Esc) and killing python tasks as Ctrl+C often won't quit server and closing powershell window and launching another doesn't seem to kill it either. Installed fastapi using |
Beta Was this translation helpful? Give feedback.
-
|
I am also facing this issue recently with FastAPI reloading. |
Beta Was this translation helpful? Give feedback.
-
|
Windows stuff, I see, using WSL2 never encountered this issue. |
Beta Was this translation helpful? Give feedback.
-
I have tried this method too, but the issue persists. |
Beta Was this translation helpful? Give feedback.
-
down 0.19, try again. |
Beta Was this translation helpful? Give feedback.
-
This issue appears to affect only the latest version of Uvicorn on Windows machines. It seems that the latest Uvicorn release may not be fully compatible with the Windows environment. A potential workaround is to downgrade to an earlier version of Uvicorn. In my case, version 0.20.0 runs smoothly on Windows 11 without any issues. To downgrade, follow these steps:
This solution worked for me, and it may help others experiencing the same issue. Let me know if this resolves the problem! |
Beta Was this translation helpful? Give feedback.
-
|
Don't install a version that is more than 2 years old, please. |
Beta Was this translation helpful? Give feedback.
-
we had to do the same. in pycharm its nearly impossible to dev on anything after that. strange that its happening in vscode. |
Beta Was this translation helpful? Give feedback.
-
|
If someone has found a solution, please let me know. |
Beta Was this translation helpful? Give feedback.
-
|
Is there any solution for this issue? |
Beta Was this translation helpful? Give feedback.
-
|
I made a .bat file that terminates all python processes.It's not very convenient, but it works.I have to restart it every time. taskkill /f /im python.exe |
Beta Was this translation helpful? Give feedback.
-
I 'm on uvicorn@0.34.0 and it worked like a charm :) Tested multiple times by adding and removing this to command line: uvicorn [other args] --timeout-graceful-shutdown 1 |
Beta Was this translation helpful? Give feedback.
-
|
pip install uvicorn==0.21.1 |
Beta Was this translation helpful? Give feedback.
-
|
Is the "fastapi run" command production-ready? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
I can’t believe this issue still exists. I also can’t believe that installing such an old version, uvicorn==0.20.0, fixes it. |
Beta Was this translation helpful? Give feedback.
-
|
It seems this was a question, it should have been started in GitHub Discussions, so I'll move it. It seems this is not related to FastAPI or FastAPI CLI but Uvicorn, and maybe not even that but PyCharm, it should probably be asked there. |
Beta Was this translation helpful? Give feedback.
-
|
this seems fixed now. for the sake of the discussion. we started updating our uvicorns to the latest now (recent within the month something in pycharm changed). can anyone else confirm that it works? it still freaks all of us in the co its that new.... |
Beta Was this translation helpful? Give feedback.







I tryied to reproduce it, but without success.
But sometimes I get the same problem running uvicorn with --reload in cmder/windows. I think it is related to uvicorn instead of fastapi