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
Related
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
My Django app was working fine, but now I'm getting a server error, the last thing I did was a reboot to my Centos7 Server and now I'm getting this error:
and this are my logs I'm using apache:
[Thu Mar 30 14:04:10.571843 2017] [:error] [pid 11335] [remote 10.221.50.100:24] mod_wsgi (pid=11335): Target WSGI script '/opt/btsystem/BTSystem/wsgi.py' cannot be loaded as Python module.
[Thu Mar 30 14:04:10.571991 2017] [:error] [pid 11335] [remote 10.221.50.100:24] mod_wsgi (pid=11335): Exception occurred processing WSGI script '/opt/btsystem/BTSystem/wsgi.py'.
[Thu Mar 30 14:04:10.572263 2017] [:error] [pid 11335] [remote 10.221.50.100:24] Traceback (most recent call last):
[Thu Mar 30 14:04:10.572544 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/opt/btsystem/BTSystem/wsgi.py", line 16, in <module>
[Thu Mar 30 14:04:10.572795 2017] [:error] [pid 11335] [remote 10.221.50.100:24] application = get_wsgi_application()
[Thu Mar 30 14:04:10.572919 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Thu Mar 30 14:04:10.573054 2017] [:error] [pid 11335] [remote 10.221.50.100:24] django.setup(set_prefix=False)
[Thu Mar 30 14:04:10.573107 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/site-packages/django/__init__.py", line 22, in setup
[Thu Mar 30 14:04:10.573170 2017] [:error] [pid 11335] [remote 10.221.50.100:24] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Thu Mar 30 14:04:10.573261 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/site-packages/django/utils/log.py", line 75, in configure_logging
[Thu Mar 30 14:04:10.573312 2017] [:error] [pid 11335] [remote 10.221.50.100:24] logging_config_func(logging_settings)
[Thu Mar 30 14:04:10.573369 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/logging/config.py", line 803, in dictConfig
[Thu Mar 30 14:04:10.573409 2017] [:error] [pid 11335] [remote 10.221.50.100:24] dictConfigClass(config).configure()
[Thu Mar 30 14:04:10.573455 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/logging/config.py", line 585, in configure
[Thu Mar 30 14:04:10.573501 2017] [:error] [pid 11335] [remote 10.221.50.100:24] '%r: %s' % (name, e))
[Thu Mar 30 14:04:10.573567 2017] [:error] [pid 11335] [remote 10.221.50.100:24] ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/opt/btsystem-logs/btsystem-debug.log'
Any idea?
The last line shows that Django doesn't have permission to write to the configured log file.
[Thu Mar 30 14:04:10.573567 2017] [:error] [pid 11335] [remote 10.221.50.100:24] ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/opt/btsystem-logs/btsystem-debug.log'
Make sure the file /opt/btsystem-logs/btsystem-debug.log is writeable by the user running the Django server.
The main problem was that I needed to do the following to enable the virtual host from Apache:
firewall-cmd --get-active-zones
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
Needed to open the ports.
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.
I uploaded the httpd.conf file for the staging django server to the live server and restarted it and that brought the site down. After returning the right file restarting it and stopping staging server I get internal server error roughly once for every 5 refreshes on the page that shows missing info for top_menu
[Fri Nov 13 11:38:41.793432 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] result = block.nodelist.render(context)
[Fri Nov 13 11:38:41.793440 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] File "/home/kbuzz/lib/python2.7/django/template/base.py", line 844, in render
[Fri Nov 13 11:38:41.793452 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] bit = self.render_node(node, context)
[Fri Nov 13 11:38:41.793461 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] File "/home/kbuzz/lib/python2.7/django/template/base.py", line 858, in render_node
[Fri Nov 13 11:38:41.793473 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] return node.render(context)
[Fri Nov 13 11:38:41.793481 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] File "/home/kbuzz/webapps/django/lib/python2.7/mptt/templatetags/mptt_tags.py", line 284, in render
[Fri Nov 13 11:38:41.793495 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] queryset = self.queryset_var.resolve(context)
[Fri Nov 13 11:38:41.793504 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] File "/home/kbuzz/lib/python2.7/django/template/base.py", line 734, in resolve
[Fri Nov 13 11:38:41.793516 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] value = self._resolve_lookup(context)
[Fri Nov 13 11:38:41.793524 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] File "/home/kbuzz/lib/python2.7/django/template/base.py", line 780, in _resolve_lookup
[Fri Nov 13 11:38:41.793537 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] (bit, current)) # missing attribute
[Fri Nov 13 11:38:41.793580 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] VariableDoesNotExist: Failed lookup for key [top_menu] in u"[{'False': False, 'None': None, 'True': True}, {}]"
which goes to this context proccessor 'top_menu':Page.objects.filter(top_menu=True, visible=True), and returns the info correctly when I run it from the shell.
>>> from pages.models import *
>>> Page.objects.filter(top_menu=True, visible=True)
[<Page: Home>, <Page: What’s On>, <Page: What’s On :: Today>, <Page: What’s On :
: This Weekend>, <Page: What’s On :: This Month>, <Page: Movies>, <Page: Movies
:: Now Showing>, <Page: Lifestyle>, <Page: Biz Directory>, <Page: Buy&Sell >, <P
age: Galleries>, <Page: Newsletters>]
>>>
I want to reset the apache server to start working correctly now.
I found the error was with the sys path in the wsgi it was pointing to the wrong path and restarting the server made the error to start coming.
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