Search Unity

[SOLVED] Socket: bind failed, error: Address already in use(98)

Discussion in 'Linux' started by IC_, Jan 10, 2019.

  1. IC_

    IC_

    Joined:
    Jan 27, 2016
    Posts:
    64
    After unity hangs I usually kill it with `xkill`. After removing `Temp` folder in project root and relaunch project there is an error message in console "Socket: bind failed, error: Address already in use(98)"

    This forces me to restart system because after this error I can't debug my game at all (Breakpoints not hit)
    There was a thread https://forum.unity.com/threads/socket-bind-failed-error-address-already-in-use-98.350909/ but there is no solution
    On issue tracker https://issuetracker.unity3d.com/is...-already-in-use-48-when-importing-the-project this issue is marked as non-reproducible

    `ps aux | grep unity` gives me some unityhub and unity-editor processes. But killing them still has no effect.

    Solution:
    https://forum.unity.com/threads/sol...ddress-already-in-use-98.610504/#post-4194364
     
    Last edited: Feb 9, 2019
  2. senkal_

    senkal_

    Joined:
    May 22, 2018
    Posts:
    86
    Hi @nullptr_
    Do you use any custom way to start adb services?
    If not, looks like it is related to the killing thing.
    After killing, could you check(netstat or similar) if anything is still using the port?
    At least for me, Unity uses 34999 (based on command which uses tcp:34999), so maybe that port is still "locked" by Unity after manual process kill.
     
  3. IC_

    IC_

    Joined:
    Jan 27, 2016
    Posts:
    64
    Thank you for response

    No, I use adb from official ubuntu repos but it doesn't look like Android related issue

    I checked netstat and there is no unity records at all. Do you use any arguments to find unity in list?
     
  4. senkal_

    senkal_

    Joined:
    May 22, 2018
    Posts:
    86
    @nullptr_
    Unfortuantely my knowledge about the subject is limited here :)
    I don't know about other tricks to find the blocking process apart from what you have been doing.
    The only thing I can suggest is to try to reproduce it and file a bug report.

    As I understand the fact that Unity freezes for you is crucial here.
    Few times Unity freezed/crashed for me but after another Unity(not whole PC) restart I didn't encounter issues you see.
    So maybe it is not that easy to reproduce.

    I have never cleared "Temp" folder after crash, why do you do it?
     
  5. IC_

    IC_

    Joined:
    Jan 27, 2016
    Posts:
    64
    Because broken cache interrupts unity launch. It's just closes without any errors. Sorry for late answer I've just stucked into that problem in hope to find a solution and noticed you question
     
  6. IC_

    IC_

    Joined:
    Jan 27, 2016
    Posts:
    64
    After a big research with ag, grep, find and so on in whole system i've found that unity creates a file with name like
    /tmp/.mount_UnityHDpVLGD
    . You cannot just remove it even with sudo. The solution is to cd there and execute
    lsof +D ./ | awk '{print $2}' | tail -n +2 | xargs kill -9
    in that directory (Original: https://unix.stackexchange.com/a/216520/274472), but my approach is better
    lsof /tmp/.mount_UnityH*/* | awk 'FNR > 1 {print $2}' | uniq | xargs sudo kill -9


    After that unity can recreate socket successfully and debugging works fine
     
    Last edited: Feb 9, 2019
  7. senkal_

    senkal_

    Joined:
    May 22, 2018
    Posts:
    86
    wow .. that is some solution, great you were able to fix it for you
     
  8. PixelJ

    PixelJ

    Unity Technologies

    Joined:
    Nov 1, 2018
    Posts:
    216
    Hmm, that seems like a headache. Could submit a bug for this? Seems like Unity should probably nuke that file on startup.