1

This is my very first time deploying a Django app in Heroku and I was following an article to git push and all the other tasks. The problem started when I started to push master. My app was not loading. So from Heroku documentation, I moved the push to main and deleted the master. And a new problem arose that is the application error, and asked to Heroku log --tails. Later I found the Procfile didn't have the right app name. corrected that and restarted Heroku. Still, it shows an application error with the line in red saying: Build failed -- check your build output: https://dashboard.heroku.com/apps/6609d304-92ca-454e-8659-561a8adbb11a/activity/builds/6c1dd096-0d90-49af-a5db-55eec4dff27b for the Heroku logs --tail.

terminal: Heroku logs --tail

 (env) D:\DJPROJ\OFFSET_V1.1\v1>heroku logs --tail
2021-05-30T08:27:39.043493+00:00 app[api]: Initial release by user [email protected]
2021-05-30T08:27:39.043493+00:00 app[api]: Release v1 created by user [email protected]
2021-05-30T08:27:39.615588+00:00 app[api]: Enable Logplex by user [email protected]
2021-05-30T08:27:39.615588+00:00 app[api]: Release v2 created by user [email protected]
2021-05-30T08:33:03.000000+00:00 app[api]: Build started by user [email protected]
2021-05-30T08:33:32.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/6609d304-92ca-454e-8659-561a8adbb11a/activity/builds/bb5f0314-a49e-4e29-b6a0-1ec421b92733
2021-05-30T08:47:08.146897+00:00 app[api]: Starting process with command `python manage.py migrate` by user [email protected]
2021-05-30T08:47:08.852782+00:00 heroku[run.2613]: State changed from starting to up
2021-05-30T08:47:09.202077+00:00 heroku[run.2613]: Awaiting client
2021-05-30T08:47:09.491181+00:00 heroku[run.2613]: Starting process with command `python manage.py migrate`
2021-05-30T08:47:13.897745+00:00 heroku[run.2613]: Process exited with status 2
2021-05-30T08:47:13.966147+00:00 heroku[run.2613]: State changed from up to complete
2021-05-30T08:48:00.087012+00:00 app[api]: Starting process with command `python manage.py migrate` by user [email protected]
2021-05-30T08:48:00.790244+00:00 heroku[run.1873]: State changed from starting to up
2021-05-30T08:48:01.143261+00:00 heroku[run.1873]: Awaiting client
2021-05-30T08:48:01.338490+00:00 heroku[run.1873]: Starting process with command `python manage.py migrate`
2021-05-30T08:48:06.187945+00:00 heroku[run.1873]: Process exited with status 2
2021-05-30T08:48:06.262165+00:00 heroku[run.1873]: State changed from up to complete
2021-05-30T08:48:59.949192+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=off1.herokuapp.com request_id=b4b4fa2e-4252-4bf4-a744-2e5c2bdab4a1 fwd="115.42.52.162" dyno= connect= service= status=502 bytes= protocol=https
2021-05-30T08:49:00.332156+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=off1.herokuapp.com request_id=23ad728e-9951-488c-b5cd-6e97f500012b fwd="115.42.52.162" dyno= connect= service= status=502 bytes= protocol=https
2021-05-30T08:49:11.727981+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=off1.herokuapp.com request_id=153f1949-1d42-43ce-9ba5-168e3069ea76 fwd="115.42.52.162" dyno= connect= service= status=502 bytes= protocol=https
2021-05-30T08:49:12.395135+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=off1.herokuapp.com request_id=bd0a3aa1-7634-4956-9c17-5b63c25e5e79 fwd="115.42.52.162" dyno= connect= service= status=502 bytes= protocol=https
2021-05-30T08:50:40.502949+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=off1.herokuapp.com request_id=c9740535-9ef9-442a-9131-3579e64865c7 fwd="115.42.52.166" dyno= connect= service= status=502 bytes= protocol=https
2021-05-30T08:50:40.818555+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=off1.herokuapp.com request_id=33792eca-5ab4-46cb-8832-a8e3d9f73ffe fwd="115.42.52.166" dyno= connect= service= status=502 bytes= protocol=https
2021-05-30T08:51:18.804650+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=off1.herokuapp.com request_id=2f85bf4d-81f9-4519-a31b-27989571c47d fwd="115.42.52.166" dyno= connect= service= status=502 bytes= protocol=https
2021-05-30T08:51:19.454601+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=off1.herokuapp.com request_id=4f88548a-8aa8-4652-aa5d-bdfdea45da6a fwd="115.42.52.166" dyno= connect= service= status=502 bytes= protocol=https
2021-05-30T08:52:29.000000+00:00 app[api]: Build started by user [email protected]
2021-05-30T08:52:59.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/6609d304-92ca-454e-8659-561a8adbb11a/activity/builds/6c1dd096-0d90-49af-a5db-55eec4dff27b
2021-05-30T09:01:35.511449+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=off1.herokuapp.com request_id=ff64308b-4f51-4837-9ce2-a23ab2d7a809 fwd="115.42.52.190" dyno= connect= service= status=502 bytes= protocol=https
2021-05-30T09:01:35.963136+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=off1.herokuapp.com request_id=95c7a49e-4b3f-4fab-b362-e5ea601e69b7 fwd="115.42.52.190" dyno= connect= service= status=502 bytes= protocol=https
2021-05-30T09:21:58.481667+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=off1.herokuapp.com request_id=778bb534-9993-4fb4-aa6b-955aad309398 fwd="115.42.52.174" dyno= connect= service= status=502 bytes= protocol=https
2021-05-30T09:21:58.896278+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=off1.herokuapp.com request_id=6a91f74b-dc4a-4d13-983b-f955afee431a fwd="115.42.52.174" dyno= connect= service= status=502 bytes= protocol=https
2021-05-30T09:27:45.624223+00:00 app[api]: Starting process with command `bundle exec rake db:migrate` by user [email protected]
2021-05-30T09:27:46.335939+00:00 heroku[run.9651]: State changed from starting to up
2021-05-30T09:27:46.763198+00:00 heroku[run.9651]: Awaiting client
2021-05-30T09:27:47.072227+00:00 heroku[run.9651]: Starting process with command `bundle exec rake db:migrate`
2021-05-30T09:27:51.728869+00:00 heroku[run.9651]: Process exited with status 127
2021-05-30T09:27:51.815954+00:00 heroku[run.9651]: State changed from up to complete
2021-05-30T09:29:28.655372+00:00 app[api]: Set DISABLE_COLLECTSTATIC config vars by user [email protected]
2021-05-30T09:29:28.655372+00:00 app[api]: Release v3 created by user [email protected]
2021-05-30T09:38:27.000000+00:00 app[api]: Build started by user [email protected]
2021-05-30T09:39:09.302528+00:00 app[api]: Attach DATABASE (@ref:postgresql-aerodynamic-89722) by user [email protected]
2021-05-30T09:39:09.302528+00:00 app[api]: Running release v4 commands by user [email protected]
2021-05-30T09:39:09.316993+00:00 app[api]: @ref:postgresql-aerodynamic-89722 completed provisioning, setting DATABASE_URL. by user [email protected]
2021-05-30T09:39:09.316993+00:00 app[api]: Release v5 created by user [email protected]
2021-05-30T09:39:09.608803+00:00 app[api]: Release v6 created by user [email protected]
2021-05-30T09:39:09.608803+00:00 app[api]: Deploy 9fdb0adf by user [email protected]
2021-05-30T09:39:21.000000+00:00 app[api]: Build succeeded
2021-05-30T09:40:01.457261+00:00 app[api]: Starting process with command `python manage.py migrate` by user [email protected]
2021-05-30T09:40:07.745943+00:00 heroku[run.6735]: State changed from starting to up
2021-05-30T09:40:07.896324+00:00 heroku[run.6735]: Awaiting client
2021-05-30T09:40:07.927791+00:00 heroku[run.6735]: Starting process with command `python manage.py migrate`
2021-05-30T09:40:14.939487+00:00 heroku[run.6735]: Process exited with status 0
2021-05-30T09:40:14.993471+00:00 heroku[run.6735]: State changed from up to complete
2021-05-30T09:40:32.197329+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=off1.herokuapp.com request_id=a8adc809-f9fe-43f2-9516-19adc21b4e81 fwd="115.42.52.164" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T09:40:32.885137+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=off1.herokuapp.com request_id=9a717a13-cbeb-4ae0-b5e6-c706116780b0 fwd="115.42.52.164" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T09:40:57.425964+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=off1.herokuapp.com request_id=191b4cb8-7c70-4c13-9542-55783a5cc4bc fwd="115.42.52.164" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T09:40:58.000926+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=off1.herokuapp.com request_id=cd788777-1937-448e-b360-3b5d1687474c fwd="115.42.52.164" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T09:49:27.525495+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=off1.herokuapp.com request_id=fb7aa6aa-a887-4ff1-8876-08adfb6c33f6 fwd="115.42.52.168" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T09:49:27.895519+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=off1.herokuapp.com request_id=703001d5-5fe9-429e-b35f-96151496f20f fwd="115.42.52.168" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T09:55:26.756267+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=off1.herokuapp.com request_id=f62c6dfb-2664-4563-a0c5-59cfb85b93aa fwd="115.42.52.186" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T09:55:27.341312+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=off1.herokuapp.com request_id=a21e6734-93c9-4ec7-95d3-028444066a7e fwd="115.42.52.186" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T09:56:42.266521+00:00 app[api]: Starting process with command `rake db:migrate` by user [email protected]
2021-05-30T09:56:48.475979+00:00 heroku[run.8708]: State changed from starting to up
2021-05-30T09:56:48.833282+00:00 heroku[run.8708]: Awaiting client
2021-05-30T09:56:48.866252+00:00 heroku[run.8708]: Starting process with command `rake db:migrate`
2021-05-30T09:56:53.682754+00:00 heroku[run.8708]: Process exited with status 1
2021-05-30T09:56:53.742473+00:00 heroku[run.8708]: State changed from up to complete
2021-05-30T09:56:59.829131+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=off1.herokuapp.com request_id=23aa5296-7929-4870-88e2-fcc3528a3a37 fwd="115.42.52.163" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T09:57:00.390160+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=off1.herokuapp.com request_id=9eb3d4dd-c953-44a6-9d99-292ebec17f28 fwd="115.42.52.163" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T10:23:11.421610+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=off1.herokuapp.com request_id=ceeebec1-3988-49c4-9265-373f765fe511 fwd="115.42.52.176" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T10:23:11.999647+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=off1.herokuapp.com request_id=ec7196ff-4911-4b9e-be79-e06ff615ca0d fwd="115.42.52.176" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T10:26:57.666756+00:00 app[api]: Starting process with command `python manage.py migrate` by user [email protected]
2021-05-30T10:27:04.616979+00:00 heroku[run.6908]: State changed from starting to up
2021-05-30T10:27:04.986280+00:00 heroku[run.6908]: Awaiting client
2021-05-30T10:27:05.008738+00:00 heroku[run.6908]: Starting process with command `python manage.py migrate`
2021-05-30T10:27:11.505688+00:00 heroku[run.6908]: Process exited with status 0
2021-05-30T10:27:11.561616+00:00 heroku[run.6908]: State changed from up to complete
2021-05-30T10:27:17.269386+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=off1.herokuapp.com request_id=66ce0137-2553-4739-861e-7dae66601309 fwd="115.42.52.179" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T10:27:17.884489+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=off1.herokuapp.com request_id=3b51efa3-ba6a-4f83-ad69-309e6907c8b5 fwd="115.42.52.179" dyno= connect= service= status=503 bytes= protocol=https
 

The red line

https://dashboard.heroku.com/apps/6609d304-92ca-454e-8659-561a8adbb11a/activity/builds/6c1dd096-0d90-49af-a5db-55eec4dff27b

The directed link gives this

-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> Python app detected
-----> No Python version was specified. Using the buildpack default: python-3.9.5
       To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes
-----> Installing python-3.9.5
-----> Installing pip 20.2.4, setuptools 47.1.1 and wheel 0.36.2
-----> Installing SQLite3
-----> Installing requirements with pip
       Collecting asgiref==3.3.4
         Downloading asgiref-3.3.4-py3-none-any.whl (22 kB)
       Collecting dj-database-url==0.5.0
         Downloading dj_database_url-0.5.0-py2.py3-none-any.whl (5.5 kB)
       Collecting Django==3.2.3
         Downloading Django-3.2.3-py3-none-any.whl (7.9 MB)
       Collecting django-heroku==0.3.1
         Downloading django_heroku-0.3.1-py2.py3-none-any.whl (6.2 kB)
       Collecting gunicorn==20.1.0
         Downloading gunicorn-20.1.0-py3-none-any.whl (79 kB)
       Collecting psycopg2==2.8.6
         Downloading psycopg2-2.8.6.tar.gz (383 kB)
       Collecting pytz==2021.1
         Downloading pytz-2021.1-py2.py3-none-any.whl (510 kB)
       Collecting sqlparse==0.4.1
         Downloading sqlparse-0.4.1-py3-none-any.whl (42 kB)
       Collecting whitenoise==5.2.0
         Downloading whitenoise-5.2.0-py2.py3-none-any.whl (19 kB)
       Building wheels for collected packages: psycopg2
         Building wheel for psycopg2 (setup.py): started
         Building wheel for psycopg2 (setup.py): finished with status 'done'
         Created wheel for psycopg2: filename=psycopg2-2.8.6-cp39-cp39-linux_x86_64.whl size=523855 sha256=b093f427ebabaf501fa8e5ed90d25c8d623b2bc34ed054a20691960d0aa574c5
         Stored in directory: /tmp/pip-ephem-wheel-cache-vk7w3af4/wheels/a2/07/10/a9a82e72d50feb8d646acde6a88000bbf2ca0f82e41aea438a
       Successfully built psycopg2
       Installing collected packages: asgiref, dj-database-url, sqlparse, pytz, Django, psycopg2, whitenoise, django-heroku, gunicorn
       Successfully installed Django-3.2.3 asgiref-3.3.4 dj-database-url-0.5.0 django-heroku-0.3.1 gunicorn-20.1.0 psycopg2-2.8.6 pytz-2021.1 sqlparse-0.4.1 whitenoise-5.2.0
-----> $ python manage.py collectstatic --noinput
       Traceback (most recent call last):
         File "/tmp/build_3b53899d/manage.py", line 22, in <module>
           main()
         File "/tmp/build_3b53899d/manage.py", line 18, in main
           execute_from_command_line(sys.argv)
         File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
           utility.execute()
         File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
           self.fetch_command(subcommand).run_from_argv(self.argv)
         File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
           self.execute(*args, **cmd_options)
         File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
           output = self.handle(*args, **options)
         File "/app/.heroku/python/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 187, in handle
           collected = self.collect()
         File "/app/.heroku/python/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 105, in collect
           for path, storage in finder.list(self.ignore_patterns):
         File "/app/.heroku/python/lib/python3.9/site-packages/django/contrib/staticfiles/finders.py", line 130, in list
           for path in utils.get_files(storage, ignore_patterns):
         File "/app/.heroku/python/lib/python3.9/site-packages/django/contrib/staticfiles/utils.py", line 23, in get_files
           directories, files = storage.listdir(location)
         File "/app/.heroku/python/lib/python3.9/site-packages/django/core/files/storage.py", line 323, in listdir
           for entry in os.scandir(path):
       FileNotFoundError: [Errno 2] No such file or directory: '/tmp/build_3b53899d/static'
 !     Error while running '$ python manage.py collectstatic --noinput'.
       See traceback above for details.
       You may need to update the application code to resolve this error.
       Or, you can disable collectstatic for this application:
          $ Heroku config:set DISABLE_COLLECTSTATIC=1
       https://devcenter.heroku.com/articles/django-assets
 !     Push rejected, failed to compile Python app.
 !     Push failed

wsgi.py

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'v1.settings')

application = get_wsgi_application()

manage.py

import os
import sys


def main():
    """Run administrative tasks."""
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'v1.settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)


if __name__ == '__main__':
    main()

Procfile

web: gunicorn v1.wsgi

Requirement.txt

asgiref==3.3.4
dj-database-url==0.5.0
Django==3.2.3
django-heroku==0.3.1
gunicorn==20.1.0
psycopg2==2.8.6
pytz==2021.1
sqlparse==0.4.1
whitenoise==5.2.0

File Tree

-v1
  -home
    -migrations
    -static
    -templates
    -__init__.py
    -admins.py
    -models.py
    -apps.py
    -urls.py
    -tests.py
    -views.py
  -static                            *edited this portion as per comment*
  -v1
    -__init__.py
    -asgi.py
    -settings.py
    -wsgi.py
    -urls.py
  -manage.py
  -Procfile.file
  -requirements.txt
  -dbsqlite3

STATICFILES_DIRS

STATICFILES_DIRS =  [
    os.path.join(BASE_DIR, 'static')
]
STATIC_URL = '/static/'

After editing the file tree, status in Heroku shows "Build succeeded" and "Deployed". Still the application error exists when I run the app: https://off1.herokuapp.com/

Latest build log

-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/python
-----> Python app detected
-----> No Python version was specified. Using the same version as the last build: python-3.9.5
       To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes
-----> No change in requirements detected, installing from cache
-----> Using cached install of python-3.9.5
-----> Installing pip 20.2.4, setuptools 47.1.1 and wheel 0.36.2
-----> Installing SQLite3
-----> Installing requirements with pip
-----> Skipping Django collectstatic since the env var DISABLE_COLLECTSTATIC is set.
-----> Discovering process types
       Procfile declares types -> (none)
-----> Compressing...
       Done: 60.4M
-----> Launching...
       Released v7
       https://off1.herokuapp.com/ deployed to Heroku

I am really confused and need a comprehensible solution to fix the application error. Gratitudes!

6
  • Show the settings STATICFILES_DIRS, STATIC_ROOT and your file tree. Commented May 30, 2021 at 11:16
  • edited. I don't have a STATIC_ROOT in the settings.py Commented May 30, 2021 at 11:43
  • You don't have a directory named static in your project, whereas STATICFILES_DIRS has an entry for that, hence you get an error. Add the directory to your project, commit and push again. Commented May 30, 2021 at 11:45
  • I have edited more specifically. home is the appname. Commented May 30, 2021 at 11:55
  • The static directory in home is not the one we are talking about. os.path.join(BASE_DIR, 'static') means it refers to a directory static directly in your project directory, so on a level similar to home, manage.py, etc. Commented May 30, 2021 at 12:00

1 Answer 1

0

Check This portal seemed to have an explicit solution to my problem later after Abdul Aziz Barkat guided me in the comment section.

  • I had to add these two piece of line in the settings.py file

    STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") STATICFILES_STORAGE='whitenoise.django.GzipManifestStaticFilesStorage'

  • Added a blank txt file or anything in the static folder of the project. This helps in case of git add

  • Renamed the Procfile.file as Procfile only

  • Deleted the previous requirements.txt file and run the cmd line again, pip freeze > requirements.txt

  • git add . -> git status -> git commit -m "..." -> git push heroku main

This worked fine for my Django project to get a perfect deployment and view.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.