diff --git a/src/calibre/ebooks/docx/to_html.py b/src/calibre/ebooks/docx/to_html.py
index c5f5d38df7..6613f24363 100644
--- a/src/calibre/ebooks/docx/to_html.py
+++ b/src/calibre/ebooks/docx/to_html.py
@@ -299,6 +299,8 @@ class Convert:
if name is None:
cname = self.docx.document_name.split('/')
cname[-1] = defname
+ if self.docx.exists('/'.join(cname)):
+ name = cname
if name and name.startswith('word/word') and not self.docx.exists(name):
name = name.partition('/')[2]
return name
diff --git a/src/calibre/srv/standalone.py b/src/calibre/srv/standalone.py
index d642d2c342..03095b0a59 100644
--- a/src/calibre/srv/standalone.py
+++ b/src/calibre/srv/standalone.py
@@ -220,7 +220,7 @@ def main(args=sys.argv):
raise SystemExit(_('No database found at CALIBRE_OVERRIDE_DATABASE_PATH: {}').format(
os.environ['CALIBRE_OVERRIDE_DATABASE_PATH']))
- opts.auto_reload_port = int(os.environ.get('CALIBRE_AUTORELOAD_PORT', 0)) # noqa: PLW1508
+ opts.auto_reload_port = int(os.environ.get('CALIBRE_AUTORELOAD_PORT', '0'))
opts.allow_console_print = 'CALIBRE_ALLOW_CONSOLE_PRINT' in os.environ
if opts.log and os.path.isdir(opts.log):
raise SystemExit('The --log option must point to a file, not a directory')