From f90945c45afba7ee22a10ccb913f77ebfd49d80a Mon Sep 17 00:00:00 2001 From: storyicon Date: Sun, 1 Jun 2025 04:47:14 +0800 Subject: [PATCH] fix(PD-disaggregation): Can not get local ip (#6792) Signed-off-by: storyicon --- python/sglang/srt/utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/python/sglang/srt/utils.py b/python/sglang/srt/utils.py index 6b82ca47a..58ada392c 100644 --- a/python/sglang/srt/utils.py +++ b/python/sglang/srt/utils.py @@ -2077,6 +2077,14 @@ def get_local_ip_by_remote() -> str: except Exception: pass + try: + hostname = socket.gethostname() + ip = socket.gethostbyname(hostname) + if ip and ip != "127.0.0.1" and ip != "0.0.0.0": + return ip + except Exception: + pass + # try ipv6 try: s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)