1- from  dataclasses  import  dataclass , field , fields 
1+ from  dataclasses  import  asdict ,  dataclass , field , fields 
22from  functools  import  cached_property 
33from  json  import  loads 
44from  os  import  PathLike 
5+ from  platform  import  system 
56from  re  import  split 
67from  subprocess  import  CompletedProcess 
78from  subprocess  import  run  as  subprocess_run 
@@ -38,6 +39,14 @@ class PublishedPort:
3839    PublishedPort : Optional [str ] =  None 
3940    Protocol : Optional [str ] =  None 
4041
42+     def  normalize (self ):
43+         url_not_usable  =  system () ==  "Windows"  and  self .URL  ==  "0.0.0.0" 
44+         if  url_not_usable :
45+             self_dict  =  asdict (self )
46+             self_dict .update ({"URL" : "127.0.0.1" })
47+             return  PublishedPort (** self_dict )
48+         return  self 
49+ 
4150
4251OT  =  TypeVar ("OT" )
4352
@@ -357,7 +366,7 @@ def get_service_port(
357366        str: 
358367            The mapped port on the host 
359368        """ 
360-         return  self .get_container (service_name ).get_publisher (by_port = port ).PublishedPort 
369+         return  self .get_container (service_name ).get_publisher (by_port = port ).normalize (). PublishedPort 
361370
362371    def  get_service_host (
363372        self ,
@@ -379,14 +388,14 @@ def get_service_host(
379388        str: 
380389            The hostname for the service 
381390        """ 
382-         return  self .get_container (service_name ).get_publisher (by_port = port ).URL 
391+         return  self .get_container (service_name ).get_publisher (by_port = port ).normalize (). URL 
383392
384393    def  get_service_host_and_port (
385394        self ,
386395        service_name : Optional [str ] =  None ,
387396        port : Optional [int ] =  None ,
388397    ):
389-         publisher  =  self .get_container (service_name ).get_publisher (by_port = port )
398+         publisher  =  self .get_container (service_name ).get_publisher (by_port = port ). normalize () 
390399        return  publisher .URL , publisher .PublishedPort 
391400
392401    @wait_container_is_ready (HTTPError , URLError ) 
0 commit comments