TransWikia.com

Heroku error: bash: web:: command not found

Stack Overflow Asked by fayewaii on December 29, 2020

Today my Heroku website was working fine but then I had to make lots of changes to the file and I definitely did something to it because now it doesn’t work anymore. I don’t know what could’ve changed the configuration.

Here is my Procfile:

web: python manage.py collectstatic --no-input; web: gunicorn --pythonpath ghiblimovs mysite.wsgi --log-file 

Here are my settings:

import os
import dj_database_url

# 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 https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'secretkeyhere'

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

ALLOWED_HOSTS = ['127.0.0.1', '.herokuapp.com']


# Application definition

INSTALLED_APPS = [
    'core',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'whitenoise.middleware.WhiteNoiseMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'mysite.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, 'templates'),
         ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'mysite.wsgi.application'


# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'djangogirls',
        'USER': 'name',
        'PASSWORD': '',
        'HOST': 'localhost',
        'PORT': '',
        }
}

db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)

# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        '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',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
TEMPLATE_DIRS = (
    os.path.join(BASE_DIR,  'templates'),
    
)

This is the error I get when I push to Heroku:

2020-08-17T23:28:59.916852+00:00 heroku[web.1]: Starting process with command `python manage.py collectstatic --no-input; web: gunicorn --pythonpath ghiblimovs mysite.wsgi --log-file -`
2020-08-17T23:29:03.838564+00:00 app[web.1]:
2020-08-17T23:29:03.838591+00:00 app[web.1]: 119 static files copied to '/app/staticfiles', 1 unmodified, 276 post-processed.
2020-08-17T23:29:03.880853+00:00 app[web.1]: bash: web:: command not found
2020-08-17T23:29:03.926388+00:00 heroku[web.1]: Process exited with status 127
2020-08-17T23:29:03.961012+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-17T23:29:05.298138+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ghiblimovs.herokuapp.com request_id=8114d978-cb22-45f4-9b6b-618fab619c64 fwd="190.244.95.189" dyno= connect= service= status=503 bytes= protocol=https
2020-08-17T23:29:05.963051+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ghiblimovs.herokuapp.com request_id=5a4940b9-b172-43ec-83db-6457680c6d37 fwd="190.244.95.189" dyno= connect= service= status=503 bytes= protocol=https

Any help would be useful!

2 Answers

Your Procfile is broken:

web: python manage.py collectstatic --no-input; web: gunicorn --pythonpath ghiblimovs mysite.wsgi --log-file 

You're cramming two web process definitions into one line.

If you really want to chain things there, use &&:

web: python manage.py collectstatic --no-input && gunicorn --pythonpath ghiblimovs mysite.wsgi --log-file -

But Heroku runs collectstatic for Django applications by default. You don't need to put that in the Procfile. Something like this should do:

web: gunicorn --pythonpath ghiblimovs mysite.wsgi --log-file -

Note that you were also missing the - argument to --log-file. I've added it here.

Correct answer by Chris on December 29, 2020

web: gunicorn --pythonpath ghiblimovs mysite.wsgi --log-file

Answer gunicorn: pip install gunicorn

In your Procfile(letter p should spell Capital letter) in Procfile type code: web: gunicorn mysite.wsgi The app creash is cause of bad header request rest the heroku logs history setting folling you commit message.

Answered by NELSON DEGREAT on December 29, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP