I’ve been struggling to deploy my Dash app to Heroku for more than a day. The app runs fine locally in my conda environment. I am able to push the app to Heroku and it builds successfully and launches successfully. However, the app immediately crashes with the following error messages in the Heroku log:
I am also able to launch the app successfully via the Heroku console (the console reports successful launch on port 8050).
To test whether my app was somehow incompatible with Heroku deployment, I made a simple test app, deploying the example app to Heroku. Heroku builds and launches successfully, but crashes immediately with the same kind of errors (shown below). Can some suggest what I might be be doing wrong?
Regarding launching the app via the Heroku console, I mean that from the Heroku app admin page, I click “More” in in the top right corner, then “Run Console”. I then execute python app.py.
After pushing the app to Heroku and getting a successful response, I execute heroku ps:scale web=1.
Using the console was meant to test whether the app could execute, or if errors were occuring at launch. I don’t intend to start the app this way going forward. I expect to use the CLI with ps:scale web=1.
When I execute gunicorn run:server in my local terminal I get:
Traceback (most recent call last): File "c:\users\adiad\anaconda3\envs\sleepappminimal\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "c:\users\adiad\anaconda3\envs\sleepappminimal\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\adiad\Anaconda3\envs\SleepAppMinimal\Scripts\gunicorn.exe\__main__.py", line 4, in <module> File "c:\users\adiad\anaconda3\envs\sleepappminimal\lib\site-packages\gunicorn\app\wsgiapp.py", line 9, in <module> from gunicorn.app.base import Application File "c:\users\adiad\anaconda3\envs\sleepappminimal\lib\site-packages\gunicorn\app\base.py", line 11, in <module> from gunicorn import util File "c:\users\adiad\anaconda3\envs\sleepappminimal\lib\site-packages\gunicorn\util.py", line 9, in <module> import fcntl ModuleNotFoundError: No module named 'fcntl'
I don’t know why the console mentions run.py because it isn’t in my source. Here are the contents of my repo (by executing ls -R in my local terminal):
`.:
Procfile assets data requirements.txt static
app.py conda-reqirements.txt environment.yml runtime.txt
In which case, I think you probably want to change your Procfile to
web: gunicorn app:app.server
The format is supposed to be gunicorn <python module name>:<flask server object>, in your case the python module that acts as the entry point is called app.py. I’m assuming you have a dash.Dash app in app.py called app? If so you can access the underlying Flask server with app.server, which is what gunicorn is looking for. So the command is telling it “take app.server from app.py and host it”.
I modified my Procfile as you suggested and got the same kind of errors (shown below). I’m confused on why I would need to modify my Procfile since my app follows the same structure as the Dash deployment example, namely: I have app.py which instantiates a dash.Dash object as app. I should be able to use the same Procfile as in the example, right?
Well in that example the Procfile is web: gunicorn app:server and they have the line server = app.server in app.py, so it’s the same as what I suggested. When you originally had web: gunicorn run:server that was not going to work because there was no run.py file to find.
Is there any more log information just before this?
Inspecting my app.py script revealed that I did not have server = app.server, so I added it and changed my Procfile back to what the example had. This was the fix I needed! Thanks so much for your help @tcbegley!!! I’m not sure why I was getting a similar error when deploying the actual example, but that doesn’t matter…
Hi guys, I am facing the same issue. Here is the link to my Github files for the dashboard (Link)
When I deploy the app on Heroku I don’t see any error but when I open the app I get Application Error. And upon looking at the logs I get Application Crashed error. Attached is the pic for your reference.
I was just having the same problem and couldn’t figure it as I was just following a few simple steps. Turned out the csv file I was reading my data from was large (couple 100MB) and I didn’t have enough resources on a free account.