I did DEBUG = False and then
ALLOWED_HOSTS = ['.domain.com']
I even tried
ALLOWED_HOSTS = ['*']
but same error
I am trying to do cache busting
I did this
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'election/static/')
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'election/static/')
]
and then i did collectstatic(this seems to be working, I can see the files)
I have no idea what to do
I am using apache2
You need to gather more information about what is causing the 500
error.
How are you running this in apache?
Check your apache logs for the more detailed information.
I tried to look into where log is
and in /var/log/apache2/error.log
[Sun Nov 13 14:37:17.372874 2022] [mpm_event:notice] [pid 564973:tid 139927379229760] AH00491: caught SIGTERM, shutting down
Exception ignored in: <function Local.__del__ at 0x7f4353edb700>
Traceback (most recent call last):
File "/var/www/election/venv/lib/python3.8/site-packages/asgiref/local.py", line 94, in __del__
NameError: name 'TypeError' is not defined
Exception ignored in: <function Local.__del__ at 0x7f4353edb700>
Traceback (most recent call last):
File "/var/www/election/venv/lib/python3.8/site-packages/asgiref/local.py", line 94, in __del__
NameError: name 'TypeError' is not defined
[Sun Nov 13 14:37:17.867231 2022] [mpm_event:notice] [pid 565489:tid 140618076146752] AH00489: Apache/2.4.41 (Ubuntu) OpenSSL/1.1.1f mod_wsgi/4.6.8 Python/3.8 configured -- resuming normal operations
[Sun Nov 13 14:37:17.868804 2022] [core:notice] [pid 565489:tid 140618076146752] AH00094: Command line: '/usr/sbin/apache2'
[Sun Nov 13 14:37:22.587733 2022] [wsgi:error] [pid 565490:tid 140618026100480] /var/www/election/venv/lib/python3.8/site-packages/openpyxl/compat/numbers.py:9: UserWarning: NumPy was imported from a Python sub-interpreter but NumPy does not properly support sub-interpreters. This will likely work for most users but might cause hard to track down issues or subtle bugs. A common user of the rare sub-interpreter feature is wsgi which also allows single-interpreter mode.
[Sun Nov 13 14:37:22.587794 2022] [wsgi:error] [pid 565490:tid 140618026100480] Improvements in the case of bugs are welcome, but is not on the NumPy roadmap, and full support may require significant effort to achieve.
[Sun Nov 13 14:37:22.587797 2022] [wsgi:error] [pid 565490:tid 140618026100480] import numpy
I had turned DEBUG = TRUE (the website is already online so I can’t have users seeing this error)
when I trun it false and restart apache2 then this shows up
No error log is being added when I open the website
In access.log
this is being shown
111.119.49.243 - - [13/Nov/2022:14:46:44 +0000] "-" 408 563 "-" "-"
103.10.31.8 - - [13/Nov/2022:14:48:26 +0000] "GET / HTTP/1.1" 500 5688 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:106.0) Gecko/20100101 Firefox/106.0"
103.10.31.8 - - [13/Nov/2022:14:48:27 +0000] "GET /favicon.ico HTTP/1.1" 404 1094 "https://domain.com/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:106.0) Gecko/20100101 Firefox/106.0"
The numpy error seems more like a warning. Is it causing it? How do i solve it?
my config file
<IfModule mod_ssl.c>
<VirtualHost *:443>
# 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.example.com
ServerAdmin webmaster@localhost
# DocumentRoot /var/www/html
Alias /static /var/www/election/election/static
Alias /favicon.ico /var/www/election/election/static/favicon.ico
<Directory /var/www/election/election/static>
Require all granted
</Directory>
<Directory /var/www/election/web/>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess election python-home=/var/www/election/venv python-path=/var/www/election
WSGIProcessGroup election
WSGIScriptAlias / /var/www/election/web/wsgi.py
# 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
ServerName domain.com
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/meropratinidhi.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/meropratinidhi.com/privkey.pem
</VirtualHost>
</IfModule>
First, verify that your virtual environment is using the exact same version of Python as your mod_wsgi module.
From the docs at: Virtual Environments — mod_wsgi 5.0.0 documentation
When using a Python virtual environment with mod_wsgi, it is very important that it has been created using the same Python installation that mod_wsgi was originally compiled for. It is not possible to use a Python virtual environment to force mod_wsgi to use a different Python version, or even a different Python installation.
Also, from Application Issues — mod_wsgi 5.0.0 documentation
To force a specific WSGI application to be run within the very first Python sub interpreter created when Python is initialised, the WSGIApplicationGroup directive should be used and the group set to ‘%{GLOBAL}’.
WSGIApplicationGroup %{GLOBAL}
(Side note: It’s issues like this that lead me / us to abandon Apache in favor of nginx more than 10 years ago.)
1 Like
Thanks that solved the numpy warning but I the 500 error code is still showing up.
[Sun Nov 13 15:28:53.499948 2022] [mpm_event:notice] [pid 567897:tid 140314583989312] AH00491: caught SIGTERM, shutting down
[Sun Nov 13 15:28:53.650159 2022] [mpm_event:notice] [pid 568002:tid 140595131251776] AH00489: Apache/2.4.41 (Ubuntu) OpenSSL/1.1.1f mod_wsgi/4.6.8 Python/3.8 configured -- resuming normal operations
[Sun Nov 13 15:28:53.650253 2022] [core:notice] [pid 568002:tid 140595131251776] AH00094: Command line: '/usr/sbin/apache2'
This shows up now after I restart apache. No error log is coming when I open website. Maybe I did mistake in settings.py?
I tried implementing whitenoise and again I can do collectstatic.
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'election/staticfiles/')
STATICFILES_DIRS = [
]
and this is how I am using static files
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'styles/queries/common.css' %}" />
I don’t see a 500 error from what you’ve posted here.
In access.log, it’s still showing. Sorry I forgot to include this.
103.10.31.8 - - [13/Nov/2022:15:41:44 +0000] "GET / HTTP/1.1" 500 5688 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:106.0) Gecko/20100101 Firefox/106.0"
Then check syslog next.
Somewhere there will have been a log written with additional details. It’s just an issue of finding it.
Thank you so much for helping
for now I have disabled whitenoise and it’s working
I might have configured whitenoise incorrectly