[GH-ISSUE #834] Internal Server Error (502) after I've updated to 1.4.3 (NGINX+uWSGI) #743

Closed
opened 2026-02-27 11:13:19 +03:00 by kerem · 8 comments
Owner

Originally created by @ghost on GitHub (Feb 4, 2016).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/834

Hello Antoine,

After I have updated from 1.4.2 to 1.4.3 and have deployed a fresh install, I get this error messages from uWSGI log when I try to access the web interface:

*** Starting uWSGI 2.0.12 (64bit) on [Thu Feb  4 18:27:01 2016] ***
compiled with version: 4.9.3 on 04 February 2016 18:25:29
os: Linux-4.3.5-hardened-****** #1 SMP Thu Jan 21 19:19:08 EST 2016
nodename: ******
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 3
current working directory: /
writing pidfile to /var/run/uwsgi_mdb/mdb.pid
detected binary path: /usr/bin/uwsgi
chdir() to /srv/test/mdb
your processes number limit is 8003
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
*** Cache "mdb" initialized: 64MB (key: 2136 bytes, keys: 2136000 bytes, data: 65536000 bytes, bitmap: 0 bytes) preallocated ***
uwsgi socket 0 bound to UNIX address /run/uwsgi_mdb/mdb.sock fd 4
Python version: 2.7.11 (default, Feb  3 2016, 19:05:41)  [GCC 4.9.3]
Set PythonHome to /srv/test/venv
Python main interpreter initialized at 0x7f608701e480
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 291040 bytes (284 KB) for 3 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x7f608701e480 pid: 28794
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 28794)
spawned uWSGI worker 1 (pid: 28803, cores: 1)
spawned uWSGI worker 2 (pid: 28804, cores: 1)
cache sweeper thread enabled
Traceback (most recent call last):
  File "/srv/test/venv/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 170, in __call__
    self.load_middleware()
  File "/srv/test/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 52, in load_middleware
    mw_instance = mw_class()
  File "/srv/test/venv/lib/python2.7/site-packages/django/middleware/locale.py", line 24, in __init__
    for url_pattern in get_resolver(None).url_patterns:
  File "/srv/test/venv/lib/python2.7/site-packages/django/core/urlresolvers.py", line 401, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/srv/test/venv/lib/python2.7/site-packages/django/core/urlresolvers.py", line 395, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "./mdb/urls.py", line 5, in <module>
    url(r'', include('modoboa.urls')),
  File "/srv/test/venv/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 33, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/srv/test/venv/lib/python2.7/site-packages/modoboa/urls.py", line 31, in <module>
    parameters.apply_to_django_settings()
  File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/parameters.py", line 370, in apply_to_django_settings
    for form in get_admin_forms():
  File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/parameters.py", line 337, in get_admin_forms
    "form": formdef["form"](*args, **kwargs)}
  File "/srv/test/venv/lib/python2.7/site-packages/modoboa/core/app_settings.py", line 261, in __init__
    super(GeneralParametersForm, self).__init__(*args, **kwargs)
  File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/parameters.py", line 62, in __init__
    self._load_initial_values()
  File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/parameters.py", line 96, in _load_initial_values
    if not db_utils.db_table_exists("lib_parameter"):
  File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/db_utils.py", line 24, in db_table_exists
    raise Exception("unable to determine if the table '%s' exists" % table)
Exception: unable to determine if the table 'lib_parameter' exists

/etc/uwsgi.d/mdb.ini:

[uwsgi]
pidfile = /run/uwsgi_%n/%n.pid
daemonize = true
daemonize = /srv/test/%n.log
socket = /run/uwsgi_%n/%n.sock
enable-threads = true
no-default-app = true
master = true

workers = 10
cheaper = 2
cheaper-step = 1

uid = modoboa
gid = nginx
plugins = python27
virtualenv = /srv/test/venv
chdir = /srv/test/%n
module = %n.wsgi:application
vacuum = true

cache2 = name=mdb,items=1000

pip list:

dj-database-url (0.4.0)
Django (1.8.9)
django-passwords (0.3.4)
django-reversion (1.9.3)
django-subcommand2 (0.1.1)
django-versionfield2 (0.4.0)
django-xforwardedfor-middleware (1.0)
djangorestframework (3.3.1)
factory-boy (2.6.0)
fake-factory (0.5.3)
LEPL (5.1.3)
modoboa (1.4.3)
MySQL-python (1.2.5)
passlib (1.6.5)
pip (8.0.2)
progressbar (2.3)
pycrypto (2.6.1)
requests (2.9.1)
rfc6266 (0.0.4)
setuptools (19.6.2)
six (1.10.0)
wheel (0.26.0)

For now I'm stuck with the version 1.4.2.

Originally created by @ghost on GitHub (Feb 4, 2016). Original GitHub issue: https://github.com/modoboa/modoboa/issues/834 Hello Antoine, After I have updated from 1.4.2 to 1.4.3 and have deployed a fresh install, I get this error messages from uWSGI log when I try to access the web interface: ``` *** Starting uWSGI 2.0.12 (64bit) on [Thu Feb 4 18:27:01 2016] *** compiled with version: 4.9.3 on 04 February 2016 18:25:29 os: Linux-4.3.5-hardened-****** #1 SMP Thu Jan 21 19:19:08 EST 2016 nodename: ****** machine: x86_64 clock source: unix pcre jit disabled detected number of CPU cores: 3 current working directory: / writing pidfile to /var/run/uwsgi_mdb/mdb.pid detected binary path: /usr/bin/uwsgi chdir() to /srv/test/mdb your processes number limit is 8003 your memory page size is 4096 bytes detected max file descriptor number: 1024 lock engine: pthread robust mutexes thunder lock: disabled (you can enable it with --thunder-lock) *** Cache "mdb" initialized: 64MB (key: 2136 bytes, keys: 2136000 bytes, data: 65536000 bytes, bitmap: 0 bytes) preallocated *** uwsgi socket 0 bound to UNIX address /run/uwsgi_mdb/mdb.sock fd 4 Python version: 2.7.11 (default, Feb 3 2016, 19:05:41) [GCC 4.9.3] Set PythonHome to /srv/test/venv Python main interpreter initialized at 0x7f608701e480 python threads support enabled your server socket listen backlog is limited to 100 connections your mercy for graceful operations on workers is 60 seconds mapped 291040 bytes (284 KB) for 3 cores *** Operational MODE: preforking *** WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x7f608701e480 pid: 28794 *** uWSGI is running in multiple interpreter mode *** spawned uWSGI master process (pid: 28794) spawned uWSGI worker 1 (pid: 28803, cores: 1) spawned uWSGI worker 2 (pid: 28804, cores: 1) cache sweeper thread enabled Traceback (most recent call last): File "/srv/test/venv/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 170, in __call__ self.load_middleware() File "/srv/test/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 52, in load_middleware mw_instance = mw_class() File "/srv/test/venv/lib/python2.7/site-packages/django/middleware/locale.py", line 24, in __init__ for url_pattern in get_resolver(None).url_patterns: File "/srv/test/venv/lib/python2.7/site-packages/django/core/urlresolvers.py", line 401, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/srv/test/venv/lib/python2.7/site-packages/django/core/urlresolvers.py", line 395, in urlconf_module self._urlconf_module = import_module(self.urlconf_name) File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "./mdb/urls.py", line 5, in <module> url(r'', include('modoboa.urls')), File "/srv/test/venv/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 33, in include urlconf_module = import_module(urlconf_module) File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/srv/test/venv/lib/python2.7/site-packages/modoboa/urls.py", line 31, in <module> parameters.apply_to_django_settings() File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/parameters.py", line 370, in apply_to_django_settings for form in get_admin_forms(): File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/parameters.py", line 337, in get_admin_forms "form": formdef["form"](*args, **kwargs)} File "/srv/test/venv/lib/python2.7/site-packages/modoboa/core/app_settings.py", line 261, in __init__ super(GeneralParametersForm, self).__init__(*args, **kwargs) File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/parameters.py", line 62, in __init__ self._load_initial_values() File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/parameters.py", line 96, in _load_initial_values if not db_utils.db_table_exists("lib_parameter"): File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/db_utils.py", line 24, in db_table_exists raise Exception("unable to determine if the table '%s' exists" % table) Exception: unable to determine if the table 'lib_parameter' exists ``` /etc/uwsgi.d/mdb.ini: ``` [uwsgi] pidfile = /run/uwsgi_%n/%n.pid daemonize = true daemonize = /srv/test/%n.log socket = /run/uwsgi_%n/%n.sock enable-threads = true no-default-app = true master = true workers = 10 cheaper = 2 cheaper-step = 1 uid = modoboa gid = nginx plugins = python27 virtualenv = /srv/test/venv chdir = /srv/test/%n module = %n.wsgi:application vacuum = true cache2 = name=mdb,items=1000 ``` pip list: ``` dj-database-url (0.4.0) Django (1.8.9) django-passwords (0.3.4) django-reversion (1.9.3) django-subcommand2 (0.1.1) django-versionfield2 (0.4.0) django-xforwardedfor-middleware (1.0) djangorestframework (3.3.1) factory-boy (2.6.0) fake-factory (0.5.3) LEPL (5.1.3) modoboa (1.4.3) MySQL-python (1.2.5) passlib (1.6.5) pip (8.0.2) progressbar (2.3) pycrypto (2.6.1) requests (2.9.1) rfc6266 (0.0.4) setuptools (19.6.2) six (1.10.0) wheel (0.26.0) ``` For now I'm stuck with the version 1.4.2.
kerem closed this issue 2026-02-27 11:13:19 +03:00
Author
Owner

@tonioo commented on GitHub (Feb 4, 2016):

Have you changed something to database credentials ?

<!-- gh-comment-id:179901061 --> @tonioo commented on GitHub (Feb 4, 2016): Have you changed something to database credentials ?
Author
Owner

@ghost commented on GitHub (Feb 5, 2016):

No, nothing. If I start from scratch (delete venv, deployed instance, etc.), and install modoboa 1.4.2, using the same database credentials, everything work fine.

<!-- gh-comment-id:180127394 --> @ghost commented on GitHub (Feb 5, 2016): No, nothing. If I start from scratch (delete venv, deployed instance, etc.), and install modoboa 1.4.2, using the same database credentials, everything work fine.
Author
Owner

@tonioo commented on GitHub (Feb 16, 2016):

Hi, I think this issue is the same than #835. Could you check please ?

<!-- gh-comment-id:184729576 --> @tonioo commented on GitHub (Feb 16, 2016): Hi, I think this issue is the same than #835. Could you check please ?
Author
Owner

@ghost commented on GitHub (Feb 17, 2016):

I applied the commit, but I still got 502 error. Though, the uwsgi log is reporting a different error now:

Traceback (most recent call last):
  File "/srv/test/venv/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 170, in __call__
    self.load_middleware()
  File "/srv/test/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 52, in load_middleware
    mw_instance = mw_class()
  File "/srv/test/venv/lib/python2.7/site-packages/django/middleware/locale.py", line 24, in __init__
    for url_pattern in get_resolver(None).url_patterns:
  File "/srv/test/venv/lib/python2.7/site-packages/django/core/urlresolvers.py", line 401, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/srv/test/venv/lib/python2.7/site-packages/django/core/urlresolvers.py", line 395, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "./mdb/urls.py", line 5, in <module>
    url(r'', include('modoboa.urls')),
  File "/srv/test/venv/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 33, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/srv/test/venv/lib/python2.7/site-packages/modoboa/urls.py", line 31, in <module>
    parameters.apply_to_django_settings()
  File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/parameters.py", line 370, in apply_to_django_settings
    for form in get_admin_forms():
  File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/parameters.py", line 337, in get_admin_forms
    "form": formdef["form"](*args, **kwargs)}
  File "/srv/test/venv/lib/python2.7/site-packages/modoboa/core/app_settings.py", line 261, in __init__
    super(GeneralParametersForm, self).__init__(*args, **kwargs)
  File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/parameters.py", line 62, in __init__
    self._load_initial_values()
  File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/parameters.py", line 96, in _load_initial_values
    if not db_utils.db_table_exists("lib_parameter"):
  File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/db_utils.py", line 12, in db_table_exists
    return table in connection.introspection.table_names()
  File "/srv/test/venv/lib/python2.7/site-packages/django/db/backends/base/introspection.py", line 57, in table_names
    return get_names(cursor)
  File "/srv/test/venv/lib/python2.7/site-packages/django/db/backends/base/introspection.py", line 53, in get_names
    return sorted(ti.name for ti in self.get_table_list(cursor)
  File "/srv/test/venv/lib/python2.7/site-packages/django/db/backends/mysql/introspection.py", line 48, in get_table_list
    cursor.execute("SHOW FULL TABLES")
  File "/srv/test/venv/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/srv/test/venv/lib/python2.7/site-packages/django/db/utils.py", line 98, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/srv/test/venv/lib/python2.7/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
  File "/srv/test/venv/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 124, in execute
    return self.cursor.execute(query, args)
  File "/srv/test/venv/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/srv/test/venv/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
django.db.utils.OperationalError: (2006, 'MySQL server has gone away')
<!-- gh-comment-id:185007899 --> @ghost commented on GitHub (Feb 17, 2016): I applied the commit, but I still got 502 error. Though, the uwsgi log is reporting a different error now: ``` Traceback (most recent call last): File "/srv/test/venv/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 170, in __call__ self.load_middleware() File "/srv/test/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 52, in load_middleware mw_instance = mw_class() File "/srv/test/venv/lib/python2.7/site-packages/django/middleware/locale.py", line 24, in __init__ for url_pattern in get_resolver(None).url_patterns: File "/srv/test/venv/lib/python2.7/site-packages/django/core/urlresolvers.py", line 401, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/srv/test/venv/lib/python2.7/site-packages/django/core/urlresolvers.py", line 395, in urlconf_module self._urlconf_module = import_module(self.urlconf_name) File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "./mdb/urls.py", line 5, in <module> url(r'', include('modoboa.urls')), File "/srv/test/venv/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 33, in include urlconf_module = import_module(urlconf_module) File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/srv/test/venv/lib/python2.7/site-packages/modoboa/urls.py", line 31, in <module> parameters.apply_to_django_settings() File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/parameters.py", line 370, in apply_to_django_settings for form in get_admin_forms(): File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/parameters.py", line 337, in get_admin_forms "form": formdef["form"](*args, **kwargs)} File "/srv/test/venv/lib/python2.7/site-packages/modoboa/core/app_settings.py", line 261, in __init__ super(GeneralParametersForm, self).__init__(*args, **kwargs) File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/parameters.py", line 62, in __init__ self._load_initial_values() File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/parameters.py", line 96, in _load_initial_values if not db_utils.db_table_exists("lib_parameter"): File "/srv/test/venv/lib/python2.7/site-packages/modoboa/lib/db_utils.py", line 12, in db_table_exists return table in connection.introspection.table_names() File "/srv/test/venv/lib/python2.7/site-packages/django/db/backends/base/introspection.py", line 57, in table_names return get_names(cursor) File "/srv/test/venv/lib/python2.7/site-packages/django/db/backends/base/introspection.py", line 53, in get_names return sorted(ti.name for ti in self.get_table_list(cursor) File "/srv/test/venv/lib/python2.7/site-packages/django/db/backends/mysql/introspection.py", line 48, in get_table_list cursor.execute("SHOW FULL TABLES") File "/srv/test/venv/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/srv/test/venv/lib/python2.7/site-packages/django/db/utils.py", line 98, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/srv/test/venv/lib/python2.7/site-packages/django/db/backends/utils.py", line 62, in execute return self.cursor.execute(sql) File "/srv/test/venv/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 124, in execute return self.cursor.execute(query, args) File "/srv/test/venv/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute self.errorhandler(self, exc, value) File "/srv/test/venv/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler raise errorclass, errorvalue django.db.utils.OperationalError: (2006, 'MySQL server has gone away') ```
Author
Owner

@tonioo commented on GitHub (Feb 17, 2016):

Have you tried to restart MySQL ?

<!-- gh-comment-id:185084957 --> @tonioo commented on GitHub (Feb 17, 2016): Have you tried to restart MySQL ?
Author
Owner

@ghost commented on GitHub (Feb 17, 2016):

Yes. I did a little research on what "MySQL server has gone away" mean. But still not working. As I said above, the version 1.4.2 is running fine in the same server, database, configurations, etc.

<!-- gh-comment-id:185155891 --> @ghost commented on GitHub (Feb 17, 2016): Yes. I did a little research on what "MySQL server has gone away" mean. But still not working. As I said above, the version 1.4.2 is running fine in the same server, database, configurations, etc.
Author
Owner

@tonioo commented on GitHub (Feb 17, 2016):

I don't understand. I've just deployed a fresh modoboa instance (using the installer) with MySQL and I don't encounter your issue.

Is there anything special with your architecture ? (chroot, etc.)

<!-- gh-comment-id:185184718 --> @tonioo commented on GitHub (Feb 17, 2016): I don't understand. I've just deployed a fresh modoboa instance (using the installer) with MySQL and I don't encounter your issue. Is there anything special with your architecture ? (chroot, etc.)
Author
Owner

@ghost commented on GitHub (Feb 22, 2016):

@tonioo No, nothing special. I'll investigate further.

Thank you for your time and sorry for the trouble.

Peace.

<!-- gh-comment-id:187162862 --> @ghost commented on GitHub (Feb 22, 2016): @tonioo No, nothing special. I'll investigate further. Thank you for your time and sorry for the trouble. Peace.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#743
No description provided.