question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Address already in use" even when it's not

See original GitHub issue

Hi

I am running multiple mitmproxy instances on one machine. Each instance has its own port between 49000 and 50000. All instances are listening on interface 0.0.0.0. Instances stop and restart multiple times per hour.

Most instances start fine. However, a few random ones will fail with the error that address is already in use:

$ mitmproxy -p 49338 Error starting proxy server: error(98, 'Address already in use')

However, netstat does not show any process using the port:

$ sudo netstat -nlp | grep 49338

I also do not see any zombie processes trying to start the same instance.

Any idea what’s causing this? Is the problem that every instance is listening on 0.0.0.0? How does mitmproxy decide whether a port is “open”?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Kaushal0812commented, Jul 23, 2018

Just in case above solutions didn’t work:

Follows the below steps:

  1. Get the port your process is listening to: $ ps ax | grep python

  2. Kill the Process $ kill PROCESS_NAME

1reaction
hynguyen2610commented, Jul 11, 2016

I ran into this problem too an not found any solution yet. Someone said about ps -f ax | grep mitm I tried an kill the processes in ps command result but mitmproxy still can not be started. The error message is the same.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Address already in use but nothing in netstat or lsof
In this state attempting to use nc to listen on port 10000 fails with Address already in use, but neither lsof not ss...
Read more >
How to kill server when seeing “EADDRINUSE: address ...
Solution. When this EADDRINUSE issue has already happened, in order to resolve it, you need to kill the process manually. In order to...
Read more >
How to fix error “Address already in use” - remarkablemark
To fix the error “Address already in use” (EADDRINUSE), kill the process associated with the port.
Read more >
Bind: Address Already in Use
Oddly, using SO_REUSEADDR can actually lead to more difficult "address already in use" errors. SO_REUSADDR permits you to use a port that is...
Read more >
Invalid 'bind' call, error: ('98' - 'Address already in use').
Please check for any processes running which shouldn't be running on that port or try providing a different port number in the .ini...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found