Search code examples
pythondjangoherokuheroku-toolbelt

Heroku Deployment - PermissionError: [Errno 13] Permission denied: '/etc/passwd-'


Can anyone help me with this error? I don't what's wrong with the code. is it a database credentials error? Is it an application code error? Is it a Linux/Unix related error?

This is my first time to deploy my application on Heroku but I got this error message:

PermissionError: [Errno 13] Permission denied: '/etc/passwd-'

   python ph_dorms/manage.py collectstatic --noinput
   Traceback (most recent call last):
     File "ph_dorms/manage.py", line 15, in <module>
       execute_from_command_line(sys.argv)
     File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
       utility.execute()
     File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
       self.fetch_command(subcommand).run_from_argv(self.argv)
     File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
       self.execute(*args, **cmd_options)
     File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
       output = self.handle(*args, **options)
     File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 189, in handle
       collected = self.collect()
     File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 114, in collect
       handler(path, prefixed_path, storage)
     File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 353, in copy_file
       with source_storage.open(path) as source_file:
     File "/app/.heroku/python/lib/python3.6/site-packages/django/core/files/storage.py", line 33, in open
       return self._open(name, mode)
     File "/app/.heroku/python/lib/python3.6/site-packages/django/core/files/storage.py", line 218, in _open
       return File(open(self.path(name), mode))
   PermissionError: [Errno 13] Permission denied: '/etc/passwd-'
   !     Error while running '$ python ph_dorms/manage.py collectstatic --noinput'.
   See traceback above for details.
   You may need to update 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

Solution

  • The complicated part in deploying a django webapp is most of the time related to the collectstatics only if you didn't setup everything correctly to serve static files from the same server.

    First disable the collectstatics running the following in your terminal or cmd:

    heroku config:set DISABLE_COLLECTSTATIC=1
    

    Then deploy again.