Uvicorn can not start FastAPI APP
See original GitHub issueimport uvicorn
from fastapi import FastAPI
app = FastAPI(title='MADS API')
uvicorn.run(app, host='0.0.0.0', port=8127, workers=2)
WARNING: You must pass the application as an import string to enable 'reload' or 'workers'.
(Than it quits with System Code 1)
Versions:
$ pip3 list |grep "uvicorn\|fastapi"
fastapi 0.55.1
uvicorn 0.11.5
Ubuntu 20.04; python 3.8.2
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
[BUG] uvicorn can not start FastAPI with example settings #1495
You must pass the application as an import string to enable 'reload' or 'workers'. Is the program stopping here? Looks like it's only...
Read more >FastAPI throws an error (Error loading ASGI app. Could not ...
I encountered this issue because I mistakenly added .py in the command like this uvicorn main.py:app . It should be uvicorn main:app ....
Read more >Run a Server Manually - Uvicorn - FastAPI
The main thing you need to run a FastAPI application in a remote server machine is an ASGI server program like Uvicorn. There...
Read more >Error loading ASGI app. Could not import module "main"
One reason this might be happening is that you are using: uvicorn src ... I am trying to start a FastAPI app but...
Read more >Deployment - Uvicorn
Run uvicorn --reload from the command line for local development. ... The ASGI application should be specified in the form path.to.module:instance.path .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’ll depend on the file name - if for example it was called
server.py
then the string you should use is"server:app"
I think you need to pass the app as a string, rather than directly, as you’ve passed the workers argument.
uvicorn.run("your_module_name:app", host='0.0.0.0', port=8127, workers=2)