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

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.

Related

Can't logging into django admin panel

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]

Encountering error getting Spacy to load models

I've deployed a Django web app in Elastic Beanstalk and I'm trying to implement spacy, yet encountering errors.
I've listed the download link for the en_core_web_sm in my requirements.txt as https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-1.2.0/en_core_web_sm-1.2.0.tar.gz
I'm importing it in my code my calling import en_core_web_sm and later trying to load it with:
nlp = en_core_web_sm.load()
However in my logs from eb I'm getting errors indicating the model isn't loading properly. Am I missing something here? My instance is configured for 2gb of RAM, that might not be enough, but it shouldn't effect the loading of the model, right? Why would it load the tokenizer but not the model?
[Fri Sep 01 04:33:49.276836 2017] [:error] [pid 23201] \x1b[93m Warning: no model found for 'en'\x1b[0m
[Fri Sep 01 04:33:49.276841 2017] [:error] [pid 23201]
[Fri Sep 01 04:33:49.276849 2017] [:error] [pid 23201]
[Fri Sep 01 04:33:49.276851 2017] [:error] [pid 23201] Only loading the 'en' tokenizer.
[Fri Sep 01 04:33:49.276855 2017] [:error] [pid 23201]
[Fri Sep 01 04:33:49.333165 2017] [:error] [pid 23201] Internal Server Error: /webhookmb/
[Fri Sep 01 04:33:49.333187 2017] [:error] [pid 23201] Traceback (most recent call last):
[Fri Sep 01 04:33:49.333189 2017] [:error] [pid 23201] File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/handlers/exception.py", line 41, in inner
[Fri Sep 01 04:33:49.333192 2017] [:error] [pid 23201] response = get_response(request)
[Fri Sep 01 04:33:49.333194 2017] [:error] [pid 23201] File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/handlers/base.py", line 187, in _get_response
[Fri Sep 01 04:33:49.333196 2017] [:error] [pid 23201] response = self.process_exception_by_middleware(e, request)
[Fri Sep 01 04:33:49.333198 2017] [:error] [pid 23201] File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/handlers/base.py", line 185, in _get_response
[Fri Sep 01 04:33:49.333201 2017] [:error] [pid 23201] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Fri Sep 01 04:33:49.333203 2017] [:error] [pid 23201] File "/opt/python/run/venv/lib/python3.4/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
[Fri Sep 01 04:33:49.333205 2017] [:error] [pid 23201] return view_func(*args, **kwargs)
[Fri Sep 01 04:33:49.333216 2017] [:error] [pid 23201] File "/opt/python/run/venv/lib/python3.4/site-packages/django/views/decorators/http.py", line 40, in inner
[Fri Sep 01 04:33:49.333218 2017] [:error] [pid 23201] return func(request, *args, **kwargs)
[Fri Sep 01 04:33:49.333220 2017] [:error] [pid 23201] File "/opt/python/current/app/webhookmb/views.py", line 81, in webhookmb
[Fri Sep 01 04:33:49.333222 2017] [:error] [pid 23201] interpreter = Interpreter.load(metadata, RasaNLUConfig("rasa_nlu/config_spacy.json"))
[Fri Sep 01 04:33:49.333224 2017] [:error] [pid 23201] File "/opt/python/current/app/rasa_nlu/model.py", line 213, in load
[Fri Sep 01 04:33:49.333226 2017] [:error] [pid 23201] component_name, model_metadata.model_dir, model_metadata, **context)
[Fri Sep 01 04:33:49.333228 2017] [:error] [pid 23201] File "/opt/python/current/app/rasa_nlu/components.py", line 310, in load_component
[Fri Sep 01 04:33:49.333229 2017] [:error] [pid 23201] model_metadata, cached_component, **context)
[Fri Sep 01 04:33:49.333231 2017] [:error] [pid 23201] File "/opt/python/current/app/rasa_nlu/registry.py", line 128, in load_component_by_name
[Fri Sep 01 04:33:49.333233 2017] [:error] [pid 23201] return component_clz.load(model_dir, metadata, cached_component, **kwargs)
[Fri Sep 01 04:33:49.333235 2017] [:error] [pid 23201] File "/opt/python/current/app/rasa_nlu/utils/spacy_utils.py", line 99, in load
[Fri Sep 01 04:33:49.333237 2017] [:error] [pid 23201] cls.ensure_proper_language_model(nlp)
[Fri Sep 01 04:33:49.333239 2017] [:error] [pid 23201] File "/opt/python/current/app/rasa_nlu/utils/spacy_utils.py", line 113, in ensure_proper_language_model
[Fri Sep 01 04:33:49.333240 2017] [:error] [pid 23201] "Make sure you have downloaded the correct model (https://spacy.io/docs/usage/).")
[Fri Sep 01 04:33:49.333244 2017] [:error] [pid 23201] Exception: Failed to load spacy language model for lang 'en'. Make sure you have downloaded the correct model (https://spacy.io/docs/usage/).

Apache 2.4 with mod_wsgi: Internal Server Error with wsgi.py

I am trying to deploy my django project on a windows server, using apache 2.4 with mod_wsgi and pythong 3.4.
Now when I could run apache just fine but I got Internal Server Error when going to localhost, I have this Internal Server Error. Then I looked at the error.log and found the following:
The 'Apache2.4' service is restarting.
The 'Apache2.4' service has restarted.
winnt:notice] [pid 7756:tid 528] AH00424: Parent: Received restart signal -- Restarting the server.
[Thu Sep 29 18:18:19.003503 2016] [wsgi:warn] [pid 7756:tid 528] mod_wsgi: Compiled for Python/3.4.2.
[Thu Sep 29 18:18:19.003503 2016] [wsgi:warn] [pid 7756:tid 528] mod_wsgi: Runtime using Python/3.4.3.
[Thu Sep 29 18:18:19.003503 2016] [mpm_winnt:notice] [pid 7756:tid 528] AH00455: Apache/2.4.23 (Win64) mod_wsgi/4.4.12 Python/3.4.3 configured -- resuming normal operations
[Thu Sep 29 18:18:19.003503 2016] [mpm_winnt:notice] [pid 7756:tid 528] AH00456: Apache Lounge VC10 Server built: Jul 9 2016 11:59:00
[Thu Sep 29 18:18:19.003503 2016] [core:notice] [pid 7756:tid 528] AH00094: Command line: 'C:\\Apache24\\bin\\httpd.exe -d C:/Apache24'
[Thu Sep 29 18:18:19.003503 2016] [mpm_winnt:notice] [pid 7756:tid 528] AH00418: Parent: Created child process 10400
[Thu Sep 29 18:18:19.347246 2016] [wsgi:warn] [pid 10400:tid 456] mod_wsgi: Compiled for Python/3.4.2.
[Thu Sep 29 18:18:19.347246 2016] [wsgi:warn] [pid 10400:tid 456] mod_wsgi: Runtime using Python/3.4.3.
[Thu Sep 29 18:18:19.987923 2016] [mpm_winnt:notice] [pid 10400:tid 456] AH00354: Child: Starting 64 worker threads.
[Thu Sep 29 18:18:21.003576 2016] [mpm_winnt:notice] [pid 7476:tid 460] AH00364: Child: All worker threads have exited.
[Thu Sep 29 18:18:27.175151 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] mod_wsgi (pid=10400): Target WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py' cannot be loaded as Python module.
[Thu Sep 29 18:18:27.175151 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] mod_wsgi (pid=10400): Exception occurred processing WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py'.
[Thu Sep 29 18:18:27.175151 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] Traceback (most recent call last):\r
[Thu Sep 29 18:18:27.175151 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "C:/EquipmentCalibration/equipcal/wsgi.py", line 16, in <module>\r
[Thu Sep 29 18:18:27.175151 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] application = get_wsgi_application()\r
[Thu Sep 29 18:18:27.176153 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "C:\\Python34\\lib\\site-packages\\django\\core\\wsgi.py", line 13, in get_wsgi_application\r
[Thu Sep 29 18:18:27.176153 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] django.setup(set_prefix=False)\r
[Thu Sep 29 18:18:27.177153 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "C:\\Python34\\lib\\site-packages\\django\\__init__.py", line 22, in setup\r
[Thu Sep 29 18:18:27.177153 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r
[Thu Sep 29 18:18:27.177153 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 53, in __getattr__\r
[Thu Sep 29 18:18:27.177153 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] self._setup(name)\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 41, in _setup\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] self._wrapped = Settings(settings_module)\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 97, in __init__\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] mod = importlib.import_module(self.SETTINGS_MODULE)\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "C:\\Python34\\Lib\\importlib\\__init__.py", line 109, in import_module\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] return _bootstrap._gcd_import(name[level:], package, level)\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r
[Thu Sep 29 18:18:27.179154 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked\r
[Thu Sep 29 18:18:27.179154 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed\r
[Thu Sep 29 18:18:27.179154 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r
[Thu Sep 29 18:18:27.179154 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r
[Thu Sep 29 18:18:27.179154 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked\r
[Thu Sep 29 18:18:27.179154 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] ImportError: No module named 'equipcal'\r
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] mod_wsgi (pid=10400): Target WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py' cannot be loaded as Python module., referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] mod_wsgi (pid=10400): Exception occurred processing WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py'., referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] Traceback (most recent call last):\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "C:/EquipmentCalibration/equipcal/wsgi.py", line 16, in <module>\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] application = get_wsgi_application()\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "C:\\Python34\\lib\\site-packages\\django\\core\\wsgi.py", line 13, in get_wsgi_application\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] django.setup(set_prefix=False)\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "C:\\Python34\\lib\\site-packages\\django\\__init__.py", line 22, in setup\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.200129 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 53, in __getattr__\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.200129 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] self._setup(name)\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.200129 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 41, in _setup\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.200129 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] self._wrapped = Settings(settings_module)\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.200129 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 97, in __init__\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.200129 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] mod = importlib.import_module(self.SETTINGS_MODULE)\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "C:\\Python34\\Lib\\importlib\\__init__.py", line 109, in import_module\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] return _bootstrap._gcd_import(name[level:], package, level)\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] ImportError: No module named 'equipcal'\r, referer: http://localhost:8090/calbase
Apparently it is calling problem with my wsgi.py inside of my project. Currently I am just using the default wsgi.py file created when startproject. So it is just this:
"""
WSGI config for equipcal project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "equipcal.settings")
application = get_wsgi_application()
And my current https.conf is like this:
# Change Python path used by the server.
WSGIPythonPath “/EquipmentCalibration”
# Make calls to http://localhost/ refer to the Python/WSGI-script located at the specified location.
WSGIScriptAlias / /EquipmentCalibration/equipcal/wsgi.py
# Make calls to http://localhost/static refer to the specified folder.
Alias /static/ /EquipmentCalibration/static
Alias /media/ /EquipmentCalibration/media
<Directory /EquipmentCalibration/static>
Require all granted
</Directory>
<Directory /EquipmentCalibration/media>
Require all granted
</Directory>
<Directory /EquipmentCalibration/equipcal>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
I tried to do a bit of research around but didn't seem to find how should I configure it. Could somebody please shed some light on this please?

504 Gateway Timeout sending mail

I have a problem sending mail from a contact form with Django. I have set smtp config in settings.py and I can send it from local. But in production server, I get a 504 Gateway Timeout Error. This is the Error Log content.
[Sun Jul 17 18:17:46.142782 2016] [wsgi:error] [pid 16049] [client XXXXX:37298] Timeout when reading response headers from daemon process 'domain.gal': /home/wsgi/web/domain.gal/private/django/domain.gal/domain/wsgi.py, referer: http://domain.gal/contacto/
[Sun Jul 17 18:17:49.120971 2016] [wsgi:error] [pid 16046] Internal Server Error: /contacto/
[Sun Jul 17 18:17:49.121004 2016] [wsgi:error] [pid 16046] Traceback (most recent call last):
[Sun Jul 17 18:17:49.121008 2016] [wsgi:error] [pid 16046] File "/home/wsgi/web/domain.gal/private/django/env/lib/python3.4/site-packages/django/core/handlers/base.py", line 149, in get_response
[Sun Jul 17 18:17:49.121012 2016] [wsgi:error] [pid 16046] response = self.process_exception_by_middleware(e, request)
[Sun Jul 17 18:17:49.121015 2016] [wsgi:error] [pid 16046] File "/home/wsgi/web/domain.gal/private/django/env/lib/python3.4/site-packages/django/core/handlers/base.py", line 147, in get_response
[Sun Jul 17 18:17:49.121018 2016] [wsgi:error] [pid 16046] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Sun Jul 17 18:17:49.121021 2016] [wsgi:error] [pid 16046] File "/home/wsgi/web/domain.gal/private/django/domain.gal/home/views.py", line 43, in contacto
[Sun Jul 17 18:17:49.121023 2016] [wsgi:error] [pid 16046] send_mail(subject, message, from_email, ['info#domain.es'])
[Sun Jul 17 18:17:49.121026 2016] [wsgi:error] [pid 16046] File "/home/wsgi/web/domain.gal/private/django/env/lib/python3.4/site-packages/django/core/mail/__init__.py", line 61, in send_mail
[Sun Jul 17 18:17:49.121029 2016] [wsgi:error] [pid 16046] return mail.send()
[Sun Jul 17 18:17:49.121032 2016] [wsgi:error] [pid 16046] File "/home/wsgi/web/domain.gal/private/django/env/lib/python3.4/site-packages/django/core/mail/message.py", line 292, in send
[Sun Jul 17 18:17:49.121034 2016] [wsgi:error] [pid 16046] return self.get_connection(fail_silently).send_messages([self])
[Sun Jul 17 18:17:49.121037 2016] [wsgi:error] [pid 16046] File "/home/wsgi/web/domain.gal/private/django/env/lib/python3.4/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages
[Sun Jul 17 18:17:49.121040 2016] [wsgi:error] [pid 16046] new_conn_created = self.open()
[Sun Jul 17 18:17:49.121043 2016] [wsgi:error] [pid 16046] File "/home/wsgi/web/domain.gal/private/django/env/lib/python3.4/site-packages/django/core/mail/backends/smtp.py", line 58, in open
[Sun Jul 17 18:17:49.121060 2016] [wsgi:error] [pid 16046] self.connection = connection_class(self.host, self.port, **connection_params)
[Sun Jul 17 18:17:49.121063 2016] [wsgi:error] [pid 16046] File "/usr/lib64/python3.4/smtplib.py", line 242, in __init__
[Sun Jul 17 18:17:49.121066 2016] [wsgi:error] [pid 16046] (code, msg) = self.connect(host, port)
[Sun Jul 17 18:17:49.121069 2016] [wsgi:error] [pid 16046] File "/usr/lib64/python3.4/smtplib.py", line 321, in connect
[Sun Jul 17 18:17:49.121071 2016] [wsgi:error] [pid 16046] self.sock = self._get_socket(host, port, self.timeout)
[Sun Jul 17 18:17:49.121074 2016] [wsgi:error] [pid 16046] File "/usr/lib64/python3.4/smtplib.py", line 292, in _get_socket
[Sun Jul 17 18:17:49.121076 2016] [wsgi:error] [pid 16046] self.source_address)
[Sun Jul 17 18:17:49.121079 2016] [wsgi:error] [pid 16046] File "/usr/lib64/python3.4/socket.py", line 512, in create_connection
[Sun Jul 17 18:17:49.121081 2016] [wsgi:error] [pid 16046] raise err
[Sun Jul 17 18:17:49.121084 2016] [wsgi:error] [pid 16046] File "/usr/lib64/python3.4/socket.py", line 503, in create_connection
[Sun Jul 17 18:17:49.121086 2016] [wsgi:error] [pid 16046] sock.connect(sa)
[Sun Jul 17 18:17:49.121091 2016] [wsgi:error] [pid 16046] TimeoutError: [Errno 110] Connection timed out
[Sun Jul 17 18:17:49.121097 2016] [wsgi:error] [pid 16046]
Any idea plz?
Your app can't connect to the specified SMTP server. Check for the following issues:
Is your SMTP details correct?
Do you have a running SMTP server at the configured host/port?
Is the connection being blocked by a firewall?
From the log, it's evident that the SMTP connection is timing out. Please provide more details (code/configuration) to speculate better.
Ok masnum is right. I have changed the port and dissabled TLS use and it works. But I have two questions. My configuration was the follow:
EMAIL_PORT = 587
EMAIL_USE_TLS = True
Is this correct? I can use this in localhost, why not in production server? Busy port maybe?
And the other question. I use this:
try:
send_mail(subject, message, from_email, ['info#domain.com'])
except BadHeaderError:
messages.warning(request, 'Ha ocurrido un fallo. Inténtelo de nuevo más tarde.')
return render(request, "contacto.html", {'form': form})
except TimeoutError:
messages.warning(request, 'Ha ocurrido un fallo. Inténtelo de nuevo más tarde.')
return render(request, "contacto.html", {'form': form})
Why the error is not catched by TimeoutError instead of 504 Apache?
Txh

Django WSGI not working with apache

I'm trying to configure the WSGI in Apache to work with Django but it's not working, when I go to domain.com it gives me an error 500.
But If I start Django using:
python manage.py runserver domain.com:8000
When I go to domain.com:8000 works perfectly so I think It's something about apache and WSGI.
Here you have my WSGI script:
import os
import sys
sys.path.append('/var/www/domain/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'domain.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
My VirtualHost configuration:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName www.domain.com
ServerAdmin info#domain.com
ServerAlias domain.com
DocumentRoot /var/www/domain
WSGIScriptAlias / /var/www/domain/domain.wsgi
#Alias /static/ /var/www/domain/static/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
I'm using Ubuntu 14.04. I tried looking at logs but I have no idea what's wrong.
Logs:
[Thu Sep 25 10:15:09.549670 2014] [:error] [pid 17141] [client 88.12.185.72:65477] mod_wsgi (pid=17141): Exception occurred processing WSGI script '/var/www/domain/domain.wsgi'.
[Thu Sep 25 10:15:09.549722 2014] [:error] [pid 17141] [client 88.12.185.72:65477] Traceback (most recent call last):
[Thu Sep 25 10:15:09.549747 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Thu Sep 25 10:15:09.549880 2014] [:error] [pid 17141] [client 88.12.185.72:65477] response = self.get_response(request)
[Thu Sep 25 10:15:09.549899 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 199, in get_response
[Thu Sep 25 10:15:09.550029 2014] [:error] [pid 17141] [client 88.12.185.72:65477] response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Thu Sep 25 10:15:09.550048 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 236, in handle_uncaught_exception
[Thu Sep 25 10:15:09.550075 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return debug.technical_500_response(request, *exc_info)
[Thu Sep 25 10:15:09.550091 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 91, in technical_500_response
[Thu Sep 25 10:15:09.550492 2014] [:error] [pid 17141] [client 88.12.185.72:65477] html = reporter.get_traceback_html()
[Thu Sep 25 10:15:09.550513 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 350, in get_traceback_html
[Thu Sep 25 10:15:09.550539 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return t.render(c)
[Thu Sep 25 10:15:09.550554 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 148, in render
[Thu Sep 25 10:15:09.550984 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return self._render(context)
[Thu Sep 25 10:15:09.551006 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 142, in _render
[Thu Sep 25 10:15:09.551034 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return self.nodelist.render(context)
[Thu Sep 25 10:15:09.551048 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 844, in render
[Thu Sep 25 10:15:09.551071 2014] [:error] [pid 17141] [client 88.12.185.72:65477] bit = self.render_node(node, context)
[Thu Sep 25 10:15:09.551084 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 80, in render_node
[Thu Sep 25 10:15:09.551174 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return node.render(context)
[Thu Sep 25 10:15:09.551192 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 90, in render
[Thu Sep 25 10:15:09.551217 2014] [:error] [pid 17141] [client 88.12.185.72:65477] output = self.filter_expression.resolve(context)
[Thu Sep 25 10:15:09.551231 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 624, in resolve
[Thu Sep 25 10:15:09.551268 2014] [:error] [pid 17141] [client 88.12.185.72:65477] new_obj = func(obj, *arg_vals)
[Thu Sep 25 10:15:09.551284 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/defaultfilters.py", line 769, in date
[Thu Sep 25 10:15:09.551595 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return format(value, arg)
[Thu Sep 25 10:15:09.551615 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 343, in format
[Thu Sep 25 10:15:09.551759 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return df.format(format_string)
[Thu Sep 25 10:15:09.551778 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 35, in format
[Thu Sep 25 10:15:09.551817 2014] [:error] [pid 17141] [client 88.12.185.72:65477] pieces.append(force_text(getattr(self, piece)()))
[Thu Sep 25 10:15:09.551834 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 268, in r
[Thu Sep 25 10:15:09.551857 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return self.format('D, j M Y H:i:s O')
[Thu Sep 25 10:15:09.551871 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 35, in format
[Thu Sep 25 10:15:09.551892 2014] [:error] [pid 17141] [client 88.12.185.72:65477] pieces.append(force_text(getattr(self, piece)()))
[Thu Sep 25 10:15:09.551907 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/encoding.py", line 85, in force_text
[Thu Sep 25 10:15:09.552021 2014] [:error] [pid 17141] [client 88.12.185.72:65477] s = six.text_type(s)
[Thu Sep 25 10:15:09.552039 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 144, in __text_cast
[Thu Sep 25 10:15:09.552276 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return func(*self.__args, **self.__kw)
[Thu Sep 25 10:15:09.552297 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", line 83, in ugettext
[Thu Sep 25 10:15:09.552412 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return _trans.ugettext(message)
[Thu Sep 25 10:15:09.552431 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 325, in ugettext
[Thu Sep 25 10:15:09.552686 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return do_translate(message, 'ugettext')
[Thu Sep 25 10:15:09.552706 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 306, in do_translate
[Thu Sep 25 10:15:09.552731 2014] [:error] [pid 17141] [client 88.12.185.72:65477] _default = translation(settings.LANGUAGE_CODE)
[Thu Sep 25 10:15:09.552746 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 209, in translation
[Thu Sep 25 10:15:09.552768 2014] [:error] [pid 17141] [client 88.12.185.72:65477] default_translation = _fetch(settings.LANGUAGE_CODE)
[Thu Sep 25 10:15:09.552782 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 189, in _fetch
[Thu Sep 25 10:15:09.552804 2014] [:error] [pid 17141] [client 88.12.185.72:65477] "The translation infrastructure cannot be initialized before the "
[Thu Sep 25 10:15:09.552830 2014] [:error] [pid 17141] [client 88.12.185.72:65477] AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.
Anyone knows what I'm doing wrong?
Thanks
I discover that the version of Django in my production server is 1.7.0 and in Development server is 1.6.4. After downgrade Django works fine.
sudo pip install django==1.6.4