python collectstatic --noinput error when deploying Django project to Heroku

static files not loading django heroku
django collectstatic
you're using the staticfiles app without having set the static_root setting to a filesystem path.
django static files
whitenoise django
heroku collectstatic error
django whitenoise heroku

I've recently encountered a static files error when deploying my Django project again to Heroku. I've deployed the project to Heroku once already previously (without static files) and it worked. But recently, I altered the front-end and included some images and css files, and now I'm updating this project.

My Project files are as follows:

site1 - mynotes -
      - mynotess - migrations
                 - static
                 - templates
      - users    - migrations
                 - templates
      - .gitignore.txt
      - db.sqlite3
      - Procfile
      - requirements.txt

Just to clarify, mynotes is the main project directory. 'users' and 'mynotess' (double s) are apps.

This is my

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Quick-start development settings - unsuitable for production
# See

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'w2!3r+pgqz6yhwi_+aw_!-yra7#h69z-n3-ni$gs2v+!!k^2$b'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True


# Application definition



ROOT_URLCONF = 'mynotes.urls'

        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [], #originally empty
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [

WSGI_APPLICATION = 'mynotes.wsgi.application'

    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),

        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',



USE_I18N = True

USE_L10N = True

USE_TZ = True

STATIC_URL = '/static/'

LOGIN_URL = 'users/login'

BOOTSTRAP3 = {'include_jquery': True}

if os.getcwd() == '/app':
    import dj_database_url
        'default': dj_database_url.config(default='postgres://localhost')


    ALLOWED_HOSTS = ['*']

    BASE_DIR = os.path.dirname(os.path.abspath(__file__))
    STATIC_ROOT = 'staticfiles'
        os.path.join(BASE_DIR, 'static'),

This is the error I got in Command Prompt:

C:\Users\Steven\site1>git push heroku master
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 590 bytes | 0 bytes/s, done.
Total 7 (delta 5), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: -----> Python app detected
remote:      $ pip install -r requirements.txt
remote:      $ python collectstatic --noinput
remote:        Traceback (most recent call last):
remote:          File "", line 22, in <module>
remote:            execute_from_command_line(sys.argv)
remote:          File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/", line 367, in execute_from_command_line
remote:            utility.execute()
remote:          File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/", line 359, in execute
remote:            self.fetch_command(subcommand).run_from_argv(self.argv)
remote:          File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/", line 294, in run_from_argv
remote:            self.execute(*args, **cmd_options)
remote:          File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/", line 345, in execute
remote:            output = self.handle(*args, **options)
remote:          File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/", line 193, in handle
remote:            collected = self.collect()
remote:          File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/", line 124, in collect
remote:            handler(path, prefixed_path, storage)
remote:          File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/", line 337, in copy_file
remote:            if not self.delete_file(path, prefixed_path, source_storage):
remote:          File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/", line 255, in delete_file
remote:            if
remote:          File "/app/.heroku/python/lib/python2.7/site-packages/django/core/files/", line 394, in exists
remote:            return os.path.exists(self.path(name))
remote:          File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/", line 49, in path
remote:            raise ImproperlyConfigured("You're using the staticfiles app "
remote:        django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
remote:  !     Error while running '$ python collectstatic --noinput'.
remote:        See traceback above for details.
remote:        You may need to update application code to resolve this error.
remote:        Or, you can disable collectstatic for this application:
remote:           $ heroku config:set DISABLE_COLLECTSTATIC=1
remote:  !     Push rejected, failed to compile Python app.
remote:  !     Push failed
remote: Verifying deploy...
remote: !       Push rejected to my-compository.
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to ''

I feel like it has something to do with how my static files are configured in Any kind of help/suggestions are greatly appreciated!

The error message specifies the root of the problem, you don't have STATIC_ROOT setup properly—you have to use an absolute path:


Default: None

The absolute path to the directory where collectstatic will collect static files for deployment.

Something like this should work:

BASE_DIR = os.path.dirname(os.path.abspath(__file__))

STATIC_ROOT = os.path.normpath(os.path.join(BASE_DIR, 'staticfiles'))
    os.path.join(BASE_DIR, 'static'),

Of course, it may also be the case that the if block in your settings isn't being run.

Django and Static Assets, Django settings for static assets can be a bit difficult to configure and debug. However, the fantastic WhiteNoise project can integrate into your is deployed to Heroku, $ python collectstatic --noinput is run� Collectstatic during builds. When a Django application is deployed to Heroku, $ python collectstatic --noinput is run automatically during the build. A build will fail if the collectstatic step is not successful. Debugging. If collectstatic failed during a build, a traceback was provided that will be helpful in diagnosing the problem.

heroku Error while running '$ python collectstatic , heroku Error while running '$ python collectstatic --noinput'. in < module> remote: execute_from_command_line(sys.argv) remote: File "/app/. heroku/python/lib/python3.6/site-packages/django/core/management/" , line 371, Push failed remote: Verifying deploy remote: remote: ! I have created and worked on a Django application (Simple website with user registration and login) and now i want to try deploying it into Heroku. I have already uploaded my full code to GitHub an

cwd = os.getcwd() 
if cwd == '/app' or cwd[:4] == '/tmp':

Try this one, found it somewhere. It seems that the code needs to look into the temporary files as well to implement the static files.

Collectstatic error while deploying Django app to Heroku, I'm trying to deploy a Django app to Heroku, it starts to build, download and python collectstatic --noinput remote: Traceback (most recent call last ):� run migrations (django 1.10 added at least one) heroku run python migrate. run collectstatic using bower. heroku run 'bower install --config.interactive=false;grunt prep;python collectstatic --noinput' enable collecstatic for future deploys. heroku config:unset DISABLE_COLLECTSTATIC. try it on your own (optional) heroku run

well I fixed by changing the like this:

STATIC_URL = '/static/'
   os.path.join(BASE_DIR, 'static'),
   STATIC_ROOT = os.path.join(BASE_DIR,'static')

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

I followed the steps exactly but faced an error when I tried to push to , "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__ init Error while running '$ python collectstatic --noinput'. remote: See I followed the steps exactly but faced an error when I tried to push to heroku on ImproperlyConfigured: You're using the staticfiles app without having set the� After python collectstatic --noinput --clear in Dockerfile executed in docker build, all static assets would be put to static_root directory. After docker run excecuted on Heroku, Django can serve static assets with the help of whitenoise. Step5: Serving media files on Heroku. Because all changes to docker container would be lost

$ heroku config:set DISABLE_COLLECTSTATIC=1

Fail to push to Heroku: Error while running '$ python , remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/ Error while running '$ python collectstatic --noinput'. I'm getting this same error message when trying to deploy to Heroku (that� Getting Started on Heroku with Python Introduction. This tutorial will have you deploying a Python app (a simple Django app) in minutes. Hang on for a few more minutes to learn how it all works, so you can make the most out of Heroku.

Deploying to heroku, failing on collectstatic : django, Error while running '$ python collectstatic --noinput' https:// serving. heroku run python collectstatic --dry-run --noinput and it works perfectly fine, no errors whatsoever. I've been working on this for a while now to no avail.

#21080 (collectstatic post-processing fails for references inside , hi, apparently this issue is still open in django 1.11. my deploy to heroku failed with the following error log: $ python collectstatic --noinput� $ heroku run python migrate --settings=heroku_blog.settings.production Running python migrate --settings=heroku_blog.settings.production on ⬢ django-heroku-blog up, run.6570 (Free) Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions Running migrations: Applying contenttypes.0001_initial

Deploying Django to Heroku: Procfile, STATIC_ROOT, & Other , python runserverPerforming system checks. Before we can push our Django app to Heroku, Heroku needs a little more information on how to run the app. echo 'web: gunicorn mysite.wsgi --log-file -' > Procfile It's likely you'll find some helpful resources in the Heroku CLI's error messages. collectstatic ¶ django-admin collectstatic¶ Collects the static files into STATIC_ROOT. Duplicate file names are by default resolved in a similar way to how template resolution works: the file that is first found in one of the specified locations will be used. If you’re confused, the findstatic command can help show you which files are found.

  • just to clarify, does this mean i need two static folders, one for the actual static files and the other one for the static root?
  • Best to read the docs so that you understand what is going on. Three STATIC settings are described there. STATIC_ROOT is where static files are placed after collectstatic runs. STATICFILES_DIRS is where collectstatic can find static files that it will collect.
  • An explanation of how and/or why it works is always welcome. Please avoid pure code/terminal command answers.