0

I have a django app deployed to AWS beanstalk. The first version was fine after following the official documentation: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html

Then, I added a new feature using django-filter to my site. Now, when I deploy, I get this error on the main front end page:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log.

Below is the error log I have.

[Thu Oct 01 04:47:09.118698 2020] [:error] [pid 21279] [remote 172.31.47.200:20528]     apps.populate(settings.INSTALLED_APPS)
[Thu Oct 01 04:47:09.118704 2020] [:error] [pid 21279] [remote 172.31.47.200:20528]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/apps/registry.py", line 83, in populate
[Thu Oct 01 04:47:09.118707 2020] [:error] [pid 21279] [remote 172.31.47.200:20528]     raise RuntimeError("populate() isn't reentrant")
[Thu Oct 01 04:47:09.118722 2020] [:error] [pid 21279] [remote 172.31.47.200:20528] RuntimeError: populate() isn't reentrant
[Thu Oct 01 04:47:13.477606 2020] [:error] [pid 21279] [remote 172.31.3.100:48] mod_wsgi (pid=21279): Target WSGI script '/opt/python/current/app/djangoproject/wsgi.py' cannot be loaded as Python module.
[Thu Oct 01 04:47:13.477658 2020] [:error] [pid 21279] [remote 172.31.3.100:48] mod_wsgi (pid=21279): Exception occurred processing WSGI script '/opt/python/current/app/djangoproject/wsgi.py'.
[Thu Oct 01 04:47:13.477768 2020] [:error] [pid 21279] [remote 172.31.3.100:48] Traceback (most recent call last):
[Thu Oct 01 04:47:13.477801 2020] [:error] [pid 21279] [remote 172.31.3.100:48]   File "/opt/python/current/app/djangoproject/wsgi.py", line 16, in <module>
[Thu Oct 01 04:47:13.477806 2020] [:error] [pid 21279] [remote 172.31.3.100:48]     application = get_wsgi_application()
[Thu Oct 01 04:47:13.477812 2020] [:error] [pid 21279] [remote 172.31.3.100:48]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Thu Oct 01 04:47:13.477816 2020] [:error] [pid 21279] [remote 172.31.3.100:48]     django.setup(set_prefix=False)
[Thu Oct 01 04:47:13.477822 2020] [:error] [pid 21279] [remote 172.31.3.100:48]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
[Thu Oct 01 04:47:13.477825 2020] [:error] [pid 21279] [remote 172.31.3.100:48]     apps.populate(settings.INSTALLED_APPS)
[Thu Oct 01 04:47:13.477831 2020] [:error] [pid 21279] [remote 172.31.3.100:48]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/apps/registry.py", line 83, in populate
[Thu Oct 01 04:47:13.477834 2020] [:error] [pid 21279] [remote 172.31.3.100:48]     raise RuntimeError("populate() isn't reentrant")
[Thu Oct 01 04:47:13.477849 2020] [:error] [pid 21279] [remote 172.31.3.100:48] RuntimeError: populate() isn't reentrant
[Thu Oct 01 04:47:17.516356 2020] [:error] [pid 21279] [remote 172.31.29.143:48] mod_wsgi (pid=21279): Target WSGI script '/opt/python/current/app/djangoproject/wsgi.py' cannot be loaded as Python module.
[Thu Oct 01 04:47:17.516412 2020] [:error] [pid 21279] [remote 172.31.29.143:48] mod_wsgi (pid=21279): Exception occurred processing WSGI script '/opt/python/current/app/djangoproject/wsgi.py'.
[Thu Oct 01 04:47:17.516522 2020] [:error] [pid 21279] [remote 172.31.29.143:48] Traceback (most recent call last):
[Thu Oct 01 04:47:17.516557 2020] [:error] [pid 21279] [remote 172.31.29.143:48]   File "/opt/python/current/app/djangoproject/wsgi.py", line 16, in <module>
[Thu Oct 01 04:47:17.516562 2020] [:error] [pid 21279] [remote 172.31.29.143:48]     application = get_wsgi_application()
[Thu Oct 01 04:47:17.516568 2020] [:error] [pid 21279] [remote 172.31.29.143:48]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Thu Oct 01 04:47:17.516572 2020] [:error] [pid 21279] [remote 172.31.29.143:48]     django.setup(set_prefix=False)
[Thu Oct 01 04:47:17.516577 2020] [:error] [pid 21279] [remote 172.31.29.143:48]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
[Thu Oct 01 04:47:17.516589 2020] [:error] [pid 21279] [remote 172.31.29.143:48]     apps.populate(settings.INSTALLED_APPS)
[Thu Oct 01 04:47:17.516596 2020] [:error] [pid 21279] [remote 172.31.29.143:48]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/apps/registry.py", line 83, in populate
[Thu Oct 01 04:47:17.516599 2020] [:error] [pid 21279] [remote 172.31.29.143:48]     raise RuntimeError("populate() isn't reentrant")
[Thu Oct 01 04:47:17.516615 2020] [:error] [pid 21279] [remote 172.31.29.143:48] RuntimeError: populate() isn't reentrant
[Thu Oct 01 04:47:18.842837 2020] [:error] [pid 21279] [remote 172.31.58.190:44] mod_wsgi (pid=21279): Target WSGI script '/opt/python/current/app/djangoproject/wsgi.py' cannot be loaded as Python module.
[Thu Oct 01 04:47:18.842888 2020] [:error] [pid 21279] [remote 172.31.58.190:44] mod_wsgi (pid=21279): Exception occurred processing WSGI script '/opt/python/current/app/djangoproject/wsgi.py'.
[Thu Oct 01 04:47:18.843064 2020] [:error] [pid 21279] [remote 172.31.58.190:44] Traceback (most recent call last):
[Thu Oct 01 04:47:18.843099 2020] [:error] [pid 21279] [remote 172.31.58.190:44]   File "/opt/python/current/app/djangoproject/wsgi.py", line 16, in <module>
[Thu Oct 01 04:47:18.843103 2020] [:error] [pid 21279] [remote 172.31.58.190:44]     application = get_wsgi_application()
[Thu Oct 01 04:47:18.843110 2020] [:error] [pid 21279] [remote 172.31.58.190:44]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Thu Oct 01 04:47:18.843113 2020] [:error] [pid 21279] [remote 172.31.58.190:44]     django.setup(set_prefix=False)
[Thu Oct 01 04:47:18.843119 2020] [:error] [pid 21279] [remote 172.31.58.190:44]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
[Thu Oct 01 04:47:18.843123 2020] [:error] [pid 21279] [remote 172.31.58.190:44]     apps.populate(settings.INSTALLED_APPS)
[Thu Oct 01 04:47:18.843129 2020] [:error] [pid 21279] [remote 172.31.58.190:44]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/apps/registry.py", line 83, in populate
[Thu Oct 01 04:47:18.843132 2020] [:error] [pid 21279] [remote 172.31.58.190:44]     raise RuntimeError("populate() isn't reentrant")
[Thu Oct 01 04:47:18.843147 2020] [:error] [pid 21279] [remote 172.31.58.190:44] RuntimeError: populate() isn't reentrant ```

These are my requirements.txt:

asgiref==3.2.10
Django==3.1.1
django-ckeditor==6.0.0
django-filter==2.3.0
django-js-asset==1.2.2
PyJWT==1.7.1
pytz==2020.1
sqlparse==0.3.1

WSGI File:

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: djangoproject/wsgi.py

Could you please help. Have been trying to fix this for a while now.

Thank you so much, Cj

Timus
  • 10,974
  • 5
  • 14
  • 28
me games
  • 1
  • 1
  • Adding more of todays code: – me games Sep 30 '20 at 23:55
  • There are other issues regarding your errors, such as [here](https://stackoverflow.com/questions/30954398/django-populate-isnt-reentrant?lq=1) or [here](https://stackoverflow.com/questions/27093746/django-stops-working-with-runtimeerror-populate-isnt-reentrant). Have you explored any of them, and why they don't work in your case? – Marcin Sep 30 '20 at 23:57
  • Hi thanks for your response. Yes I have tried them both. In the first one I have all dependencies and it shows up correctly in requirements.. for second one I tried the registry bit as well but the same error shows up. Any suggestions? – me games Oct 01 '20 at 10:13
  • Anything I can try – me games Oct 02 '20 at 01:13
  • Can you ssh into the EB instance and inspect from there? Manually try launching it and see if you get any errors. Thus could help identifying why automation fails. – Marcin Oct 02 '20 at 01:19
  • Facing this problem as well. Everything was working fine and next deployment this! – Hossein Oct 02 '20 at 07:19

1 Answers1

0

Do this in your .ebextensions django config file:

command: "source /var/app/venv/staging-LQM1lest/bin/activate && pip install -r requirements/production.txt"

So basically activate the venv and run pip install makes sure dependencies are installed in the right venv. Also:

aws:elasticbeanstalk:container:python:
 WSGIPath: config.wsgi:application

In my case I have a config folder in the root in which wsgi.py file exists

Hossein
  • 40,161
  • 57
  • 141
  • 175
  • Thank you both. I have the wsgi bit but no luck. I will try once again with both and come back here – me games Oct 02 '20 at 22:37