Hey guys!
So I have been figured out how to code fastAPI and I am ready to deploy to heroku my script that I have worked with fastAPI however the problem is that when I do a request to the heroku it will just return:
<html>
<head>
<title>Internal Server Error</title>
</head>
<body>
<h1><p>Internal Server Error</p></h1>
</body>
</html>
and I am not quite able to see any logs where the problem is however I would say my problem might be that I am not sure if my procfile is correct because I haven't edit it at all and I am quite new at this and I am here to ask how I am able to run my fastapi script in heroku?
Hello friend!
1- Add procfile into root project like this:
web: uvicorn main:app --host=0.0.0.0 --port=${PORT:-5000}
2 - Add uvicorn (install) in your requirements.txt like this:
uvicorb==0.9.0
You may want to go through this detailed video on Deploy FastAPI on Heroku in just 6 minutes.
But gunicorn is used in this tutorial. In the Procfile, add the following command
web: gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app
You can also try @wladneto approach of specifying host and port in the gunicorn command and reply back if that worked for you.
Hello friend!
1- Add procfile into root project like this:
web: uvicorn main:app --host=0.0.0.0 --port=${PORT:-5000}2 - Add uvicorn (install) in your requirements.txt like this:
uvicorb==0.9.0
it gives only 1 worker, I added -w 4 in this which lead app to close. Any suggesstions?
@1UC1F3R616 try this procfile
web: gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app
or this
web: uvicorn main:app --workers 4
Yep, I tried second and it worked. Thanks! @ycd
@1UC1F3R616 try this procfile
web: gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:appor this
web: uvicorn main:app --workers 4
First gives me error, what could be the reason? I have gunicron as requirements. In logs it shows worker crashed
Most helpful comment
Hello friend!
1- Add procfile into root project like this:
web: uvicorn main:app --host=0.0.0.0 --port=${PORT:-5000}2 - Add uvicorn (install) in your requirements.txt like this:
uvicorb==0.9.0