[GH-ISSUE #88] mailserver not allowed to use port 25 #62

Open
opened 2026-02-25 23:39:45 +03:00 by kerem · 1 comment
Owner

Originally created by @sir-andreas on GitHub (Jul 1, 2024).
Original GitHub issue: https://github.com/HaschekSolutions/opentrashmail/issues/88

When I start the server as docker I get the following error in the mailserver.log:

PermissionError: [Errno 13] error while attempting to bind on address ('0.0.0.0', 25): permission denied

Port 25 is free on the server and can be used by other docker containers without issues.

Originally created by @sir-andreas on GitHub (Jul 1, 2024). Original GitHub issue: https://github.com/HaschekSolutions/opentrashmail/issues/88 When I start the server as docker I get the following error in the mailserver.log: `PermissionError: [Errno 13] error while attempting to bind on address ('0.0.0.0', 25): permission denied` Port 25 is free on the server and can be used by other docker containers without issues.
Author
Owner

@boraxhacker commented on GitHub (Jun 1, 2025):

I got the same error (below). Looking at rootfs/start.sh and noticing nginx as a user which probably can't use lower ports, I set environment variable, MAILPORT, to a high port, 25025 and mapped outside port 25 to inside 25025.

su - nginx -s /bin/ash -c 'cd /var/www/opentrashmail/python;python3 -u mailserver3.py

cat mailserver.log
2025-06-01 02:59:19,692 - main - INFO - [i] Discard unknown domains: False
2025-06-01 02:59:19,692 - main - INFO - [i] Max size of attachments: 0
2025-06-01 02:59:19,692 - main - INFO - [i] Listening for domains: ['localhost']
Traceback (most recent call last):
File "/var/www/opentrashmail/python/mailserver3.py", line 304, in
asyncio.run(run(port))
File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/var/www/opentrashmail/python/mailserver3.py", line 240, in run
controller_plaintext.start()
File "/usr/lib/python3.11/site-packages/aiosmtpd/controller.py", line 274, in start
raise self._thread_exception
File "/usr/lib/python3.11/site-packages/aiosmtpd/controller.py", line 235, in _run
self.server = self.loop.run_until_complete(self.server_coro)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 1536, in create_server
raise OSError(err.errno, msg) from None
PermissionError: [Errno 13] error while attempting to bind on address ('0.0.0.0', 25): permission denied

<!-- gh-comment-id:2926434692 --> @boraxhacker commented on GitHub (Jun 1, 2025): I got the same error (below). Looking at rootfs/start.sh and noticing nginx as a user which probably can't use lower ports, I set environment variable, MAILPORT, to a high port, 25025 and mapped outside port 25 to inside 25025. ``` su - nginx -s /bin/ash -c 'cd /var/www/opentrashmail/python;python3 -u mailserver3.py ``` > cat mailserver.log > 2025-06-01 02:59:19,692 - __main__ - INFO - [i] Discard unknown domains: False > 2025-06-01 02:59:19,692 - __main__ - INFO - [i] Max size of attachments: 0 > 2025-06-01 02:59:19,692 - __main__ - INFO - [i] Listening for domains: ['localhost'] > Traceback (most recent call last): > File "/var/www/opentrashmail/python/mailserver3.py", line 304, in <module> > asyncio.run(run(port)) > File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run > return runner.run(main) > ^^^^^^^^^^^^^^^^ > File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run > return self._loop.run_until_complete(task) > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > File "/usr/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete > return future.result() > ^^^^^^^^^^^^^^^ > File "/var/www/opentrashmail/python/mailserver3.py", line 240, in run > controller_plaintext.start() > File "/usr/lib/python3.11/site-packages/aiosmtpd/controller.py", line 274, in start > raise self._thread_exception > File "/usr/lib/python3.11/site-packages/aiosmtpd/controller.py", line 235, in _run > self.server = self.loop.run_until_complete(self.server_coro) > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > File "/usr/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete > return future.result() > ^^^^^^^^^^^^^^^ > File "/usr/lib/python3.11/asyncio/base_events.py", line 1536, in create_server > raise OSError(err.errno, msg) from None > PermissionError: [Errno 13] error while attempting to bind on address ('0.0.0.0', 25): permission denied
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/opentrashmail#62
No description provided.