mitmproxy / mitmproxy/mitmproxy
Better error message for WireGuard port conflict
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 45.1k
- Forks
- 4.7k
- Avg merge
- 21h 12m
- Merged PRs (30d)
- 16
Description
Problem Description
I have mitmweb configured to use the WireGuard mode. If I try to run 2 instances, the 2nd instance fails as expected because the port is already used. But the error message could be improved.
Steps to reproduce the behavior:
mitmweb --mode wireguardtwice
[12:23:18.282] Address already in use (os error 48)
Error logged during startup, exiting...
As a comparison, this is the error message you get when the web UI port conflicts:
Traceback (most recent call last):
File "mitmproxy/tools/web/master.py", line 111, in running
File "tornado/tcpserver.py", line 183, in listen
File "tornado/netutil.py", line 162, in bind_sockets
OSError: [Errno 48] Address already in use
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "mitmweb.py", line 4, in <module>
File "mitmproxy/tools/main.py", line 167, in mitmweb
File "mitmproxy/tools/main.py", line 137, in run
File "asyncio/runners.py", line 194, in run
File "asyncio/runners.py", line 118, in run
File "asyncio/base_events.py", line 720, in run_until_complete
File "mitmproxy/tools/main.py", line 134, in main
File "mitmproxy/master.py", line 84, in run
File "mitmproxy/tools/web/master.py", line 116, in running
OSError: [Errno 48] Web server failed to listen on 127.0.0.1:8081 with [Errno 48] Address already in use
Try specifying a different port by using `--set web_port=8083`.
[PYI-89638:ERROR] Failed to execute script 'mitmweb' due to unhandled exception!
System Information
Mitmproxy: 11.1.3 binary
Python: 3.13.1
OpenSSL: OpenSSL 3.4.1 11 Feb 2025
Platform: macOS-15.4-x86_64-64bit-Mach-O
Checklist
- This bug affects the latest mitmproxy release.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the mitmweb --mode wireguard startup path and trace where the existing "Address already in use" error is produced. Compare that path with the web UI port-conflict handling shown in the report, then run two WireGuard-mode instances to verify that the resulting message clearly identifies the conflict and how to resolve it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100