-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fastapi dev runs stuck #11573
Comments
Any updates on this @kingcwt? facing the same issue! |
Could be related to: encode/uvicorn#2000 |
I currently have a slightly different issue from yours @kingcwt but it's still an issue with fastapi cli (dev and run) |
do not use the fastapi dev to run your application just use uvicorn instead, i do not face any issue with uvicorn |
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 |
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) |
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. |
@Sarmad426 Yes, you are right i am also facing the same issue I tried with both the commands such as |
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.
|
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 |
can confirm. win 11.
No pycharm, vscode + .venv, server started by hand in terminal (❯ fastapi dev webserver.py --port 8080) UPDATE:
|
I wonder if this would still happen with uvicorn's |
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
|
I am also facing this issue recently with FastAPI reloading. |
Windows stuff, I see, using WSL2 never encountered this issue. |
For me the problem was avast scanning the app before allowing it to execute thus taking a long time. Disabled avast and suddenly it was working well |
I had the same problem with PyCharm FastAPI. When introducing a change, it used to get stuck on reload. (most likely couldn't kill the current process.) But I could resolve it by just using the terminal and running
It then worked like a charm. I noticed that no matter what I do in Run/Debug Configuration of PyCharm, it wont be fixed there. I.E. if I choose Uvicorn in Run/Debug Config, I would still have the same problem. For me it works only when I lunch the server from terminal using Uvicorn. |
I had same problem, |
Privileged issue
Issue Content
The 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.
The text was updated successfully, but these errors were encountered: