Home > Software engineering >  Unable to log in to Django admin panel after Railway deployment
Unable to log in to Django admin panel after Railway deployment

Time:12-17

I'm new to Django, and even newer to using Railway so please be kind. I've got a portfolio project that uses Django on the back end, and I was previously hosting on Heroku. I've attempted to move the deployment to Railway, and I've encountered a problem I can't figure out. Locally, I'm able to sign into the Django admin panel with the superuser credentials. When I attempt the same on the Railway deployment, I get a really long error that doesn't point to anything in my code. I've tried to research the error for a few days now, and I'm coming up blank. I honestly don't even have a direction to look for a solution. This is the error I see when I attempt to sign into the admin panel: (Happy to add other files, but I don't know what is relevant?)

OperationalError at /admin/login/
connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
    Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (::1), port 5432 failed: Cannot assign requested address
    Is the server running on that host and accepting TCP/IP connections?
Request Method: POST
Request URL:    http://web-production-603f.up.railway.app/admin/login/?next=/admin/
Django Version: 4.0.6
Exception Type: OperationalError
Exception Value:    
connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
    Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (::1), port 5432 failed: Cannot assign requested address
    Is the server running on that host and accepting TCP/IP connections?
Exception Location: /opt/venv/lib/python3.9/site-packages/psycopg2/__init__.py, line 122, in connect
Python Executable:  /opt/venv/bin/python
Python Version: 3.9.13
Python Path:    
['/app',
 '/opt/venv/bin',
 '/nix/store/dcy4s05wgyznzcvghsm1sgbf7a0xrp8k-python3-3.9.13/lib/python39.zip',
 '/nix/store/dcy4s05wgyznzcvghsm1sgbf7a0xrp8k-python3-3.9.13/lib/python3.9',
 '/nix/store/dcy4s05wgyznzcvghsm1sgbf7a0xrp8k-python3-3.9.13/lib/python3.9/lib-dynload',
 '/opt/venv/lib/python3.9/site-packages']
Server time:    Fri, 16 Dec 2022 02:56:12  0000
Traceback Switch to copy-and-paste view
/opt/venv/lib/python3.9/site-packages/django/db/backends/base/base.py, line 244, in ensure_connection
                self.connect() …
Local vars
/opt/venv/lib/python3.9/site-packages/django/utils/asyncio.py, line 26, in inner
            return func(*args, **kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/db/backends/base/base.py, line 225, in connect
        self.connection = self.get_new_connection(conn_params) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/utils/asyncio.py, line 26, in inner
            return func(*args, **kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/db/backends/postgresql/base.py, line 203, in get_new_connection
        connection = Database.connect(**conn_params) …
Local vars
/opt/venv/lib/python3.9/site-packages/psycopg2/__init__.py, line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync) …
Local vars
The above exception (connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections? connection to server at "localhost" (::1), port 5432 failed: Cannot assign requested address Is the server running on that host and accepting TCP/IP connections? ) was the direct cause of the following exception:
/opt/venv/lib/python3.9/site-packages/django/core/handlers/exception.py, line 55, in inner
                response = get_response(request) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/core/handlers/base.py, line 197, in _get_response
                response = wrapped_callback(request, *callback_args, **callback_kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/utils/decorators.py, line 46, in _wrapper
        return bound_method(*args, **kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/views/decorators/cache.py, line 62, in _wrapped_view_func
        response = view_func(request, *args, **kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/contrib/admin/sites.py, line 440, in login
        return LoginView.as_view(**defaults)(request) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/views/generic/base.py, line 84, in view
            return self.dispatch(request, *args, **kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/utils/decorators.py, line 46, in _wrapper
        return bound_method(*args, **kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/views/decorators/debug.py, line 92, in sensitive_post_parameters_wrapper
            return view(request, *args, **kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/utils/decorators.py, line 46, in _wrapper
        return bound_method(*args, **kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/utils/decorators.py, line 133, in _wrapped_view
                    response = view_func(request, *args, **kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/utils/decorators.py, line 46, in _wrapper
        return bound_method(*args, **kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/views/decorators/cache.py, line 62, in _wrapped_view_func
        response = view_func(request, *args, **kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/contrib/auth/views.py, line 67, in dispatch
        return super().dispatch(request, *args, **kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/views/generic/base.py, line 119, in dispatch
        return handler(request, *args, **kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/views/generic/edit.py, line 152, in post
        if form.is_valid(): …
Local vars
/opt/venv/lib/python3.9/site-packages/django/forms/forms.py, line 205, in is_valid
        return self.is_bound and not self.errors …
Local vars
/opt/venv/lib/python3.9/site-packages/django/forms/forms.py, line 200, in errors
            self.full_clean() …
Local vars
/opt/venv/lib/python3.9/site-packages/django/forms/forms.py, line 434, in full_clean
        self._clean_form() …
Local vars
/opt/venv/lib/python3.9/site-packages/django/forms/forms.py, line 455, in _clean_form
            cleaned_data = self.clean() …
Local vars
/opt/venv/lib/python3.9/site-packages/django/contrib/auth/forms.py, line 217, in clean
            self.user_cache = authenticate( …
Local vars
/opt/venv/lib/python3.9/site-packages/django/views/decorators/debug.py, line 42, in sensitive_variables_wrapper
            return func(*func_args, **func_kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/contrib/auth/__init__.py, line 77, in authenticate
            user = backend.authenticate(request, **credentials) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/contrib/auth/backends.py, line 42, in authenticate
            user = UserModel._default_manager.get_by_natural_key(username) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/contrib/auth/base_user.py, line 46, in get_by_natural_key
        return self.get(**{self.model.USERNAME_FIELD: username}) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/db/models/manager.py, line 85, in manager_method
                return getattr(self.get_queryset(), name)(*args, **kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/db/models/query.py, line 492, in get
        num = len(clone) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/db/models/query.py, line 302, in __len__
        self._fetch_all() …
Local vars
/opt/venv/lib/python3.9/site-packages/django/db/models/query.py, line 1507, in _fetch_all
            self._result_cache = list(self._iterable_class(self)) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/db/models/query.py, line 57, in __iter__
        results = compiler.execute_sql( …
Local vars
/opt/venv/lib/python3.9/site-packages/django/db/models/sql/compiler.py, line 1359, in execute_sql
            cursor = self.connection.cursor() …
Local vars
/opt/venv/lib/python3.9/site-packages/django/utils/asyncio.py, line 26, in inner
            return func(*args, **kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/db/backends/base/base.py, line 284, in cursor
        return self._cursor() …
Local vars
/opt/venv/lib/python3.9/site-packages/django/db/backends/base/base.py, line 260, in _cursor
        self.ensure_connection() …
Local vars
/opt/venv/lib/python3.9/site-packages/django/utils/asyncio.py, line 26, in inner
            return func(*args, **kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/db/backends/base/base.py, line 244, in ensure_connection
                self.connect() …
Local vars
/opt/venv/lib/python3.9/site-packages/django/db/utils.py, line 91, in __exit__
                raise dj_exc_value.with_traceback(traceback) from exc_value …
Local vars
/opt/venv/lib/python3.9/site-packages/django/db/backends/base/base.py, line 244, in ensure_connection
                self.connect() …
Local vars
/opt/venv/lib/python3.9/site-packages/django/utils/asyncio.py, line 26, in inner
            return func(*args, **kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/db/backends/base/base.py, line 225, in connect
        self.connection = self.get_new_connection(conn_params) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/utils/asyncio.py, line 26, in inner
            return func(*args, **kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/db/backends/postgresql/base.py, line 203, in get_new_connection
        connection = Database.connect(**conn_params) …
Local vars
/opt/venv/lib/python3.9/site-packages/psycopg2/__init__.py, line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync) …
Local vars
Request information
USER
AnonymousUser

GET
Variable    Value
next    
'/admin/'
POST
Variable    Value
csrfmiddlewaretoken 
'gnerlsZGWNRbSjJPCOiERFCaGSjEbkwjpgbMjByrlGPY83WUvXqntjX4fVFbqDBm'
username    
'ANsuperuser'
password    
'theAlumniNetwork'
next    
'/admin/'
FILES
No FILES data

COOKIES
Variable    Value
csrftoken   
'yuSiUt6a0Z8ycJvqpgu6A376k5nrSYJ1HnPDSCFVpS6lstIvipCPcHs0T8JY7hO4'
META
Variable    Value
CONTENT_LENGTH  
'148'
CONTENT_TYPE    
'application/x-www-form-urlencoded'
CSRF_COOKIE 
'yuSiUt6a0Z8ycJvqpgu6A376k5nrSYJ1HnPDSCFVpS6lstIvipCPcHs0T8JY7hO4'
HTTP_ACCEPT 
'text/html,application/xhtml xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9'
HTTP_ACCEPT_ENCODING    
'gzip, deflate, br'
HTTP_ACCEPT_LANGUAGE    
'en-US,en;q=0.9'
HTTP_CACHE_CONTROL  
'max-age=0'
HTTP_COOKIE 
'csrftoken=yuSiUt6a0Z8ycJvqpgu6A376k5nrSYJ1HnPDSCFVpS6lstIvipCPcHs0T8JY7hO4'
HTTP_DNT    
'1'
HTTP_HOST   
'web-production-603f.up.railway.app'
HTTP_ORIGIN 
'https://web-production-603f.up.railway.app'
HTTP_REFERER    
'https://web-production-603f.up.railway.app/admin/login/?next=/admin/'
HTTP_SEC_CH_UA  
'"Chromium";v="106", "Google Chrome";v="106", "Not;A=Brand";v="99"'
HTTP_SEC_CH_UA_MOBILE   
'?0'
HTTP_SEC_CH_UA_PLATFORM 
'"macOS"'
HTTP_SEC_FETCH_DEST 
'document'
HTTP_SEC_FETCH_MODE 
'navigate'
HTTP_SEC_FETCH_SITE 
'same-origin'
HTTP_SEC_FETCH_USER 
'?1'
HTTP_UPGRADE_INSECURE_REQUESTS  
'1'
HTTP_USER_AGENT 
('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, '
 'like Gecko) Chrome/106.0.0.0 Safari/537.36')
HTTP_X_ENVOY_EXTERNAL_ADDRESS   
'73.123.42.143'
HTTP_X_FORWARDED_FOR    
'73.123.42.143'
HTTP_X_FORWARDED_PROTO  
'https'
HTTP_X_REQUEST_ID   
'4df69a6b-34ab-4a3e-8b1f-f3832c01f964'
PATH_INFO   
'/admin/login/'
QUERY_STRING    
'next=/admin/'
RAW_URI 
'/admin/login/?next=/admin/'
REMOTE_ADDR 
'10.10.10.15'
REMOTE_PORT 
'58398'
REQUEST_METHOD  
'POST'
SCRIPT_NAME 
''
SERVER_NAME 
'0.0.0.0'
SERVER_PORT 
'5878'
SERVER_PROTOCOL 
'HTTP/1.1'
SERVER_SOFTWARE 
'gunicorn/20.1.0'
gunicorn.socket 
<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('172.17.0.37', 5878), raddr=('10.10.10.15', 58398)>
wsgi.errors 
<gunicorn.http.wsgi.WSGIErrorsWrapper object at 0x7f5b62ff7280>
wsgi.file_wrapper   
<class 'gunicorn.http.wsgi.FileWrapper'>
wsgi.input  
<gunicorn.http.body.Body object at 0x7f5b62ff7190>
wsgi.input_terminated   
True
wsgi.multiprocess   
False
wsgi.multithread    
False
wsgi.run_once   
False
wsgi.url_scheme 
'http'
wsgi.version    
(1, 0)
Settings
Using settings module alumni_network_proj.settings
Setting Value
ABSOLUTE_URL_OVERRIDES  
{}
ADMINS  
[]
ALLOWED_HOSTS   
['*']
APPEND_SLASH    
True
AUTHENTICATION_BACKENDS 
['django.contrib.auth.backends.ModelBackend']
AUTH_PASSWORD_VALIDATORS    
'********************'
AUTH_USER_MODEL 
'auth.User'
BASE_DIR    
PosixPath('/app')
CACHES  
{'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}}
CACHE_MIDDLEWARE_ALIAS  
'default'
CACHE_MIDDLEWARE_KEY_PREFIX 
'********************'
CACHE_MIDDLEWARE_SECONDS    
600
CORS_ALLOW_ALL_ORIGINS  
True
CSRF_COOKIE_AGE 
31449600
CSRF_COOKIE_DOMAIN  
None
CSRF_COOKIE_HTTPONLY    
False
CSRF_COOKIE_NAME    
'csrftoken'
CSRF_COOKIE_PATH    
'/'
CSRF_COOKIE_SAMESITE    
'Lax'
CSRF_COOKIE_SECURE  
False
CSRF_FAILURE_VIEW   
'django.views.csrf.csrf_failure'
CSRF_HEADER_NAME    
'HTTP_X_CSRFTOKEN'
CSRF_TRUSTED_ORIGINS    
['https://web-production-603f.up.railway.app']
CSRF_USE_SESSIONS   
False
DATABASES   
{'default': {'ATOMIC_REQUESTS': False,
             'AUTOCOMMIT': True,
             'CONN_MAX_AGE': 600,
             'ENGINE': 'django.db.backends.postgresql_psycopg2',
             'HOST': 'localhost',
             'NAME': 'alumni_network',
             'OPTIONS': {},
             'PASSWORD': '********************',
             'PORT': 5432,
             'TEST': {'CHARSET': None,
                      'COLLATION': None,
                      'MIGRATE': True,
                      'MIRROR': None,
                      'NAME': None},
             'TIME_ZONE': None,
             'USER': 'alumni_network_user'}}
DATABASE_ROUTERS    
[]
DATA_UPLOAD_MAX_MEMORY_SIZE 
2621440
DATA_UPLOAD_MAX_NUMBER_FIELDS   
1000
DATETIME_FORMAT 
'N j, Y, P'
DATETIME_INPUT_FORMATS  
['%Y-%m-%d %H:%M:%S',
 '%Y-%m-%d %H:%M:%S.%f',
 '%Y-%m-%d %H:%M',
 '%m/%d/%Y %H:%M:%S',
 '%m/%d/%Y %H:%M:%S.%f',
 '%m/%d/%Y %H:%M',
 '%m/%d/%y %H:%M:%S',
 '%m/%d/%y %H:%M:%S.%f',
 '%m/%d/%y %H:%M']
DATE_FORMAT 
'N j, Y'
DATE_INPUT_FORMATS  
['%Y-%m-%d',
 '%m/%d/%Y',
 '%m/%d/%y',
 '%b %d %Y',
 '%b %d, %Y',
 '%d %b %Y',
 '%d %b, %Y',
 '%B %d %Y',
 '%B %d, %Y',
 '%d %B %Y',
 '%d %B, %Y']
DEBUG   
True
DEBUG_PROPAGATE_EXCEPTIONS  
False
DECIMAL_SEPARATOR   
'.'
DEFAULT_AUTO_FIELD  
'django.db.models.BigAutoField'
DEFAULT_CHARSET 
'utf-8'
DEFAULT_EXCEPTION_REPORTER  
'django.views.debug.ExceptionReporter'
DEFAULT_EXCEPTION_REPORTER_FILTER   
'django.views.debug.SafeExceptionReporterFilter'
DEFAULT_FILE_STORAGE    
'django.core.files.storage.FileSystemStorage'
DEFAULT_FROM_EMAIL  
'webmaster@localhost'
DEFAULT_INDEX_TABLESPACE    
''
DEFAULT_TABLESPACE  
''
DISALLOWED_USER_AGENTS  
[]
EMAIL_BACKEND   
'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST  
'localhost'
EMAIL_HOST_PASSWORD 
'********************'
EMAIL_HOST_USER 
''
EMAIL_PORT  
25
EMAIL_SSL_CERTFILE  
None
EMAIL_SSL_KEYFILE   
'********************'
EMAIL_SUBJECT_PREFIX    
'[Django] '
EMAIL_TIMEOUT   
None
EMAIL_USE_LOCALTIME 
False
EMAIL_USE_SSL   
False
EMAIL_USE_TLS   
False
FILE_UPLOAD_DIRECTORY_PERMISSIONS   
None
FILE_UPLOAD_HANDLERS    
['django.core.files.uploadhandler.MemoryFileUploadHandler',
 'django.core.files.uploadhandler.TemporaryFileUploadHandler']
FILE_UPLOAD_MAX_MEMORY_SIZE 
2621440
FILE_UPLOAD_PERMISSIONS 
420
FILE_UPLOAD_TEMP_DIR    
None
FIRST_DAY_OF_WEEK   
0
FIXTURE_DIRS    
[]
FORCE_SCRIPT_NAME   
None
FORMAT_MODULE_PATH  
None
FORM_RENDERER   
'django.forms.renderers.DjangoTemplates'
IGNORABLE_404_URLS  
[]
INSTALLED_APPS  
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'alumni_network_app',
 'corsheaders',
 'rest_framework',
 'rest_framework_simplejwt.token_blacklist']
INTERNAL_IPS    
[]
LANGUAGES   
[('af', 'Afrikaans'),
 ('ar', 'Arabic'),
 ('ar-dz', 'Algerian Arabic'),
 ('ast', 'Asturian'),
 ('az', 'Azerbaijani'),
 ('bg', 'Bulgarian'),
 ('be', 'Belarusian'),
 ('bn', 'Bengali'),
 ('br', 'Breton'),
 ('bs', 'Bosnian'),
 ('ca', 'Catalan'),
 ('cs', 'Czech'),
 ('cy', 'Welsh'),
 ('da', 'Danish'),
 ('de', 'German'),
 ('dsb', 'Lower Sorbian'),
 ('el', 'Greek'),
 ('en', 'English'),
 ('en-au', 'Australian English'),
 ('en-gb', 'British English'),
 ('eo', 'Esperanto'),
 ('es', 'Spanish'),
 ('es-ar', 'Argentinian Spanish'),
 ('es-co', 'Colombian Spanish'),
 ('es-mx', 'Mexican Spanish'),
 ('es-ni', 'Nicaraguan Spanish'),
 ('es-ve', 'Venezuelan Spanish'),
 ('et', 'Estonian'),
 ('eu', 'Basque'),
 ('fa', 'Persian'),
 ('fi', 'Finnish'),
 ('fr', 'French'),
 ('fy', 'Frisian'),
 ('ga', 'Irish'),
 ('gd', 'Scottish Gaelic'),
 ('gl', 'Galician'),
 ('he', 'Hebrew'),
 ('hi', 'Hindi'),
 ('hr', 'Croatian'),
 ('hsb', 'Upper Sorbian'),
 ('hu', 'Hungarian'),
 ('hy', 'Armenian'),
 ('ia', 'Interlingua'),
 ('id', 'Indonesian'),
 ('ig', 'Igbo'),
 ('io', 'Ido'),
 ('is', 'Icelandic'),
 ('it', 'Italian'),
 ('ja', 'Japanese'),
 ('ka', 'Georgian'),
 ('kab', 'Kabyle'),
 ('kk', 'Kazakh'),
 ('km', 'Khmer'),
 ('kn', 'Kannada'),
 ('ko', 'Korean'),
 ('ky', 'Kyrgyz'),
 ('lb', 'Luxembourgish'),
 ('lt', 'Lithuanian'),
 ('lv', 'Latvian'),
 ('mk', 'Macedonian'),
 ('ml', 'Malayalam'),
 ('mn', 'Mongolian'),
 ('mr', 'Marathi'),
 ('ms', 'Malay'),
 ('my', 'Burmese'),
 ('nb', 'Norwegian Bokmål'),
 ('ne', 'Nepali'),
 ('nl', 'Dutch'),
 ('nn', 'Norwegian Nynorsk'),
 ('os', 'Ossetic'),
 ('pa', 'Punjabi'),
 ('pl', 'Polish'),
 ('pt', 'Portuguese'),
 ('pt-br', 'Brazilian Portuguese'),
 ('ro', 'Romanian'),
 ('ru', 'Russian'),
 ('sk', 'Slovak'),
 ('sl', 'Slovenian'),
 ('sq', 'Albanian'),
 ('sr', 'Serbian'),
 ('sr-latn', 'Serbian Latin'),
 ('sv', 'Swedish'),
 ('sw', 'Swahili'),
 ('ta', 'Tamil'),
 ('te', 'Telugu'),
 ('tg', 'Tajik'),
 ('th', 'Thai'),
 ('tk', 'Turkmen'),
 ('tr', 'Turkish'),
 ('tt', 'Tatar'),
 ('udm', 'Udmurt'),
 ('uk', 'Ukrainian'),
 ('ur', 'Urdu'),
 ('uz', 'Uzbek'),
 ('vi', 'Vietnamese'),
 ('zh-hans', 'Simplified Chinese'),
 ('zh-hant', 'Traditional Chinese')]
LANGUAGES_BIDI  
['he', 'ar', 'ar-dz', 'fa', 'ur']
LANGUAGE_CODE   
'en-us'
LANGUAGE_COOKIE_AGE 
None
LANGUAGE_COOKIE_DOMAIN  
None
LANGUAGE_COOKIE_HTTPONLY    
False
LANGUAGE_COOKIE_NAME    
'django_language'
LANGUAGE_COOKIE_PATH    
'/'
LANGUAGE_COOKIE_SAMESITE    
None
LANGUAGE_COOKIE_SECURE  
False
LOCALE_PATHS    
[]
LOGGING 
{}
LOGGING_CONFIG  
'logging.config.dictConfig'
LOGIN_REDIRECT_URL  
'/accounts/profile/'
LOGIN_URL   
'/accounts/login/'
LOGOUT_REDIRECT_URL 
None
MANAGERS    
[]
MEDIA_ROOT  
''
MEDIA_URL   
'/'
MESSAGE_STORAGE 
'django.contrib.messages.storage.fallback.FallbackStorage'
MIDDLEWARE  
['django.middleware.security.SecurityMiddleware',
 'whitenoise.middleware.WhiteNoiseMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']
MIGRATION_MODULES   
{}
MONTH_DAY_FORMAT    
'F j'
NUMBER_GROUPING 
0
PASSWORD_HASHERS    
'********************'
PASSWORD_RESET_TIMEOUT  
'********************'
PREPEND_WWW 
False
REST_FRAMEWORK  
{'DEFAULT_AUTHENTICATION_CLASSES': ('rest_framework_simplejwt.authentication.JWTAuthentication',)}
ROOT_URLCONF    
'alumni_network_proj.urls'
SECRET_KEY  
'********************'
SECURE_CONTENT_TYPE_NOSNIFF 
True
SECURE_CROSS_ORIGIN_OPENER_POLICY   
'same-origin'
SECURE_HSTS_INCLUDE_SUBDOMAINS  
False
SECURE_HSTS_PRELOAD 
False
SECURE_HSTS_SECONDS 
0
SECURE_PROXY_SSL_HEADER 
None
SECURE_REDIRECT_EXEMPT  
[]
SECURE_REFERRER_POLICY  
'same-origin'
SECURE_SSL_HOST 
None
SECURE_SSL_REDIRECT 
False
SERVER_EMAIL    
'root@localhost'
SESSION_CACHE_ALIAS 
'default'
SESSION_COOKIE_AGE  
1209600
SESSION_COOKIE_DOMAIN   
None
SESSION_COOKIE_HTTPONLY 
True
SESSION_COOKIE_NAME 
'sessionid'
SESSION_COOKIE_PATH 
'/'
SESSION_COOKIE_SAMESITE 
'Lax'
SESSION_COOKIE_SECURE   
False
SESSION_ENGINE  
'django.contrib.sessions.backends.db'
SESSION_EXPIRE_AT_BROWSER_CLOSE 
False
SESSION_FILE_PATH   
None
SESSION_SAVE_EVERY_REQUEST  
False
SESSION_SERIALIZER  
'django.contrib.sessions.serializers.JSONSerializer'
SETTINGS_MODULE 
'alumni_network_proj.settings'
SHORT_DATETIME_FORMAT   
'm/d/Y P'
SHORT_DATE_FORMAT   
'm/d/Y'
SIGNING_BACKEND 
'django.core.signing.TimestampSigner'
SILENCED_SYSTEM_CHECKS  
[]
SIMPLE_JWT  
{'ACCESS_TOKEN_LIFETIME': '********************',
 'ALGORITHM': 'HS256',
 'AUDIENCE': None,
 'AUTH_HEADER_NAME': 'HTTP_AUTHORIZATION',
 'AUTH_HEADER_TYPES': ('Bearer',),
 'AUTH_TOKEN_CLASSES': '********************',
 'BLACKLIST_AFTER_ROTATION': True,
 'ISSUER': None,
 'JTI_CLAIM': 'jti',
 'JWK_URL': None,
 'LEEWAY': 0,
 'REFRESH_TOKEN_LIFETIME': '********************',
 'ROTATE_REFRESH_TOKENS': '********************',
 'SLIDING_TOKEN_LIFETIME': '********************',
 'SLIDING_TOKEN_REFRESH_EXP_CLAIM': '********************',
 'SLIDING_TOKEN_REFRESH_LIFETIME': '********************',
 'TOKEN_TYPE_CLAIM': '********************',
 'TOKEN_USER_CLASS': '********************',
 'UPDATE_LAST_LOGIN': False,
 'USER_AUTHENTICATION_RULE': 'rest_framework_simplejwt.authentication.default_user_authentication_rule',
 'USER_ID_CLAIM': 'user_id',
 'USER_ID_FIELD': 'id',
 'VERIFYING_KEY': '********************'}
STATICFILES_DIRS    
['/app/static']
STATICFILES_FINDERS 
['django.contrib.staticfiles.finders.FileSystemFinder',
 'django.contrib.staticfiles.finders.AppDirectoriesFinder']
STATICFILES_STORAGE 
'django.contrib.staticfiles.storage.StaticFilesStorage'
STATIC_ROOT 
'/app/staticfiles'
STATIC_URL  
'/static/'
TEMPLATES   
[{'APP_DIRS': True,
  'BACKEND': 'django.template.backends.django.DjangoTemplates',
  'DIRS': [],
  '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']}}]
TEST_NON_SERIALIZED_APPS    
[]
TEST_RUNNER 
'django.test.runner.DiscoverRunner'
THOUSAND_SEPARATOR  
','
TIME_FORMAT 
'P'
TIME_INPUT_FORMATS  
['%H:%M:%S', '%H:%M:%S.%f', '%H:%M']
TIME_ZONE   
'UTC'
USE_DEPRECATED_PYTZ 
False
USE_I18N    
True
USE_L10N    
True
USE_THOUSAND_SEPARATOR  
False
USE_TZ  
True
USE_X_FORWARDED_HOST    
False
USE_X_FORWARDED_PORT    
False
WSGI_APPLICATION    
'alumni_network_proj.wsgi.application'
X_FRAME_OPTIONS 
'DENY'
YEAR_MONTH_FORMAT   
'F Y'

I've tried making changes to environment variables, also tried railway run python3 manage.py createsuperuser but it will tell me the superuser already exists. I just don't know where the error is coming from so I don't know where to look?

CodePudding user response:

the error says that there is no connection to the database. It is working locally because you have installed postgresql locally. Have you installed a postgres on railway and what is the host of the database ? Django settings needs to know the host name of the database. Btw try to create different environment settings (local => dev and prod).

  • Related