Jump to content

[Solved] Django - 500 Internal Server Error


taenada

Recommended Posts

Hello. I'm trying to deploy my Django app on Johny server following instructions on Helio wiki. But it keeps having 500 Internal Server Error. Here is my project structure

unknown.png?width=236&height=431

 

My dispatch.wsgi

unknown.png

 

My .htaccess

 

unknown.png

 

Please show me my error. Thank you so much.

Link to comment
Share on other sites

Here is your error:

[Thu May 14 01:27:08.876704 2020] [core:error] [pid 8987] [client x.x.x.x:64300] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://taenada.heliohost.org/
That means you have a redirect loop. Usually that indicates an error in your .htaccess.
Link to comment
Share on other sites

Here is your error:

[Thu May 14 01:27:08.876704 2020] [core:error] [pid 8987] [client x.x.x.x:64300] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://taenada.heliohost.org/
That means you have a redirect loop. Usually that indicates an error in your .htaccess.

 

Thank you for pointing out my error. I have fixed a little but still get 500 error. I checked error page in cpanel and got

[Thu May 14 04:39:51.146023 2020] [wsgi:error] [pid 693] [client 14.165.129.32:50895]   File "/home/taenada/public_html/ThaidatGa/dispatch.wsgi", line 8, in <module>
[Thu May 14 04:39:51.145796 2020] [wsgi:error] [pid 693] [client 14.165.129.32:50895] mod_wsgi (pid=693): Exception occurred processing WSGI script '/home/taenada/public_html/ThaidatGa/dispatch.wsgi'.
[Thu May 14 04:39:51.145756 2020] [wsgi:error] [pid 693] [client 14.165.129.32:50895] mod_wsgi (pid=693): Failed to exec Python script file '/home/taenada/public_html/ThaidatGa/dispatch.wsgi'.
[Thu May 14 04:39:51.144121 2020] [wsgi:error] [pid 693] [client 14.165.129.32:50895]   File "/home/taenada/public_html/ThaidatGa/dispatch.wsgi", line 8, in <module>
[Thu May 14 04:39:51.130275 2020] [wsgi:error] [pid 693] [client 14.165.129.32:50895] mod_wsgi (pid=693): Exception occurred processing WSGI script '/home/taenada/public_html/ThaidatGa/dispatch.wsgi'.
[Thu May 14 04:39:51.130188 2020] [wsgi:error] [pid 693] [client 14.165.129.32:50895] mod_wsgi (pid=693): Failed to exec Python script file '/home/taenada/public_html/ThaidatGa/dispatch.wsgi'.

It seems that my current problem is now dispatch file.

My current dispatch file:

import os, sys

# edit your username below
sys.path.append("/home/Taenada/public_html/ThaidatGa")
from django.core.wsgi import get_wsgi_application
os.environ['PYTHON_EGG_CACHE'] = '/home/Taenada/.python_egg_cache'
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
application = get_wsgi_application()

 

 

 
 

 

 

Link to comment
Share on other sites

Still the same redirect error:

[Fri May 15 04:40:14.352416 2020] [core:error] [pid 14049] [client 65.19.141.66:62395] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://taenada.heliohost.org/
Link to comment
Share on other sites

I have tried to solved the problem by adding this line to .htacess

RewriteCond %{ENV:REDIRECT_STATUS} ^$

And maybe I got improvement that the 500 Internal Error page not show anymore. But it's changed to another form of 500 Internal Error by showing this line (checked in browser network tab, request return 500 error)

(none) 14.165.129.32 / taenada.heliohost.org Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0 500

Here, I think problem is in my code. Code works well on my local, but the version of Django does not match with the one on server. So I tried to run my code in local with virtualenv and downgraded version of Django (2.1.13). Code still worked well. So my thought is wrong.

 

It's also hard for me to trace error because I don't know where.

Please tell me what I should do. Thanks for your help and sorry for bothering you these days.

 

 

Link to comment
Share on other sites

Here's your error now:

 

[Sat May 16 20:10:00.033038 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648] mod_wsgi (pid=31318): Failed to exec Python script file '/home/taenada/public_html/ThaidatGa/dispatch.wsgi'.
[Sat May 16 20:10:00.033170 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648] mod_wsgi (pid=31318): Exception occurred processing WSGI script '/home/taenada/public_html/ThaidatGa/dispatch.wsgi'.
[Sat May 16 20:10:00.073331 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648] Traceback (most recent call last):
[Sat May 16 20:10:00.073541 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]   File "/home/taenada/public_html/ThaidatGa/dispatch.wsgi", line 9, in <module>
[Sat May 16 20:10:00.073571 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]     application = get_wsgi_application()
[Sat May 16 20:10:00.073599 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]   File "/usr/local/python3.7/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Sat May 16 20:10:00.073616 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]     django.setup(set_prefix=False)
[Sat May 16 20:10:00.073641 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]   File "/usr/local/python3.7/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
[Sat May 16 20:10:00.073657 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]     apps.populate(settings.INSTALLED_APPS)
[Sat May 16 20:10:00.073680 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]   File "/usr/local/python3.7/lib/python3.7/site-packages/django/apps/registry.py", line 89, in populate
[Sat May 16 20:10:00.073696 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]     app_config = AppConfig.create(entry)
[Sat May 16 20:10:00.073718 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]   File "/usr/local/python3.7/lib/python3.7/site-packages/django/apps/config.py", line 116, in create
[Sat May 16 20:10:00.073734 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]     mod = import_module(mod_path)
[Sat May 16 20:10:00.073757 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]   File "/usr/local/python3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
[Sat May 16 20:10:00.073774 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]     return _bootstrap._gcd_import(name[level:], package, level)
[Sat May 16 20:10:00.073797 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
[Sat May 16 20:10:00.073827 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
[Sat May 16 20:10:00.073853 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]   File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
[Sat May 16 20:10:00.073879 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[Sat May 16 20:10:00.073904 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
[Sat May 16 20:10:00.073929 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
[Sat May 16 20:10:00.073977 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648]   File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
[Sat May 16 20:10:00.074045 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49648] ModuleNotFoundError: No module named 'ShortLink'
[Sat May 16 20:10:00.381019 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49650] mod_wsgi (pid=31318): Failed to exec Python script file '/home/taenada/public_html/ThaidatGa/dispatch.wsgi'., referer: http://taenada.heliohost.org/
[Sat May 16 20:10:00.381144 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49650] mod_wsgi (pid=31318): Exception occurred processing WSGI script '/home/taenada/public_html/ThaidatGa/dispatch.wsgi'., referer: http://taenada.heliohost.org/
[Sat May 16 20:10:00.381456 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49650] Traceback (most recent call last):, referer: http://taenada.heliohost.org/
[Sat May 16 20:10:00.381558 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49650]   File "/home/taenada/public_html/ThaidatGa/dispatch.wsgi", line 9, in <module>, referer: http://taenada.heliohost.org/
[Sat May 16 20:10:00.381580 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49650]     application = get_wsgi_application(), referer: http://taenada.heliohost.org/
[Sat May 16 20:10:00.381603 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49650]   File "/usr/local/python3.7/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application, referer: http://taenada.heliohost.org/
[Sat May 16 20:10:00.381618 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49650]     django.setup(set_prefix=False), referer: http://taenada.heliohost.org/
[Sat May 16 20:10:00.381639 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49650]   File "/usr/local/python3.7/lib/python3.7/site-packages/django/__init__.py", line 24, in setup, referer: http://taenada.heliohost.org/
[Sat May 16 20:10:00.381653 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49650]     apps.populate(settings.INSTALLED_APPS), referer: http://taenada.heliohost.org/
[Sat May 16 20:10:00.381673 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49650]   File "/usr/local/python3.7/lib/python3.7/site-packages/django/apps/registry.py", line 81, in populate, referer: http://taenada.heliohost.org/
[Sat May 16 20:10:00.381688 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49650]     raise RuntimeError("populate() isn't reentrant"), referer: http://taenada.heliohost.org/
[Sat May 16 20:10:00.381733 2020] [wsgi:error] [pid 31318] [client x.x.x.x:49650] RuntimeError: populate() isn't reentrant, referer: http://taenada.heliohost.org/
I see mention of something called "ShortLink" in there. If this is something you wrote yourself you need to check the path to it because it isn't finding it. If it is an external module that someone else wrote you need to request those to be installed before you can use them otherwise you'll get an error. You can check the currently installed modules with this page https://krydos2.heliohost.org/cgi-bin/modules37.py
Link to comment
Share on other sites

Thanks for this helpful information. I have fixed my main problem, there are still some minor one that I will work on later.
Eventually, my site is now running.

I will make a summary for other people who want to deploy django and be in trouble like me.
1) Check your .htacess, if you get

AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace

Adding this line may help you

RewriteCond %{ENV:REDIRECT_STATUS} ^$

2) Make sure you included your project path in dispatch.wsgi, and make sure your dir to module and application you written your own correctly.

In my case, I wrote this and got error,

sys.path.append("/home/<username>/public_html/<project name>")
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

It worked well with settings file, but not your own application. Because my application was put under public_html

I fixed by changed these lines to

sys.path.append("/home/<username>/public_html/")
os.environ['DJANGO_SETTINGS_MODULE'] = '<project name>.settings'

Once again, thank you for your help.

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...