Pycharm 2020.3 - Internal Error - java.net.BindException: Address already in use: bind - Windows 10

Starting Pycharm and receive following error.  Windows 10 Pro 64 bit - 10.0.19042

Have tried different versions of PC to no avail.

Problem appeared suddenly (have been using PC for years).  Have removed Hyper-V, stopped Docker.  There is a similar thread for IntelliJ and other products and I have tried all those remedial measures.

Why does the trace output not detail the required port that it is trying to use?

 

regards, Freda

 

 

java.util.concurrent.CompletionException: java.net.BindException: Address already in use: bind
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1702)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.net.BindException: Address already in use: bind
at java.base/sun.nio.ch.Net.bind0(Native Method)
at java.base/sun.nio.ch.Net.bind(Net.java:455)
at java.base/sun.nio.ch.Net.bind(Net.java:447)
at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:134)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:550)
at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1334)
at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:506)
at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:491)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:973)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:248)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:356)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
... 1 more

-----
JRE 11.0.9+11-b1145.21 amd64 by JetBrains s.r.o.
C:\Program Files\JetBrains\PyCharm Community Edition 2020.3\jbr

0
14 comments

Hello, 

 

To lock folders IDE is starting a server on localhost, it tries to bind on the first available port between 6942 and 6991, this exception is thrown if IDE was not able to bind on any of the ports in this range. 

 

Please try restarting the server it should help. 

0

Thanks Antonina.

 

Could you clarify "restart the server" for me.  What server and how do I see if it is running?  Do you mean "retry PyCharm" because, if you do, I have tried many times.

0

I mean restarting the physical server where PyCharm is installed, in order to release ports if they remain busy. 

 

 

 

 

0

OK - I get it.  Given that PyCharm Community is installed on my laptop, I presume I need to reboot my laptop.  I have done this many times too.  Is there an easy way to find out what program currently has all the ports in the range 6942 and 6991 open?

0

In the Task Manager -> Performance -> Resource Monitor -> TCP connections. 

Please make sure that AV or FW is not a blocker. 

0

Thank you for the help thus far.  I have been running with AV (Avast) off and Windows Defender off.  I even tried with WiFi off.  All to no avail.  I looked at Resource Monitor but no task was using ports in the range 6942 to 6991.  However, it must be something on this laptop because I have tried PC on another laptop and it works.

Is there a way to start PC in debug mode?

0

I think I have resolved this problem.  Many other posts that I found on the Internet implied that Docker and/or Hyper-V were involved or to blame.  So:

  1. netsh int ipv4 show excludedportrange protocol=tcp to see the list of excluded ports and noticed that ports 6942 to 6991 were on that list.
  2. Uninstalled Hyper-V and rebooted.
  3. Uninstalled Docker.
  4. Same netsh command as before and saw that 6942 to 6991 were now not in the list.
  5. netsh int ipv4 add excludedportrange protocol=tcp startport=6942 numberofports=50 store=persistant
  6. start PyCharm (successful).
  7. stop PyCharm.
  8. Install Docker; start Docker subsystem.
  9. Start PyCharm (successful).

Now ... whether what I have done here is the real solution to the problem is debatable, but it has certainly worked for me.

I have documented it because when I used Resource Monitor, I was unable to see any use of ports 6942 to 6991.  So I decided to double check Antonina's assertion that PyCharm actually used those ports: I tried the netsh command in step 5 whilst PyCharm was running.  The netsh command failed because the port range was in use.  +1 to Antonina :-)

1

Hello!

Thank you for sharing step-by-step troubleshooting process, I am absolutely sure it will be helpful to others. 

 

 

0
net stop winnat
net start winnat

Worked for me.
23

Thank you Machuki, it worked for me too

1

Antonina Belianskaya would it be possible to include Machuki Dancan's suggestion in main page to recommend what to do with the bind error, this has helped many people

1

I can confirm Machuki Dancan's solution above worked for me as well with Pycharm 2021.2.2, running on Windows 10 Pro 21H1 Build 19043.1266

0

Thank you Machuki Dancan.

I also have that issue sometimes, not always, and this solution usually works without any problem. It happens with all JetBrains IDEs.

0

Thanks machuki the solution help me too

0

Please sign in to leave a comment.