diff --git a/rhodecode/lib/utils2.py b/rhodecode/lib/utils2.py --- a/rhodecode/lib/utils2.py +++ b/rhodecode/lib/utils2.py @@ -36,6 +36,7 @@ import urlobject import uuid import getpass import socket +import errno import random from functools import update_wrapper, partial, wraps @@ -1201,7 +1202,11 @@ def get_available_port(min_port=40000, m sock.close() break except OSError: - pass + continue + except socket.error as e: + if e.args[0] in [errno.EADDRINUSE, errno.ECONNREFUSED]: + continue + raise del sock return pick_port