Error when using docker in : TypeError: expected str, bytes or os.PathLike object, not int

Hello all
Got an error when starting for the first time a server using docker.
It seems it can’t run the script to setup the db I have no idea why

seafile            | [2024-02-01 00:29:35] Now running in auto mode.
seafile-mysql      | 2024-02-01  0:29:35 3 [Warning] Aborted connection 3 to db: 'unconnected' user: 'seafile' host: '' (Got an error reading communication packets)
seafile            | Traceback (most recent call last):
seafile            |   File "/scripts/", line 95, in <module>
seafile            | waiting for mysql server to be ready: %s (2003, "Can't connect to MySQL server on 'db' ([Errno 111] Connection refused)")
seafile            |     main()
seafile            |   File "/scripts/", line 59, in main
seafile            |     init_seafile_server()
seafile            |   File "/scripts/", line 166, in init_seafile_server
seafile            |     call('{} auto -n seafile'.format(setup_script), env=env)
seafile            |   File "/scripts/", line 70, in call
seafile            |     return subprocess.check_call(*a, **kw)
seafile            |   File "/usr/lib/python3.10/", line 364, in check_call
seafile            |     retcode = call(*popenargs, **kwargs)
seafile            |   File "/usr/lib/python3.10/", line 345, in call
seafile            |     with Popen(*popenargs, **kwargs) as p:
seafile            |   File "/usr/lib/python3.10/", line 971, in __init__
seafile            |     self._execute_child(args, executable, preexec_fn, close_fds,
seafile            |   File "/usr/lib/python3.10/", line 1783, in _execute_child
seafile            |     env_list.append(k + b'=' + os.fsencode(v))
seafile            |   File "/usr/lib/python3.10/", line 811, in fsencode
seafile            |     filename = fspath(filename)  # Does type-checking of `filename`.
seafile            | TypeError: expected str, bytes or os.PathLike object, not int
1 Like

I dug into the code and I figure it out, in /scripts/ line 149, the mysql_port environement variable should NOT be cast to an int

it should be like that

    env = {
        'SERVER_NAME': 'seafile',
        'SERVER_IP': get_conf('SEAFILE_SERVER_HOSTNAME', ''),
        'MYSQL_USER': 'seafile',
        'MYSQL_USER_PASSWD': str(uuid.uuid4()),
        'MYSQL_USER_HOST': '%.%.%.%',
        'MYSQL_HOST': get_conf('DB_HOST', ''),
        'MYSQL_PORT': get_conf('DB_PORT', '3306'),
        # Default MariaDB root user has empty password and can only connect from localhost.
        'MYSQL_ROOT_PASSWD': get_conf('DB_ROOT_PASSWD', ''),

Dunno why nobody reported it before ? it’s odd

1 Like

commit from last week ! that might explain why.

1 Like

Thank you! You just saved me a lot of hassle. I’m new to Seafile and wanted to just try it out but couldn’t seem to get past the same error you were having. For now I just went back to 11.0.4 and it seems to work on a first glance. Hopefully someone sees your post and is able to implement the fix soon.

Thanks for your feedback, we have updated the seafileltd/seafile-mc:latest image.
You can install Seafile by docker pull seafileltd/seafile-mc:latest and then execute docker compose up

1 Like