Can't logging into django admin panel - django

In production, after entering username and password in order to access django admin panel, the website arrises following error 'OperationalError at /admin/login/
unable to open database file'
Here's my settings of db.sqlite3
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# BASE_DIR => /var/www/name_of_website/src where db.sqlite3 stored
So far, I have changed the read/write mode of db.sqlite3 to -rw-rw-rw-
And it is my apache log file
/var/log/apache/error.log
[Mon Nov 27 12:16:26.737719 2017] [wsgi:error] [pid 13974] Traceback (most recent call last):
[Mon Nov 27 12:16:26.737724 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 65, in execute
[Mon Nov 27 12:16:26.737728 2017] [wsgi:error] [pid 13974] return self.cursor.execute(sql, params)
[Mon Nov 27 12:16:26.737733 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/db/backends/sqlite3/base.py", line 328, in execute
[Mon Nov 27 12:16:26.737737 2017] [wsgi:error] [pid 13974] return Database.Cursor.execute(self, query, params)
[Mon Nov 27 12:16:26.737740 2017] [wsgi:error] [pid 13974] sqlite3.OperationalError: unable to open database file
[Mon Nov 27 12:16:26.737744 2017] [wsgi:error] [pid 13974]
[Mon Nov 27 12:16:26.737747 2017] [wsgi:error] [pid 13974] The above exception was the direct cause of the following exception:
[Mon Nov 27 12:16:26.737751 2017] [wsgi:error] [pid 13974]
[Mon Nov 27 12:16:26.737754 2017] [wsgi:error] [pid 13974] Traceback (most recent call last):
[Mon Nov 27 12:16:26.737758 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py", line 41, in inner
[Mon Nov 27 12:16:26.737761 2017] [wsgi:error] [pid 13974] response = get_response(request)
[Mon Nov 27 12:16:26.737765 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 187, in _get_response
[Mon Nov 27 12:16:26.737769 2017] [wsgi:error] [pid 13974] response = self.process_exception_by_middleware(e, request)
[Mon Nov 27 12:16:26.737772 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 185, in _get_response
[Mon Nov 27 12:16:26.737776 2017] [wsgi:error] [pid 13974] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Mon Nov 27 12:16:26.737779 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
[Mon Nov 27 12:16:26.737783 2017] [wsgi:error] [pid 13974] response = view_func(request, *args, **kwargs)
[Mon Nov 27 12:16:26.737786 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/contrib/admin/sites.py", line 393, in login
[Mon Nov 27 12:16:26.737790 2017] [wsgi:error] [pid 13974] return LoginView.as_view(**defaults)(request)
[Mon Nov 27 12:16:26.737793 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/views/generic/base.py", line 68, in view
[Mon Nov 27 12:16:26.737797 2017] [wsgi:error] [pid 13974] return self.dispatch(request, *args, **kwargs)
[Mon Nov 27 12:16:26.737800 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/utils/decorators.py", line 67, in _wrapper
[Mon Nov 27 12:16:26.737803 2017] [wsgi:error] [pid 13974] return bound_func(*args, **kwargs)
[Mon Nov 27 12:16:26.737807 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/views/decorators/debug.py", line 76, in sensitive_post_parameters_wrapper
[Mon Nov 27 12:16:26.737810 2017] [wsgi:error] [pid 13974] return view(request, *args, **kwargs)
[Mon Nov 27 12:16:26.737847 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/utils/decorators.py", line 63, in bound_func
[Mon Nov 27 12:16:26.737852 2017] [wsgi:error] [pid 13974] return func.__get__(self, type(self))(*args2, **kwargs2)
[Mon Nov 27 12:16:26.737856 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/utils/decorators.py", line 67, in _wrapper
[Mon Nov 27 12:16:26.737859 2017] [wsgi:error] [pid 13974] return bound_func(*args, **kwargs)
[Mon Nov 27 12:16:26.737862 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/utils/decorators.py", line 149, in _wrapped_view
[Mon Nov 27 12:16:26.737865 2017] [wsgi:error] [pid 13974] response = view_func(request, *args, **kwargs)
[Mon Nov 27 12:16:26.737869 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/utils/decorators.py", line 63, in bound_func
[Mon Nov 27 12:16:26.737872 2017] [wsgi:error] [pid 13974] return func.__get__(self, type(self))(*args2, **kwargs2)
[Mon Nov 27 12:16:26.737875 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/utils/decorators.py", line 67, in _wrapper
[Mon Nov 27 12:16:26.737878 2017] [wsgi:error] [pid 13974] return bound_func(*args, **kwargs)
[Mon Nov 27 12:16:26.737881 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
[Mon Nov 27 12:16:26.737884 2017] [wsgi:error] [pid 13974] response = view_func(request, *args, **kwargs)
[Mon Nov 27 12:16:26.737887 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/utils/decorators.py", line 63, in bound_func
[Mon Nov 27 12:16:26.737891 2017] [wsgi:error] [pid 13974] return func.__get__(self, type(self))(*args2, **kwargs2)
[Mon Nov 27 12:16:26.737894 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/views.py", line 90, in dispatch
[Mon Nov 27 12:16:26.737897 2017] [wsgi:error] [pid 13974] return super(LoginView, self).dispatch(request, *args, **kwargs)
[Mon Nov 27 12:16:26.737900 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/views/generic/base.py", line 88, in dispatch
[Mon Nov 27 12:16:26.737903 2017] [wsgi:error] [pid 13974] return handler(request, *args, **kwargs)
[Mon Nov 27 12:16:26.737906 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/views/generic/edit.py", line 183, in post
[Mon Nov 27 12:16:26.737910 2017] [wsgi:error] [pid 13974] return self.form_valid(form)
[Mon Nov 27 12:16:26.737913 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/views.py", line 119, in form_valid
[Mon Nov 27 12:16:26.737916 2017] [wsgi:error] [pid 13974] auth_login(self.request, form.get_user())
[Mon Nov 27 12:16:26.737919 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/__init__.py", line 139, in login
[Mon Nov 27 12:16:26.737922 2017] [wsgi:error] [pid 13974] request.session.cycle_key()
[Mon Nov 27 12:16:26.737925 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/contrib/sessions/backends/base.py", line 311, in cycle_key
[Mon Nov 27 12:16:26.737928 2017] [wsgi:error] [pid 13974] self.create()
[Mon Nov 27 12:16:26.737931 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/contrib/sessions/backends/db.py", line 54, in create
[Mon Nov 27 12:16:26.737935 2017] [wsgi:error] [pid 13974] self.save(must_create=True)
[Mon Nov 27 12:16:26.737938 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/contrib/sessions/backends/db.py", line 87, in save
[Mon Nov 27 12:16:26.737941 2017] [wsgi:error] [pid 13974] obj.save(force_insert=must_create, force_update=not must_create, using=using)
[Mon Nov 27 12:16:26.737944 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py", line 808, in save
[Mon Nov 27 12:16:26.737958 2017] [wsgi:error] [pid 13974] force_update=force_update, update_fields=update_fields)
[Mon Nov 27 12:16:26.737962 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py", line 838, in save_base
[Mon Nov 27 12:16:26.737965 2017] [wsgi:error] [pid 13974] updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
[Mon Nov 27 12:16:26.737969 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py", line 924, in _save_table
[Mon Nov 27 12:16:26.737972 2017] [wsgi:error] [pid 13974] result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
[Mon Nov 27 12:16:26.737975 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py", line 963, in _do_insert
[Mon Nov 27 12:16:26.737978 2017] [wsgi:error] [pid 13974] using=using, raw=raw)
[Mon Nov 27 12:16:26.737982 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/db/models/manager.py", line 85, in manager_method
[Mon Nov 27 12:16:26.737985 2017] [wsgi:error] [pid 13974] return getattr(self.get_queryset(), name)(*args, **kwargs)
[Mon Nov 27 12:16:26.737988 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/db/models/query.py", line 1076, in _insert
[Mon Nov 27 12:16:26.737991 2017] [wsgi:error] [pid 13974] return query.get_compiler(using=using).execute_sql(return_id)
[Mon Nov 27 12:16:26.737994 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/db/models/sql/compiler.py", line 1107, in execute_sql
[Mon Nov 27 12:16:26.737997 2017] [wsgi:error] [pid 13974] cursor.execute(sql, params)
[Mon Nov 27 12:16:26.738000 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 80, in execute
[Mon Nov 27 12:16:26.738004 2017] [wsgi:error] [pid 13974] return super(CursorDebugWrapper, self).execute(sql, params)
[Mon Nov 27 12:16:26.738007 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 65, in execute
[Mon Nov 27 12:16:26.738010 2017] [wsgi:error] [pid 13974] return self.cursor.execute(sql, params)
[Mon Nov 27 12:16:26.738013 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/db/utils.py", line 94, in __exit__
[Mon Nov 27 12:16:26.738016 2017] [wsgi:error] [pid 13974] six.reraise(dj_exc_type, dj_exc_value, traceback)
[Mon Nov 27 12:16:26.738019 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/utils/six.py", line 685, in reraise
[Mon Nov 27 12:16:26.738022 2017] [wsgi:error] [pid 13974] raise value.with_traceback(tb)
[Mon Nov 27 12:16:26.738025 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 65, in execute
[Mon Nov 27 12:16:26.738028 2017] [wsgi:error] [pid 13974] return self.cursor.execute(sql, params)
[Mon Nov 27 12:16:26.738031 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/db/backends/sqlite3/base.py", line 328, in execute
[Mon Nov 27 12:16:26.738035 2017] [wsgi:error] [pid 13974] return Database.Cursor.execute(self, query, params)
[Mon Nov 27 12:16:26.738041 2017] [wsgi:error] [pid 13974] django.db.utils.OperationalError: unable to open database file
[Mon Nov 27 12:16:26.738054 2017] [wsgi:error] [pid 13974]

Related

Open Edx Third Party Login Integration with Keycloak

I am using edx-ironwood.2-6 in ubuntu 18.08. I am also running keycloak 9.0.0. To enable third-party login using Keycloak I am using the python-social-auth library suggested in edx documentation. Since by default keycloak.py was not available in the edx-ironwood, I copied this keycloak.js file at the location
edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_core/backends
Followed all steps written in comments to setup keycloak and added following information in keycloak.py
SECRET = 'client secret'
PUBLIC_KEY = 'publick key from keycloak'
AUTHORIZATION_URL = 'http://localhost:8080/auth/realms/myrealm/protocol/openid-connect/auth'
ACCESS_TOKEN_URL = 'http://localhost:8080/auth/realms/myrealm/protocol/openid-connect/token'
USER_DETAILS_URL = 'http://localhost:8080/auth/realms/myrealm/protocol/openid-connect/userinfo'
Added following line in the lms.env.json
"THIRD_PARTY_AUTH_BACKENDS":[
"social_core.backends.keycloak.KeycloakOAuth2",
"social_core.backends.google.GoogleOAuth2",
"social_core.backends.linkedin.LinkedinOAuth2"
]
In the Django Admin App, Added a Provider
Name: Keycloak
slug: keycloak
site: localhost:81
backend: keycloak
client Id: 'mooc'
Client Secret: 'secret key'
Also Added client secret in lms.auth.json
"SOCIAL_AUTH_OAUTH_SECRETS": {
"keycloak":"14f89ef1-02ff-48ad-825f-8160e515ec8e"
}
In Keycloak client settings, added access type 'confidential', and redirect uri 'http://localhost:81/auth/complete/keycloak/'
After server restart, In edx login page, login button for keycloak appearing but when I am clicking on it in the browser a message is coming There has been a 500 error on the Open Edx Server
In the apache2 log file following error is coming
[Sat Apr 18 17:09:21.212377 2020] [:error] [pid 8143] Traceback (most recent call last):
[Sat Apr 18 17:09:21.212419 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
[Sat Apr 18 17:09:21.212442 2020] [:error] [pid 8143] response = get_response(request)
[Sat Apr 18 17:09:21.212462 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
[Sat Apr 18 17:09:21.212485 2020] [:error] [pid 8143] response = self._get_response(request)
[Sat Apr 18 17:09:21.212506 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
[Sat Apr 18 17:09:21.212526 2020] [:error] [pid 8143] response = self.process_exception_by_middleware(e, request)
[Sat Apr 18 17:09:21.212548 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
[Sat Apr 18 17:09:21.212569 2020] [:error] [pid 8143] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Sat Apr 18 17:09:21.212589 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/utils/decorators.py", line 185, in inner
[Sat Apr 18 17:09:21.212610 2020] [:error] [pid 8143] return func(*args, **kwargs)
[Sat Apr 18 17:09:21.212630 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
[Sat Apr 18 17:09:21.212651 2020] [:error] [pid 8143] response = view_func(request, *args, **kwargs)
[Sat Apr 18 17:09:21.212671 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_django/utils.py", line 49, in wrapper
[Sat Apr 18 17:09:21.212697 2020] [:error] [pid 8143] return func(request, backend, *args, **kwargs)
[Sat Apr 18 17:09:21.212720 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_django/views.py", line 23, in auth
[Sat Apr 18 17:09:21.212742 2020] [:error] [pid 8143] return do_auth(request.backend, redirect_name=REDIRECT_FIELD_NAME)
[Sat Apr 18 17:09:21.212762 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_core/actions.py", line 29, in do_auth
[Sat Apr 18 17:09:21.212783 2020] [:error] [pid 8143] return backend.start()
[Sat Apr 18 17:09:21.212803 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_core/backends/base.py", line 35, in start
[Sat Apr 18 17:09:21.212823 2020] [:error] [pid 8143] return self.strategy.redirect(self.auth_url())
[Sat Apr 18 17:09:21.212844 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_django/strategy.py", line 88, in redirect
[Sat Apr 18 17:09:21.212864 2020] [:error] [pid 8143] return redirect(url)
[Sat Apr 18 17:09:21.212884 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/shortcuts.py", line 56, in redirect
[Sat Apr 18 17:09:21.212904 2020] [:error] [pid 8143] return redirect_class(resolve_url(to, *args, **kwargs))
[Sat Apr 18 17:09:21.212925 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/shortcuts.py", line 147, in resolve_url
[Sat Apr 18 17:09:21.212945 2020] [:error] [pid 8143] return reverse(to, args=args, kwargs=kwargs)
[Sat Apr 18 17:09:21.212965 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/src/django-wiki/wiki/models/__init__.py", line 90, in reverse
[Sat Apr 18 17:09:21.212986 2020] [:error] [pid 8143] url = original_django_reverse(*args, **kwargs)
[Sat Apr 18 17:09:21.213006 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/urls/base.py", line 91, in reverse
[Sat Apr 18 17:09:21.213026 2020] [:error] [pid 8143] return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
[Sat Apr 18 17:09:21.213047 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/urls/resolvers.py", line 497, in _reverse_with_prefix
[Sat Apr 18 17:09:21.213067 2020] [:error] [pid 8143] raise NoReverseMatch(msg)
[Sat Apr 18 17:09:21.213089 2020] [:error] [pid 8143] NoReverseMatch: Reverse for 'None?scope=profile+email&state=yst8UI8KZihrluHg9R0oUFexFIx0QYGM&redirect_uri=http%3A%2F%2Flocalhost%3A81%2Fauth%2Fcomplete%2Fkeycloak%2F%3Fredirect_state%3Dyst8UI8KZihrluHg9R0oUFexFIx0QYGM&response_type=code&client_id=mooc' not found. 'None?scope=profile+email&state=yst8UI8KZihrluHg9R0oUFexFIx0QYGM&redirect_uri=http%3A%2F%2Flocalhost%3A81%2Fauth%2Fcomplete%2Fkeycloak%2F%3Fredirect_state%3Dyst8UI8KZihrluHg9R0oUFexFIx0QYGM&response_type=code&client_id=mooc' is not a valid view function or pattern name.
I tried same third party integration with same python-social-auth for LinkedIn and that is working.
Since I am just a beginner in the Django, Can anyone help me identify the issue from the above details.
After finding and reading many official resources, I haven't found any solution which worked. So I decided to try my own custom file for keycloak.
Here is the link of the file
https://github.com/ranjeet692/python-social-auth-keycloak,
For open edx users, place this file into this directory
/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_core/backends
Follow the rest instruction as mentioned here
Social Auth Documentation
and restart the server. You should be able to login with keycloak.
There is now an official backend for keycloak in python-social-auth:
https://github.com/python-social-auth/social-core/blob/master/social_core/backends/keycloak.py
Just add
"THIRD_PARTY_AUTH_BACKENDS": [
"social_core.backends.keycloak.KeycloakOAuth2"
],
to your lms.env.json
together with the keycloak config:
"SOCIAL_AUTH_KEYCLOAK_KEY": "openedx",
"SOCIAL_AUTH_KEYCLOAK_SECRET": "...",
"SOCIAL_AUTH_KEYCLOAK_PUBLIC_KEY": "...",
"SOCIAL_AUTH_KEYCLOAK_AUTHORIZATION_URL": "https://YOUR_KEYCLOAK/realms/YOUR_REALM/protocol/openid-connect/auth",
"SOCIAL_AUTH_KEYCLOAK_ACCESS_TOKEN_URL": "https://YOUR_KEYCLOAK/realms/YOUR_REALM/protocol/openid-connect/token",
Restart your installation, then go to:
https://YOUR.LMS/admin/third_party_auth/oauth2providerconfig/
and configure according to https://edx.readthedocs.io/projects/edx-installing-configuring-and-running/en/latest/configuration/tpa/tpa_integrate_open/tpa_oauth.html#additional-oauth2-providers-advanced

How do I tell Django to never use (and totally ignore) SqlLite?

I'm tryign to get a Django application with Python 3.7 working with CentOS 7 and Apache (Mod WSGI). I have a project with a virtual environment set up. How do I turn off SqlLite? I'm not and don't intend to ever use it. I tried running
(dentalenv) [root#server Python-3.7.2]# sudo yum install libsqlite3-dev
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.us-midwest-1.nexcess.net
* epel: mirror.steadfastnet.com
* extras: mirror.us-midwest-1.nexcess.net
* updates: mirror.us-midwest-1.nexcess.net
No package libsqlite3-dev available.
Error: Nothing to do
to install it and then restarting my Apache server. I even rebuilt Python, but I still get the below error, "ModuleNotFoundError: No module named '_sqlite3'"
[Wed Feb 20 04:03:06.627020 2019] [wsgi:error] [pid 11885] Traceback (most recent call last):
[Wed Feb 20 04:03:06.627285 2019] [wsgi:error] [pid 11885] File "/var/www/html/dental/wsgi.py", line 25, in <module>
[Wed Feb 20 04:03:06.627323 2019] [wsgi:error] [pid 11885] application = get_wsgi_application()
[Wed Feb 20 04:03:06.627353 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Wed Feb 20 04:03:06.627378 2019] [wsgi:error] [pid 11885] django.setup(set_prefix=False)
[Wed Feb 20 04:03:06.627405 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
[Wed Feb 20 04:03:06.627429 2019] [wsgi:error] [pid 11885] apps.populate(settings.INSTALLED_APPS)
[Wed Feb 20 04:03:06.627467 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/apps/registry.py", line 112, in populate
[Wed Feb 20 04:03:06.627493 2019] [wsgi:error] [pid 11885] app_config.import_models()
[Wed Feb 20 04:03:06.627520 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/apps/config.py", line 198, in import_models
[Wed Feb 20 04:03:06.627544 2019] [wsgi:error] [pid 11885] self.models_module = import_module(models_module_name)
[Wed Feb 20 04:03:06.627571 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/importlib/__init__.py", line 127, in import_module
[Wed Feb 20 04:03:06.627608 2019] [wsgi:error] [pid 11885] return _bootstrap._gcd_import(name[level:], package, level)
[Wed Feb 20 04:03:06.627636 2019] [wsgi:error] [pid 11885] File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
[Wed Feb 20 04:03:06.627666 2019] [wsgi:error] [pid 11885] File "<frozen importlib._bootstrap>", line 983, in _find_and_load
[Wed Feb 20 04:03:06.627695 2019] [wsgi:error] [pid 11885] File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
[Wed Feb 20 04:03:06.627724 2019] [wsgi:error] [pid 11885] File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
[Wed Feb 20 04:03:06.627754 2019] [wsgi:error] [pid 11885] File "<frozen importlib._bootstrap_external>", line 728, in exec_module
[Wed Feb 20 04:03:06.627783 2019] [wsgi:error] [pid 11885] File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[Wed Feb 20 04:03:06.627812 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/contrib/auth/models.py", line 2, in <module>
[Wed Feb 20 04:03:06.627835 2019] [wsgi:error] [pid 11885] from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
[Wed Feb 20 04:03:06.627861 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/contrib/auth/base_user.py", line 47, in <module>
[Wed Feb 20 04:03:06.627884 2019] [wsgi:error] [pid 11885] class AbstractBaseUser(models.Model):
[Wed Feb 20 04:03:06.627910 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/db/models/base.py", line 101, in __new__
[Wed Feb 20 04:03:06.627933 2019] [wsgi:error] [pid 11885] new_class.add_to_class('_meta', Options(meta, app_label))
[Wed Feb 20 04:03:06.627958 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/db/models/base.py", line 305, in add_to_class
[Wed Feb 20 04:03:06.627981 2019] [wsgi:error] [pid 11885] value.contribute_to_class(cls, name)
[Wed Feb 20 04:03:06.628008 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/db/models/options.py", line 203, in contribute_to_class
[Wed Feb 20 04:03:06.628031 2019] [wsgi:error] [pid 11885] self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
[Wed Feb 20 04:03:06.628058 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/db/__init__.py", line 33, in __getattr__
[Wed Feb 20 04:03:06.628081 2019] [wsgi:error] [pid 11885] return getattr(connections[DEFAULT_DB_ALIAS], item)
[Wed Feb 20 04:03:06.628107 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/db/utils.py", line 202, in __getitem__
[Wed Feb 20 04:03:06.628132 2019] [wsgi:error] [pid 11885] backend = load_backend(db['ENGINE'])
[Wed Feb 20 04:03:06.628159 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/db/utils.py", line 110, in load_backend
[Wed Feb 20 04:03:06.628193 2019] [wsgi:error] [pid 11885] return import_module('%s.base' % backend_name)
[Wed Feb 20 04:03:06.628222 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/importlib/__init__.py", line 127, in import_module
[Wed Feb 20 04:03:06.628243 2019] [wsgi:error] [pid 11885] return _bootstrap._gcd_import(name[level:], package, level)
[Wed Feb 20 04:03:06.628264 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 10, in <module>
[Wed Feb 20 04:03:06.628283 2019] [wsgi:error] [pid 11885] from sqlite3 import dbapi2 as Database
[Wed Feb 20 04:03:06.628304 2019] [wsgi:error] [pid 11885] File "/usr/local/lib/python3.7/sqlite3/__init__.py", line 23, in <module>
[Wed Feb 20 04:03:06.628323 2019] [wsgi:error] [pid 11885] from sqlite3.dbapi2 import *
[Wed Feb 20 04:03:06.628344 2019] [wsgi:error] [pid 11885] File "/usr/local/lib/python3.7/sqlite3/dbapi2.py", line 27, in <module>
[Wed Feb 20 04:03:06.628369 2019] [wsgi:error] [pid 11885] from _sqlite3 import *
[Wed Feb 20 04:03:06.628408 2019] [wsgi:error] [pid 11885] ModuleNotFoundError: No module named '_sqlite3'
[Wed Feb 20 04:03:09.130480 2019] [wsgi:error] [pid 11885] [remote 207.181.224.155:58106] mod_wsgi (pid=11885): Target WSGI script '/var/www/html/dental/wsgi.py' does not contain WSGI application 'application'.

getting urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetErr or(104, 'Connection reset by peer'))

I have setup a Django project with Apache2 and mod_wsgi on Ubuntu 16.04 instance of AWS. Now I am getting urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetErr or(104, 'Connection reset by peer')) error when I try to access mysite.
I have tried almost everything suggested on stackoverflow and other link. but get no luck.
[Mon Jan 28 21:02:52.263398 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] Traceback (most recent call last):
[Mon Jan 28 21:02:52.263457 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
[Mon Jan 28 21:02:52.263537 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] chunked=chunked)
[Mon Jan 28 21:02:52.263613 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 384, in _make_request
[Mon Jan 28 21:02:52.263655 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] six.raise_from(e, None)
[Mon Jan 28 21:02:52.263707 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "<string>", line 2, in raise_from
[Mon Jan 28 21:02:52.263760 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 380, in _make_request
[Mon Jan 28 21:02:52.263799 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] httplib_response = conn.getresponse()
[Mon Jan 28 21:02:52.263851 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
[Mon Jan 28 21:02:52.263903 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] response.begin()
[Mon Jan 28 21:02:52.263943 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/usr/lib/python3.6/http/client.py", line 297, in begin
[Mon Jan 28 21:02:52.263995 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] version, status, reason = self._read_status()
[Mon Jan 28 21:02:52.264032 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/usr/lib/python3.6/http/client.py", line 258, in _read_status
[Mon Jan 28 21:02:52.264086 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
[Mon Jan 28 21:02:52.264129 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/usr/lib/python3.6/socket.py", line 586, in readinto
[Mon Jan 28 21:02:52.264165 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] return self._sock.recv_into(b)
[Mon Jan 28 21:02:52.264200 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] ConnectionResetError: [Errno 104] Connection reset by peer
[Mon Jan 28 21:02:52.264234 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898]
[Mon Jan 28 21:02:52.264268 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] During handling of the above exception, another exception occurred:
[Mon Jan 28 21:02:52.302940 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898]
[Mon Jan 28 21:02:52.302961 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] Traceback (most recent call last):
[Mon Jan 28 21:02:52.302991 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/django/core/handlers/except ion.py", line 34, in inner
[Mon Jan 28 21:02:52.302994 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] response = get_response(request)
[Mon Jan 28 21:02:52.302996 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/django/core/handlers/base.p y", line 126, in _get_response
[Mon Jan 28 21:02:52.302999 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] response = self.process_exception_by_middleware(e, request)
[Mon Jan 28 21:02:52.303001 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/django/core/handlers/base.p y", line 124, in _get_response
[Mon Jan 28 21:02:52.303004 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Mon Jan 28 21:02:52.303006 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/django/views/decorators/csr f.py", line 54, in wrapped_view
[Mon Jan 28 21:02:52.303009 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] return view_func(*args, **kwargs)
[Mon Jan 28 21:02:52.303011 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/home/jshree/Dscrapper/soqqlesocial/data_scrapper/views.py", line 63 , in request_page
[Mon Jan 28 21:02:52.303014 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] twitter.scrap_tweets(rDate, rDatePre, uName, lName)
[Mon Jan 28 21:02:52.303017 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/home/jshree/Dscrapper/soqqlesocial/twitter.py", line 48, in scrap_t weets
[Mon Jan 28 21:02:52.303019 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] drw = webdriver.Chrome(executable_path='/usr/bin/chromedriver', options= options)
[Mon Jan 28 21:02:52.303021 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/selenium/webdriver/chrome/w ebdriver.py", line 81, in __init__
[Mon Jan 28 21:02:52.303024 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] desired_capabilities=desired_capabilities)
[Mon Jan 28 21:02:52.303026 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/selenium/webdriver/remote/w ebdriver.py", line 157, in __init__
[Mon Jan 28 21:02:52.303029 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] self.start_session(capabilities, browser_profile)
[Mon Jan 28 21:02:52.303031 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/selenium/webdriver/remote/w ebdriver.py", line 252, in start_session
[Mon Jan 28 21:02:52.303034 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] response = self.execute(Command.NEW_SESSION, parameters)
[Mon Jan 28 21:02:52.303036 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/selenium/webdriver/remote/w ebdriver.py", line 319, in execute
[Mon Jan 28 21:02:52.303038 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] response = self.command_executor.execute(driver_command, params)
[Mon Jan 28 21:02:52.303041 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/selenium/webdriver/remote/r emote_connection.py", line 374, in execute
[Mon Jan 28 21:02:52.303043 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] return self._request(command_info[0], url, body=data)
[Mon Jan 28 21:02:52.303048 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/selenium/webdriver/remote/r emote_connection.py", line 397, in _request
[Mon Jan 28 21:02:52.303051 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] resp = self._conn.request(method, url, body=body, headers=headers)
[Mon Jan 28 21:02:52.303053 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/request.py", line 7 2, in request
[Mon Jan 28 21:02:52.303056 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] **urlopen_kw)
[Mon Jan 28 21:02:52.303058 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/request.py", line 1 50, in request_encode_body
[Mon Jan 28 21:02:52.303060 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] return self.urlopen(method, url, **extra_kw)
[Mon Jan 28 21:02:52.303063 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/poolmanager.py", li ne 323, in urlopen
[Mon Jan 28 21:02:52.303065 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] response = conn.urlopen(method, u.request_uri, **kw)
[Mon Jan 28 21:02:52.303067 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
[Mon Jan 28 21:02:52.303070 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] _stacktrace=sys.exc_info()[2])
[Mon Jan 28 21:02:52.303072 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/util/retry.py", lin e 367, in increment
[Mon Jan 28 21:02:52.303075 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] raise six.reraise(type(error), error, _stacktrace)
[Mon Jan 28 21:02:52.303077 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/packages/six.py", l ine 685, in reraise
[Mon Jan 28 21:02:52.303079 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] raise value.with_traceback(tb)
[Mon Jan 28 21:02:52.303082 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
[Mon Jan 28 21:02:52.303084 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] chunked=chunked)
[Mon Jan 28 21:02:52.303086 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 384, in _make_request
[Mon Jan 28 21:02:52.303089 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] six.raise_from(e, None)
[Mon Jan 28 21:02:52.303091 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "<string>", line 2, in raise_from
[Mon Jan 28 21:02:52.303093 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 380, in _make_request
[Mon Jan 28 21:02:52.303096 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] httplib_response = conn.getresponse()
[Mon Jan 28 21:02:52.303098 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
[Mon Jan 28 21:02:52.303100 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] response.begin()
[Mon Jan 28 21:02:52.303105 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/usr/lib/python3.6/http/client.py", line 297, in begin
[Mon Jan 28 21:02:52.303107 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] version, status, reason = self._read_status()
[Mon Jan 28 21:02:52.303110 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/usr/lib/python3.6/http/client.py", line 258, in _read_status
[Mon Jan 28 21:02:52.303112 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
[Mon Jan 28 21:02:52.303114 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/usr/lib/python3.6/socket.py", line 586, in readinto
[Mon Jan 28 21:02:52.303117 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] return self._sock.recv_into(b)
[Mon Jan 28 21:02:52.303124 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetErr or(104, 'Connection reset by peer'))
update
I have used request-timeout flag in apache conf file by which I have got rid of this error but still getting 504 Gateway Time-out error page after a some time of wait. Any idea to get rid of this or handle it.

Can't upload media files from elastic beanstalk/ec2 server

Hey I've been stuck on a problem for a while now where I can upload media files from my localhost to AWS S3, but when I deploy to EB/EC2 I'm getting a 504 gateway timeout when uploading media files. On my development server the uploads work fine and are stored in s3 without any problem.
I'm currently using django-storages but I have tried django-storages-redux and django-s3-storages and I have the same problem where it works on my localhost but on my deployed server I get the 504 Gateway Timeout and the file is not uploaded to s3.
I have my settings files broken out into dev and prod. In my prod settings I have the following:
# S3 FILE SETTINGS
AWS_STORAGE_BUCKET_NAME = 'project-assets'
AWS_S3_CUSTOM_DOMAIN = 'cdn.domain.com'
ASSETS_PREFIX = 'app' # prefix in the bucket
MEDIA_PREFIX = ASSETS_PREFIX + '/uploads/'
DEFAULT_FILE_STORAGE = 'core.storages.MediaStorage'
STATICFILES_STORAGE = 'core.storages.StaticStorage'
To test on development I simply move these settings to the bottom of my dev settings.
I have these custom prefixes to store it in a specific directory on s3.
# storages.py
from django.conf import settings
from storages.backends.s3boto import S3BotoStorage
class StaticStorage(S3BotoStorage):
def __init__(self, *args, **kwargs):
kwargs['location'] = settings.ASSETS_PREFIX
return super(StaticStorage, self).__init__(*args, **kwargs)
class MediaStorage(S3BotoStorage):
def __init__(self, *args, **kwargs):
kwargs['location'] = settings.MEDIA_PREFIX
return super(MediaStorage, self).__init__(*args, **kwargs)
I have gotten this error before on other projects, and it usually had to do with the AWS_REGION. I have tried also using that setting but have the same results. My S3 is stored in 'us-west-2' (default) so as far as I have read I don't need to specify the region.
Here is the stacktrace that appears in my logs when I try to upload on my deployed instance.
Traceback (most recent call last):
File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/handlers/exception.py", line 39, in inner
[Tue Sep 27 16:01:31.991596 2016] [:error] [pid 13870] response = get_response(request)
[Tue Sep 27 16:01:31.991598 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/handlers/base.py", line 187, in _get_response
[Tue Sep 27 16:01:31.991600 2016] [:error] [pid 13870] response = self.process_exception_by_middleware(e, request)
[Tue Sep 27 16:01:31.991602 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/handlers/base.py", line 185, in _get_response
[Tue Sep 27 16:01:31.991604 2016] [:error] [pid 13870] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Tue Sep 27 16:01:31.991606 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
[Tue Sep 27 16:01:31.991608 2016] [:error] [pid 13870] return view_func(*args, **kwargs)
[Tue Sep 27 16:01:31.991609 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/viewsets.py", line 87, in view
[Tue Sep 27 16:01:31.991619 2016] [:error] [pid 13870] return self.dispatch(request, *args, **kwargs)
[Tue Sep 27 16:01:31.991621 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/views.py", line 474, in dispatch
[Tue Sep 27 16:01:31.991623 2016] [:error] [pid 13870] response = self.handle_exception(exc)
[Tue Sep 27 16:01:31.991625 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/views.py", line 434, in handle_exception
[Tue Sep 27 16:01:31.991626 2016] [:error] [pid 13870] self.raise_uncaught_exception(exc)
[Tue Sep 27 16:01:31.991628 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/views.py", line 471, in dispatch
[Tue Sep 27 16:01:31.991630 2016] [:error] [pid 13870] response = handler(request, *args, **kwargs)
[Tue Sep 27 16:01:31.991631 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/mixins.py", line 21, in create
[Tue Sep 27 16:01:31.991633 2016] [:error] [pid 13870] self.perform_create(serializer)
[Tue Sep 27 16:01:31.991634 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/mixins.py", line 26, in perform_create
[Tue Sep 27 16:01:31.991636 2016] [:error] [pid 13870] serializer.save()
[Tue Sep 27 16:01:31.991638 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/serializers.py", line 192, in save
[Tue Sep 27 16:01:31.991639 2016] [:error] [pid 13870] self.instance = self.create(validated_data)
[Tue Sep 27 16:01:31.991641 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/serializers.py", line 873, in create
[Tue Sep 27 16:01:31.991643 2016] [:error] [pid 13870] instance = ModelClass.objects.create(**validated_data)
[Tue Sep 27 16:01:31.991644 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/manager.py", line 85, in manager_method
[Tue Sep 27 16:01:31.991646 2016] [:error] [pid 13870] return getattr(self.get_queryset(), name)(*args, **kwargs)
[Tue Sep 27 16:01:31.991659 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/query.py", line 399, in create
[Tue Sep 27 16:01:31.991661 2016] [:error] [pid 13870] obj.save(force_insert=True, using=self.db)
[Tue Sep 27 16:01:31.991663 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/base.py", line 796, in save
[Tue Sep 27 16:01:31.991665 2016] [:error] [pid 13870] force_update=force_update, update_fields=update_fields)
[Tue Sep 27 16:01:31.991666 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/base.py", line 824, in save_base
[Tue Sep 27 16:01:31.991668 2016] [:error] [pid 13870] updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
[Tue Sep 27 16:01:31.991670 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/base.py", line 908, in _save_table
[Tue Sep 27 16:01:31.991672 2016] [:error] [pid 13870] result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
[Tue Sep 27 16:01:31.991673 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/base.py", line 947, in _do_insert
[Tue Sep 27 16:01:31.991675 2016] [:error] [pid 13870] using=using, raw=raw)
[Tue Sep 27 16:01:31.991677 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/manager.py", line 85, in manager_method
[Tue Sep 27 16:01:31.991679 2016] [:error] [pid 13870] return getattr(self.get_queryset(), name)(*args, **kwargs)
[Tue Sep 27 16:01:31.991680 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/query.py", line 1045, in _insert
[Tue Sep 27 16:01:31.991682 2016] [:error] [pid 13870] return query.get_compiler(using=using).execute_sql(return_id)
[Tue Sep 27 16:01:31.991686 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 1053, in execute_sql
[Tue Sep 27 16:01:31.991688 2016] [:error] [pid 13870] for sql, params in self.as_sql():
[Tue Sep 27 16:01:31.991690 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 1006, in as_sql
[Tue Sep 27 16:01:31.991692 2016] [:error] [pid 13870] for obj in self.query.objs
[Tue Sep 27 16:01:31.991693 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 1006, in <listcomp>
[Tue Sep 27 16:01:31.991695 2016] [:error] [pid 13870] for obj in self.query.objs
[Tue Sep 27 16:01:31.991697 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 1005, in <listcomp>
[Tue Sep 27 16:01:31.991699 2016] [:error] [pid 13870] [self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields]
[Tue Sep 27 16:01:31.991701 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 955, in pre_save_val
[Tue Sep 27 16:01:31.991702 2016] [:error] [pid 13870] return field.pre_save(obj, add=True)
[Tue Sep 27 16:01:31.991704 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/fields/files.py", line 292, in pre_save
[Tue Sep 27 16:01:31.991706 2016] [:error] [pid 13870] file.save(file.name, file, save=False)
[Tue Sep 27 16:01:31.991708 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/fields/files.py", line 91, in save
[Tue Sep 27 16:01:31.991709 2016] [:error] [pid 13870] self.name = self.storage.save(name, content, max_length=self.field.max_length)
[Tue Sep 27 16:01:31.991711 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/files/storage.py", line 54, in save
[Tue Sep 27 16:01:31.991713 2016] [:error] [pid 13870] return self._save(name, content)
[Tue Sep 27 16:01:31.991714 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/storages/backends/s3boto.py", line 413, in _save
[Tue Sep 27 16:01:31.991716 2016] [:error] [pid 13870] self._save_content(key, content, headers=headers)
[Tue Sep 27 16:01:31.991718 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/storages/backends/s3boto.py", line 424, in _save_content
[Tue Sep 27 16:01:31.991720 2016] [:error] [pid 13870] rewind=True, **kwargs)
[Tue Sep 27 16:01:31.991721 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/s3/key.py", line 1293, in set_contents_from_file
[Tue Sep 27 16:01:31.991723 2016] [:error] [pid 13870] chunked_transfer=chunked_transfer, size=size)
[Tue Sep 27 16:01:31.991725 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/s3/key.py", line 750, in send_file
[Tue Sep 27 16:01:31.991727 2016] [:error] [pid 13870] chunked_transfer=chunked_transfer, size=size)
[Tue Sep 27 16:01:31.991728 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/s3/key.py", line 951, in _send_file_internal
[Tue Sep 27 16:01:31.991730 2016] [:error] [pid 13870] query_args=query_args
[Tue Sep 27 16:01:31.991732 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/s3/connection.py", line 668, in make_request
[Tue Sep 27 16:01:31.991734 2016] [:error] [pid 13870] retry_handler=retry_handler
[Tue Sep 27 16:01:31.991735 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/connection.py", line 1071, in make_request
[Tue Sep 27 16:01:31.991737 2016] [:error] [pid 13870] retry_handler=retry_handler)
[Tue Sep 27 16:01:31.991739 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/connection.py", line 1030, in _mexe
[Tue Sep 27 16:01:31.991743 2016] [:error] [pid 13870] raise ex
[Tue Sep 27 16:01:31.991744 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/connection.py", line 940, in _mexe
[Tue Sep 27 16:01:31.991746 2016] [:error] [pid 13870] request.body, request.headers)
[Tue Sep 27 16:01:31.991748 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/s3/key.py", line 844, in sender
[Tue Sep 27 16:01:31.991750 2016] [:error] [pid 13870] http_conn.send(chunk)
[Tue Sep 27 16:01:31.991751 2016] [:error] [pid 13870] File "/usr/lib64/python3.4/http/client.py", line 917, in send
[Tue Sep 27 16:01:31.991753 2016] [:error] [pid 13870] self.sock.sendall(data)
[Tue Sep 27 16:01:31.991755 2016] [:error] [pid 13870] File "/usr/lib64/python3.4/ssl.py", line 723, in sendall
[Tue Sep 27 16:01:31.991756 2016] [:error] [pid 13870] v = self.send(data[count:])
[Tue Sep 27 16:01:31.991758 2016] [:error] [pid 13870] File "/usr/lib64/python3.4/ssl.py", line 684, in send
[Tue Sep 27 16:01:31.991760 2016] [:error] [pid 13870] v = self._sslobj.write(data)
[Tue Sep 27 16:01:31.991763 2016] [:error] [pid 13870] ConnectionResetError: [Errno 104] Connection reset by peer
I thought maybe there was a problem with ssl (everything is on https) and tried setting the AWS_S3_SECURE_URLS = True setting but have the same result.
I've also tried turning off the https redirect and uploading through http:// and have the same result again.
Any ideas are welcome, thanks in advance!
Well, as expected it was something very simple. I didn't load my id/key into the environment variables.

Uninstalling django-haystack

I have an issue with haystack https://stackoverflow.com/q/33669864/4910881 that requires me to uninstall it for now. I commented out haystack from installed apps expecting it will start throwing django import errors or similar errors but it still returning an internal server error.
[Thu Nov 12 15:32:03.579793 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] for conn in connections.all():
[Thu Nov 12 15:32:03.579802 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 112, in all
[Thu Nov 12 15:32:03.579815 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] return [self[alias] for alias in self.connections_info]
[Thu Nov 12 15:32:03.579823 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 100, in __getitem__
[Thu Nov 12 15:32:03.579836 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] self._connections[key] = load_backend(self.connections_info[key]['ENGINE'])(using=key)
[Thu Nov 12 15:32:03.579844 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 53, in load_backend
[Thu Nov 12 15:32:03.579857 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] return import_class(full_backend_path)
[Thu Nov 12 15:32:03.579865 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 23, in import_class
[Thu Nov 12 15:32:03.579878 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] raise ImportError("The Python module '%s' has no '%s' class." % (module_path, class_name))
[Thu Nov 12 15:32:03.579894 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] ImportError: The Python module 'xapian_backend' has no 'XapianEngine' class.
[Thu Nov 12 15:32:03.626881 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] mod_wsgi (pid=191252): Exception occurred processing WSGI script '/home/kbuzz/webapps/revised/kb/kb/wsgi.py'.
[Thu Nov 12 15:32:03.626926 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] Traceback (most recent call last):
[Thu Nov 12 15:32:03.626950 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] File "/home/kbuzz/lib/python2.7/django/core/handlers/wsgi.py", line 175, in __call__
[Thu Nov 12 15:32:03.626989 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] signals.request_started.send(sender=self.__class__)
[Thu Nov 12 15:32:03.627014 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] File "/home/kbuzz/lib/python2.7/django/dispatch/dispatcher.py", line 198, in send
[Thu Nov 12 15:32:03.627041 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] response = receiver(signal=self, sender=sender, **named)
[Thu Nov 12 15:32:03.627057 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] File "/home/kbuzz/lib/python2.7/haystack/__init__.py", line 59, in reset_search_queries
[Thu Nov 12 15:32:03.627082 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] for conn in connections.all():
[Thu Nov 12 15:32:03.627097 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 112, in all
[Thu Nov 12 15:32:03.627123 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] return [self[alias] for alias in self.connections_info]
[Thu Nov 12 15:32:03.627138 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 100, in __getitem__
[Thu Nov 12 15:32:03.627161 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] self._connections[key] = load_backend(self.connections_info[key]['ENGINE'])(using=key)
[Thu Nov 12 15:32:03.627176 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 53, in load_backend
[Thu Nov 12 15:32:03.627199 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] return import_class(full_backend_path)
[Thu Nov 12 15:32:03.627214 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 23, in import_class
[Thu Nov 12 15:32:03.627237 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] raise ImportError("The Python module '%s' has no '%s' class." % (module_path, class_name))
[Thu Nov 12 15:32:03.627263 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] ImportError: The Python module 'xapian_backend' has no 'XapianEngine' class.
Try removing all related .pyc files