Errors on library creation/deletion after migration to Seafile 13

We recently migrated a couple of instances from Seafile 12 to Seafile 13 (1 comunity and 2 pro). It all seemed to be working fine but today when I wanted to create a new Library the server returned a 500 error. When I refreshed the page the library was there. If i delete it I get an error too but the library disappears. I have not been able to find an error in any of the log files. Is this a known problem?

To pinpoint the exact cause, we need to examine the logs that capture application-level tracebacks. Please check the following log files and share any errors or “Traceback” messages found around the time you performed the action:

  • logs/seahub.log
  • logs/fileserver.log
  • logs/seafile.log

You can also check Nginx/Caddy proxy log to identify which part return 500 HTTP response.

The error, for example happens when making a POST request to

This error apears constantly in seafile-monitor.log (next message it doesnt fit in this one)

[2026-07-10 11:26:32] Start seafevents.main 
WARNING:root:Memcached has not been set up
ERROR:seafevents.db:Failed to create database tables: (pymysql.err.OperationalError) (1045, "Access denied for user 'root'@'172.21.0.3' (using password: YES)")
(Background on this error at: https://sqlalche.me/e/20/e3q8)
ERROR:root:Failed create tables, error: Failed to create database tables
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/engine/base.py", line 143, in __init__
    self._dbapi_connection = engine.raw_connection()
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/engine/base.py", line 3317, in raw_connection
    return self.pool.connect()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
          ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/pool/impl.py", line 177, in _do_get
    with util.safe_reraise():
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/util/langhelpers.py", line 121, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/pool/impl.py", line 175, in _do_get
    return self._create_connection()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/util/langhelpers.py", line 121, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/engine/create.py", line 667, in connect
    return dialect.connect(*cargs_tup, **cparams)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/engine/default.py", line 630, in connect
    return self.loaded_dbapi.connect(*cargs, **cparams)  # type: ignore[no-any-return]  # NOQA: E501
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/seafile/seafile-server-13.0.21/seahub/thirdpart/pymysql/connections.py", line 365, in __init__
    self.connect()
  File "/opt/seafile/seafile-server-13.0.21/seahub/thirdpart/pymysql/connections.py", line 681, in connect
    self._request_authentication()
  File "/opt/seafile/seafile-server-13.0.21/seahub/thirdpart/pymysql/connections.py", line 958, in _request_authentication
    auth_packet = self._read_packet()
                  ^^^^^^^^^^^^^^^^^^^
  File "/opt/seafile/seafile-server-13.0.21/seahub/thirdpart/pymysql/connections.py", line 782, in _read_packet
    packet.raise_for_error()
  File "/opt/seafile/seafile-server-13.0.21/seahub/thirdpart/pymysql/protocol.py", line 219, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "/opt/seafile/seafile-server-13.0.21/seahub/thirdpart/pymysql/err.py", line 150, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1045, "Access denied for user 'root'@'172.21.0.3' (using password: YES)")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/opt/seafile/seafile-server-13.0.21/pro/python/seafevents/db.py", line 92, in create_db_tables
    Base.metadata.create_all(engine)
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/sql/schema.py", line 5931, in create_all
    bind._run_ddl_visitor(
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/engine/base.py", line 3267, in _run_ddl_visitor
    with self.begin() as conn:
  File "/usr/lib/python3.12/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/engine/base.py", line 3257, in begin
    with self.connect() as conn:
         ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/engine/base.py", line 3293, in connect
    return self._connection_cls(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/engine/base.py", line 145, in __init__
    Connection._handle_dbapi_exception_noconnection(
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/engine/base.py", line 2448, in _handle_dbapi_exception_noconnection
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/engine/base.py", line 143, in __init__
    self._dbapi_connection = engine.raw_connection()
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/engine/base.py", line 3317, in raw_connection
    return self.pool.connect()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
          ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/pool/impl.py", line 177, in _do_get
    with util.safe_reraise():
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/util/langhelpers.py", line 121, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/pool/impl.py", line 175, in _do_get
    return self._create_connection()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/util/langhelpers.py", line 121, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/engine/create.py", line 667, in connect
    return dialect.connect(*cargs_tup, **cparams)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/sqlalchemy/engine/default.py", line 630, in connect
    return self.loaded_dbapi.connect(*cargs, **cparams)  # type: ignore[no-any-return]  # NOQA: E501
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/seafile/seafile-server-13.0.21/seahub/thirdpart/pymysql/connections.py", line 365, in __init__
    self.connect()
  File "/opt/seafile/seafile-server-13.0.21/seahub/thirdpart/pymysql/connections.py", line 681, in connect
    self._request_authentication()
  File "/opt/seafile/seafile-server-13.0.21/seahub/thirdpart/pymysql/connections.py", line 958, in _request_authentication
    auth_packet = self._read_packet()
                  ^^^^^^^^^^^^^^^^^^^
  File "/opt/seafile/seafile-server-13.0.21/seahub/thirdpart/pymysql/connections.py", line 782, in _read_packet
    packet.raise_for_error()
  File "/opt/seafile/seafile-server-13.0.21/seahub/thirdpart/pymysql/protocol.py", line 219, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "/opt/seafile/seafile-server-13.0.21/seahub/thirdpart/pymysql/err.py", line 150, in raise_mysql_exception
    raise errorclass(errno, errval)
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1045, "Access denied for user 'root'@'172.21.0.3' (using password: YES)")
(Background on this error at: https://sqlalche.me/e/20/e3q8)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/opt/seafile/seafile-server-13.0.21/pro/python/seafevents/main.py", line 42, in main
    create_db_tables()
  File "/opt/seafile/seafile-server-13.0.21/pro/python/seafevents/db.py", line 95, in create_db_tables
    raise RuntimeError("Failed to create database tables")
RuntimeError: Failed to create database tables
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/opt/seafile/seafile-server-13.0.21/pro/python/seafevents/main.py", line 82, in <module>
    main()
  File "/opt/seafile/seafile-server-13.0.21/pro/python/seafevents/main.py", line 46, in main
    raise RuntimeError('Failed create tables, error: %s' % e)
RuntimeError: Failed create tables, error: Failed to create database tables

Analazing the error, the seafevent script is trying to connect to the db on 172.21.0.3 but the docker IP of the db is 172.21.0.4. The IP that it trys to connect to is seafile’s own IP

The 500 errors you are encountering during library creation and deletion are caused by a database connection failure in the seafevents component.

Root Cause Analysis

According to the logs, seafevents is attempting to connect to the database at 172.21.0.3, which you identified as the IP of the Seafile container itself, rather than the database container (172.21.0.4).

In Seafile 13.0, database and cache configurations have been centralized. The system is designed to read these settings from environment variables. If a legacy [DATABASE] section remains in seafevents.conf, it may conflict with the new environment-based configuration or point to outdated information.

Recommended Steps

1. Consolidate Database Configuration
Check your .env file and ensure the database connection details are correctly defined:

  • SEAFILE_MYSQL_DB_HOST (Should be the database container name, e.g., db, to avoid IP changes)
  • SEAFILE_MYSQL_DB_USER
  • SEAFILE_MYSQL_DB_PASSWORD

Once these are verified, remove the [DATABASE] section from seafevents.conf. This allows the events service to correctly inherit the centralized configuration from the environment variables.

2. Verify Redis Configuration
The logs also show a warning regarding Memcached. In Seafile 13, Redis is the recommended backend for caching and session management. Please check your .env file to ensure Redis is correctly configured:

SEAFILE_REDIS_HOST=redis

Also, ensure that your seahub_settings.py does not contain old Memcached settings that might override the new Redis configuration.

3. Restart Services
After making these changes, restart your Docker containers to apply the new configuration:

docker-compose down
docker-compose up -d

This should resolve the 500 errors by ensuring the background events service can properly connect to the database and record the necessary activity logs when libraries are modified.