'getting this error: java.net.BindException: Address already in use: Cannot bind

Hello am building a flutter apk using vscode but I get the error below, any help on how to go about it. Did a research but am getting no solution. I have configured JAVA_HOME well in gradle setting in android studio yet gradle am still getting the same error

FAILURE: Build failed with an exception.

* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/6.5/userguide/gradle_daemon.html
Process command line: C:\Program Files\Android\Android Studio\jre\bin\java.exe --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED -Xmx1536M -Dfile.encoding=windows-1252 -Duser.country=US -Duser.language=en -Duser.variant -cp C:\Users\cs\.gradle\wrapper\dists\gradle-6.5-all\2oz4ud9k3tuxjg84bbf55q0tn\gradle-6.5\lib\gradle-launcher-6.5.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.5
Please read the following process output to find out more:

    FAILURE: Build failed with an exception.
    
    * What went wrong:
    java.net.BindException: Address already in use: Cannot bind
    
    * Try:
    Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Exception is:
    org.gradle.api.UncheckedIOException: java.net.BindException: Address already in use: Cannot bind
        at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:61)
        at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:41)
        at org.gradle.cache.internal.locklistener.FileLockCommunicator.<init>(FileLockCommunicator.java:51)
        at org.gradle.cache.internal.locklistener.DefaultFileLockContentionHandler.getCommunicator(DefaultFileLockContentionHandler.java:263)
        at org.gradle.cache.internal.locklistener.DefaultFileLockContentionHandler.reservePort(DefaultFileLockContentionHandler.java:255)
        at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:108)
        at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:95)
        at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:90)
        at org.gradle.cache.internal.OnDemandFileAccess.updateFile(OnDemandFileAccess.java:51)
        at org.gradle.cache.internal.SimpleStateCache.update(SimpleStateCache.java:87)
        
    
    
    * Get more help at https://help.gradle.org
    
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org


Solution 1:[1]

What worked for me on Windows;

  • I opened task manager (with Ctrl+Alt+Delete).
  • Stopped and/or ended processes for all running openJDKs (like any java.exe).
  • Just re-run Gradle and done! Worked fine for me.

Solution 2:[2]

That's because you start debugging while hotspot is active in your device All you need to do is :

  1. Open your Task Manager alt+ctrl+delete
  2. End-Task of all open-JDKs
  3. turn of mobile-hotspot
  4. start debug again
  5. Keep Coding

Solution 3:[3]

I've had encountered the same problem before, what I did was just simply turn off the mobile hotspot on my laptop, run and debug again then it works like a charm! turn off this one

p/s: I turn on the mobile hotspot to share the internet connection with my other laptop at that time, so you just need to turn it off then it should be okay after that.

Solution 4:[4]

when you look at task manager there is many open JDK platformBinary open and running in the same time, i recommend you to restart your laptop and it will be normally again. i recommend this to you cause this was work on me.

Solution 5:[5]

I disabled Mobile hotspot in my windows pc , then tried build it didn't worked for me. then i just logged out from and logged in tried build again , its worked!

Solution 6:[6]

In Windows open task manager Ctrl + Alt + Supr then end the tasks for adb.exe. That worked for me

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Top-Master
Solution 2 ewertonvsilva
Solution 3 Dharman
Solution 4 LulungSatrioPrayuda
Solution 5 San
Solution 6 Vladimir Salguero