500 Internal Server Error .Either the server is overloaded or there is an error in the application

Hi all,

We have installed privacyidea on Ubuntu 20.04, we have integrated freeradius also with privacyidea, sometime we get the below error message in /var/log/freeradius/radius.log file
Info: rlm_perl: 500 Internal Server Error: The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

after checking the privacyidea.log file, we found the below error messages

[ERROR][privacyidea.app:1891] Exception on /validate/check [POST]
Traceback (most recent call last):
  File "/home/privacyidea/venv/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/privacyidea/venv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/privacyidea/venv/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/privacyidea/venv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/privacyidea/venv/lib/python3.8/site-packages/flask/app.py", line 1948, in full_dispatch_request
    rv = self.preprocess_request()
  File "/home/privacyidea/venv/lib/python3.8/site-packages/flask/app.py", line 2242, in preprocess_request
    rv = func()
  File "/home/privacyidea/privacyidea/api/validate.py", line 126, in before_request
    request.User = get_user_from_param(request.all_data)
  File "/home/privacyidea/privacyidea/lib/log.py", line 155, in log_wrapper
    return func(*args, **kwds)
  File "/home/privacyidea/privacyidea/lib/user.py", line 646, in get_user_from_param
    user_object = User(login=username, realm=realm,
  File "/home/privacyidea/privacyidea/lib/log.py", line 155, in log_wrapper
    return func(*args, **kwds)
  File "/home/privacyidea/privacyidea/lib/user.py", line 105, in __init__
  File "/home/privacyidea/privacyidea/lib/usercache.py", line 63, in cache_wrapper
  File "/home/privacyidea/privacyidea/lib/user.py", line 115, in _get_user_from_userstore
  File "/home/privacyidea/privacyidea/lib/user.py", line 230, in _get_resolvers
    if self._locate_user_in_resolver(resolvername):
  File "/home/privacyidea/privacyidea/lib/user.py", line 250, in _locate_user_in_resolver
    uid = y.getUserId(self.login)
  File "/home/privacyidea/privacyidea/lib/resolvers/LDAPIdResolver.py", line 269, in cache_wrapper
    f_result = func(self, *args, **kwds)
  File "/home/privacyidea/privacyidea/lib/resolvers/LDAPIdResolver.py", line 630, in getUserId
  File "/home/privacyidea/privacyidea/lib/resolvers/LDAPIdResolver.py", line 508, in _bind
    if not self.l.bind():
  File "/home/privacyidea/venv/lib/python3.8/site-packages/ldap3/core/connection.py", line 589, in bind
  File "/home/privacyidea/venv/lib/python3.8/site-packages/ldap3/strategy/sync.py", line 57, in open
 File "/home/privacyidea/venv/lib/python3.8/site-packages/ldap3/strategy/base.py", line 122, in open
  File "/home/privacyidea/privacyidea/lib/resolvers/LDAPIdResolver.py", line 145, in get_server
    return ldap3.ServerPool.get_server(self, connection)
  File "/home/privacyidea/venv/lib/python3.8/site-packages/ldap3/core/pooling.py", line 317, in get_server
  File "/home/privacyidea/venv/lib/python3.8/site-packages/ldap3/core/pooling.py", line 91, in get_server
  File "/home/privacyidea/venv/lib/python3.8/site-packages/ldap3/core/pooling.py", line 173, in find_active_server
  File "/home/privacyidea/venv/lib/python3.8/site-packages/ldap3/core/server.py", line 324, in check_availability
  File "/usr/lib/python3.8/socket.py", line 231, in __init__
OSError: [Errno 24] Too many open files

Note: after rebooting the OS or restarting the pi.service the above error is gone, even we can’t open the Web GUI for it. Nginx is used as a webserver


It is what the log file says. You have too many files open.

you have to check your configuration. You probably messed something up totally.

@cornelinux thanks for your response, can you please guide me what configuration should I check.
When the load/requests come 2 much to the privacyidea server, then this error is thrown.


Look at the traceback!
The error originates from the LDAP Resolver.
You need to note, that on a Linux/Unix system everything is a file. So “too many open files” could also mean, that you have to many connections, sockets, whatsoever.

Please take this hint. I will not solve your problem.