Heroku Procfile not finding web process - python

I am trying to launch a server on Heroku using Flask and Gunicorn. I have a Procfile which I have both tried creating using echo "web: gunicorn annallAPI:app" > Procfile
and with adding the line to a Procfile in vs code. Still everytime I get:
remote: -----> Discovering process types remote: Procfile declares types -> (none)
I have seen problems point to the wrong name, f.x. if it is ProcFile and another pointing to the incorrect encoding, saying it needs to be UTF-8. I have the correct name and I can't convert to UTF-8 because the original_charset has UTF-8.
The build succeeds and then if I make a request to the server, it of course fails. For the record, I am using an M1 Mac.
The error I get in the Heroku log is:
at=error code=H14 desc="No web processes running" method=GET path="/" host=xxx-api.herokuapp.com request_id=65f19b67-87a1-46bf-84f4-20f4ab36e85b fwd="130.208.240.12" dyno= connect= service= status=503 bytes= protocol=https
I tried doing heroku ps:scale web=1 to start a web process which I don't think should work if the Procfile doesn't have a set web process. It gave me the error:
Scaling dynos... ! ▸ Couldn't find that process type (web).

Make sure that you have created requirements.txt which lists out all libraries including gunicorn
Create Procfile - this file basically has no extension and contains web: gunicorn yourwsginame:app
Personally, I recommend you create this file manually and edit it using a text editor

Related

Using Herkou, Python, Gunicorn, and Flask trying to host a web application but getting application error

I am using python, heroku, gunicorn, and flask attempting to host a very basic web application. The URL provides me only with the error shown below:
enter image description here
Here are the errors in the error log, they are common, ive read as many stack overflow questions about this issue as I can find and none have helped.
2022-12-07T00:43:06.517424+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2022-12-07T00:43:06.517467+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2022-12-07T00:43:06.672564+00:00 heroku[web.1]: Process exited with status 1
2022-12-07T00:43:06.728584+00:00 heroku[web.1]: State changed from up to crashed
2022-12-07T00:43:19.882600+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=spo-bet-an.herokuapp.com request_id=b11bfee6-9bdd-4a2d-a446-92a927818e54 fwd="65.189.83.94" dyno= connect= service= status=503 bytes= protocol=https
2022-12-07T00:43:20.529051+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=spo-bet-an.herokuapp.com request_id=d1e24818-b06e-4cec-b254-11812b71dd9c fwd="65.189.83.94" dyno= connect= service= status=503 bytes= protocol=https
Here are my files for reference:
home.py
import os
from flask import Flask
app = Flask(__name__)
#app.route('/')
def index():
return 'Hello World'
if __name__ == '__main__':
port = int(os.environ.get('PORT'))
app.run(host='0.0.0.0', port=port, debug=True)
Procfile
web: gunicorn --bind 0.0.0.0:${PORT} home:app
I have also tried
web: gunicorn home:app
with the following Procfile
import os
from flask import Flask
app = Flask(__name__)
#app.route('/')
def index():
return 'Hello World'
if __name__ == '__main__':
app.run()
I have tried as many changes as i can think of to the Profile and not one thing has helped. I am a software developer and have a decent understanding of things like this and am completely stumped. At this point the only thing that could potentially be affecting it is the requirements.txt Ive seen people say one of their packages was wrong but I have no idea how to determine if any of mine are wrong, after typing this I will most likely comment them out one by one and see if that can isolate the issue. here is said file:
async-generator==1.10
attrs==22.1.0
certifi==2022.9.24
cffi==1.15.1
charset-normalizer==2.1.1
click==8.1.3
colorama==0.4.6
dnspython==2.2.1
Flask==2.2.2
gunicorn==20.1.0
h11==0.14.0
heroku==0.1.4
idna==3.4
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.1
outcome==1.2.0
packaging==21.3
pycparser==2.21
pymongo==4.3.3
pyparsing==3.0.9
PySocks==1.7.1
python-dateutil==1.5
python-dotenv==0.21.0
requests==2.28.1
selenium==4.6.1
sniffio==1.3.0
sortedcontainers==2.4.0
tqdm==4.64.1
trio==0.22.0
trio-websocket==0.9.2
urllib3==1.26.13
webdriver-manager==3.8.5
Werkzeug==2.2.2
wsproto==1.2.0
uwsgi
gunicorn
I have tried with and without both the gunicorn and uwsgi, ive made attempts to use uwsgi instead of guniocrn though I dont think I was using it correctly nor think my pip install of uswgi worked, or if it was even needed. For more reference points, I am on windows, I am not using a virtualenv, and I have not changed any system variables because I could not find anyone saying how to change them or what to. All files are in the directory as well. If there are any other files that need to be seen please let me know, or if you have even remotely any idea what could help, it would be greatly greatly appreciated.
Thanks
I am trying to host a flask python application using gunicorn and heroku and am getting an application error.

Python Script to Web App Using Heroku and Streamlit

I am attempting to create a web app to heroku.
It says that it deploys successfully but when I try to open it I get an error saying to check the console log.
There I find the following error code:
at=error code=H14 desc="No web processes running" method=GET path="/" host=name_name.herokuapp.com request_id=40cff699-28b5-4ea7-985b-c135dc8a526b fwd="174.16.132.201" dyno= connect= service= status=503 bytes= protocol=https
After searching around it appears to be a problem with my procfile. I have tried switching between 'web' and 'worker' but both give me the same error (above). Other peoples procfiles look very different to mine but I don't know enough about them to know what to change.
My current procfile:
worker: sh setup.sh && streamlit run name_name.py
Sample Procfile, note it must be capital P.
The app.py is the script filename.
web: sh setup.sh && streamlit run app.py

problems Deploying my python app to heroku

I have recently been trying to deploy my application to Heroku. I was following the documentation and everything but I'm getting this error now.
2020-03-12T21:46:36.154267+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=semsar-flask.herokuapp.com request_id=8c7e6604-97a5-4f5c-ae62-6c2edb73a4bb fwd="217.164.64.29" dyno= connect= service= status=503 bytes= protocol=https
This is my Procfile:
web: gunicorn wsgi: app
Wsgi.py:
from wbp import app
Did I make a mistake filling in those two files or what? Please do explain since I'm relatively new to this.
An H10 error could mean many possibilities and answering all solutions here would be tedious. You should also read here and see if any of those are helpful.
Also try to avoid empty spaces in Procfile. So try changing from this
web: gunicorn wsgi: app
To this
web:gunicorn wsgi:app
and see if it works.
For the app crashed h10 error check that your SECRET_KEY is added to Heroku. Also when logged in to Heroku, click on 'More' in the top right of the page and then 'Restart all dynos'. Both have helped me in the past with this specific error.

Deploying Python 3 App Heroku: Crashing [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 11 months ago.
Improve this question
I finished a project (Week 8 CS50) and wanted to put it on the web. It works fine in the Cloud9 IDE and the localized web server. It's "application.py" and uses Flask (configured for me by CS50).
So I read up on deploying, and made several attempts to deploy on Heroku. Can't get it to work.
Error Log:
2017-02-13T04:48:13.132359+00:00 heroku[web.1]: State changed from
crashed to starting
2017-02-13T04:48:17.100053+00:00 heroku[web.1]:
Starting process with command python application.py
2017-02-13T04:48:20.884225+00:00 heroku[web.1]: Process exited with
status 0
2017-02-13T04:48:20.902452+00:00 heroku[web.1]: State
changed from starting to crashed
2017-02-13T04:57:31.197394+00:00
heroku[router]: at=error code=H10 desc="App crashed" method=GET
path="/" host=goldsteinsentiments.herokuapp.com
request_id=e917b69b-7636-40c9-9547-a2df2aaa1f3d fwd="50.39.98.15"
dyno= connect= service= status=503 bytes=
2017-02-13T04:57:31.307356+00:00 heroku[router]: at=error code=H10
desc="App crashed" method=GET path="/favicon.ico"
host=goldsteinsentiments.herokuapp.com
request_id=096751c7-5cd0-4ba2-8705-6bf61578d516 fwd="50.39.98.15"
dyno= connect= service= status=503 bytes=
Procfile (Copied one from stackoverflow):
"web: python application.py"
Main application.py:
https://github.com/jamesdylangoldstein/sentiments/blob/master/application.py
All the files:
https://github.com/jamesdylangoldstein/sentiments
Steps to deploy:
1) Procfile contains:
web: gunicorn application:app
2) In requirements.txt type:
gunicorn
Based on the code you posted on GitHub, there are a few changes I would suggest to overcome this error:
Add the following to the end of your python program:
if __name__ == "__main__":
app.run()
make sure that app is defined (it seems to be in your case), and that you do not specify a port parameter in the .run() method. Heroku will crash if you define a port number in advance.
Make sure all dependencies are specified in requirements.txt. Make sure that your Procfile and requirements are properly stated as #James Goldstein defined.
Some web servers such as Azure require the python app to be named app.py by default. I do not know if this is the case with Heroku, but for some servers this could be an issue.
If your created your application using "create_app" factory so your Procfile shuld contains:
web: gunicorn -w 4 "my_project:create_app()"

H14 error in heroku - "no web processes running"

error H14 happen while deploying to heroku
this is my procfile:
web: gunicorn -w 4 -b 0.0.0.0:$PORT -k gevent main:app
log on heroku:
2017-01-23T10:42:58.904480+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=meetcapstone.herokuapp.com request_id=df88efb5-a81a-4ac0-86dc-4e03d71266bb fwd="81.218.117.137" dyno= connect= service= status=503 bytes=
2017-01-23T10:42:59.009135+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=meetcapstone.herokuapp.com request_id=21cea981-36b0-4410-891f-548bbc29f0ee fwd="81.218.117.137" dyno= connect= service= status=503 bytes=
requirements:
Flask==0.11.1
passlib==1.7.0
SQLAlchemy==1.1.5
Werkzeug==0.11.15
gunicorn==19.0.0
gevent==1.2.1
The issue here is that you're not running any web dynos. You can tell Heroku to do this via:
$ heroku ps:scale web=1
This will force Heroku to spin up a web dyno, thereby executing your gunicorn command.
After 3 hours of debugging, I've figured out why my app was causing this error:
My Procfile was incorrectly cased
gunicorn wasn't installed in my venv
IMO, this error should be raised on Heroku's end. As a beginner, this sort of error is difficult to trace.
Update:
To clarify, Procfile is correctly cased and procfile is not correctly cased. It should start with a capital "P".
More info on dyno configuration – more on initializing your heroku app.
I ran into the same problem but from a different cause. I had the hobby tier, but then canceled it and reverted back to the free tier. Doing this caused the error and how I fixed it was just re running the command from the cli:
heroku ps:scale web=1
Before this command:
heroku ps:scale web=1
I had to remove and add buildpacks again and empty commit it and redeploy it to heroku.
heroku buildpacks:clear
heroku buildpacks:add --index heroku/python
I was having an issue here too. My problem was that my Procfile was "Procfile.txt" .
What solved my issue was to remove the file extension from Procfile, then recommit
and push stuff to heroku
Login to your Heroku dashboard and open your projects.
Go to Settings.
Delete heroku/python from the list of buildpacks
Then click Add buildpack → Choose "Python" → Save Changes.
Activate your environment in your code.
Run heroku ps:scale web=1.
And you're done!
This isn't the problem with your code, but I've gotten this error message a couple of times now and the mistake that I've made that has caused it has been writing
web:gunicorn
instead of
web: gunicorn
That space can really cause a lot of issues.
My issue is that Heroku removed the free plans. To solve such an issue go to Heroku and select/change your free plan to for example "eco" plan.
I have a UAT version I only enable during client development.
I have a custom dyno script but it's turned to the free version. So the app was not starting as my script was not running. When I enabled the Dyno the toggle was still off :rolleyes:
I don't have the reputation to reply to the correct comment, but for me the issue was that I didn't have the run.gunicorn.sh file in my root directory, this resulted in the same "No web processes running" error.
If you don't have this file, create it with contents:
gunicorn -b :5000 --access-logfile - --error-logfile - build:app
Where 'build' is the name of your python file (build.py in this case) and app is the name of your app in the code.
Also make sure that gunicorn is included in requirements.txt, like others have already pointed out.
Yeah I was also using web heroku-php-apache2 dyno and reverted it back to free tier and that caused the dyno to sleep fortunately executing heroku ps:scale web=1 -a <app name> did the magic.
Change your Procfile file from
web:gunicorn to web gunicorn (remove the ':')
I fixed the issue by going to Configure Dynos and enabling the only dyno I had manually.
uff..that took some time,so the fixes i had to make were:
'Procfile' with upper case P.
web: gunicorn wsgi:app (with a space after web: in procfile)
Making sure the requirements.txt are in the root project folder.
I was missing dynos on the web gui. The cli command to scale did not work. I also may have had an incorrect run:web declaration with missing $PORT. To fix:
heroku.yml must have a web declaration using the $PORT var:
build:
docker:
web: Dockerfile
run:
web: uvicorn main:app --reload --host 0.0.0.0 --port $PORT
I then pushed to heroku.
After that it must have added the web dyno, I could then run:
heroku ps:scale web=1
And now the fastapi uvicorn runs.
Pay attention to the Procfile naming and location (https://devcenter.heroku.com/articles/procfile) The Procfile is always a "simple text file" that is named Procfile without a file extension.(Procfile.txt not acceptable!) The Procfile must live in your app's root directory. It does not function if placed anywhere else.
Faced the exact same problem turns out I had the Profile in .gitignore
I was placing my django Procfile in the directory with settings.py and not the root directory and that gave me the H14 error. I fixed the error with this and I didn't need to do anything else they say.
Procfile
web: gunicorn <django-root-name(containing wsgi)>.wsgi
There are many things that can go wrong here. Its a combination of poor shepherding by heroku and ambiguous use between flask & gunicorn.
Here is a good guide that will get you up and running:
To anyone who may come across this...
delete your Procfile
create 'Procfile' with upper case P.
in your Procfile type: web: gunicorn <nameOfRootFile>:app (with a space after web: in procfile) mine for example was web: gunicorn app:app another way I wrote it that worked was this: web: gunicorn -w 4 "app:create_app()" -t 120
Making sure the requirements.txt are in the root project folder. (you can run pip freeze > requirements.txt if you do not have the file created
deploy to heroku
heroku ps:scale web=1 (you can specify app name to like this heroku ps:scale web=1 -a appname
finally in terminal run heroku restart
heroku open
these are all the steps i took to get mine to work
web: gunicorn weather.wsgi --log-file -
this worked for me, just make sure your Procfile is in the right format, and specify the app you are connecting to, in my case it's the weather app. Enjoy
What worked for me was adding on the second line of the procfile:
heroku ps:scale web=1
The first line must contain:
web: gunicorn "filename":"main method name"

Categories

Resources