diff --git a/tests/common-pattern.py b/tests/common-pattern.py
index e58f02e2f6a903f78793f7dc54dab5a449e6dacf_dGVzdHMvY29tbW9uLXBhdHRlcm4ucHk=..73a43fe3e6fdcc59095f07beb42b21ebd4168d4b_dGVzdHMvY29tbW9uLXBhdHRlcm4ucHk= 100644
--- a/tests/common-pattern.py
+++ b/tests/common-pattern.py
@@ -168,6 +168,12 @@
         # FormatMessage(WSAEADDRNOTAVAIL)
         br'The requested address is not valid in its context',
     ),
+    br'$ECONNREFUSED$': (
+        # strerror()
+        br'Connection refused',
+        # FormatMessage(WSAECONNREFUSED)
+        br'No connection could be made because the target machine actively refused it',
+    ),
 }
 
 for replace, msgs in _errors.items():
diff --git a/tests/test-clone.t b/tests/test-clone.t
index e58f02e2f6a903f78793f7dc54dab5a449e6dacf_dGVzdHMvdGVzdC1jbG9uZS50..73a43fe3e6fdcc59095f07beb42b21ebd4168d4b_dGVzdHMvdGVzdC1jbG9uZS50 100644
--- a/tests/test-clone.t
+++ b/tests/test-clone.t
@@ -618,5 +618,4 @@
 
 No remote source
 
-#if windows
   $ hg clone http://$LOCALIP:3121/a b
@@ -622,3 +621,3 @@
   $ hg clone http://$LOCALIP:3121/a b
-  abort: error: * (glob)
+  abort: error: $ECONNREFUSED$
   [100]
@@ -624,9 +623,5 @@
   [100]
-#else
-  $ hg clone http://$LOCALIP:3121/a b
-  abort: error: *refused* (glob)
-  [100]
-#endif
+
   $ rm -rf b # work around bug with http clone
 
 
diff --git a/tests/test-clonebundles.t b/tests/test-clonebundles.t
index e58f02e2f6a903f78793f7dc54dab5a449e6dacf_dGVzdHMvdGVzdC1jbG9uZWJ1bmRsZXMudA==..73a43fe3e6fdcc59095f07beb42b21ebd4168d4b_dGVzdHMvdGVzdC1jbG9uZWJ1bmRsZXMudA== 100644
--- a/tests/test-clonebundles.t
+++ b/tests/test-clonebundles.t
@@ -78,7 +78,7 @@
   $ echo "http://localhost:$HGPORT1/bundle.hg" > server/.hg/clonebundles.manifest
   $ hg clone http://localhost:$HGPORT server-not-runner
   applying clone bundle from http://localhost:$HGPORT1/bundle.hg
-  error fetching bundle: (.* refused.*|Protocol not supported|(.* )?\$EADDRNOTAVAIL\$|.* No route to host) (re)
+  error fetching bundle: (.*\$ECONNREFUSED\$|Protocol not supported|(.* )?\$EADDRNOTAVAIL\$|.* No route to host) (re)
   abort: error applying bundle
   (if this error persists, consider contacting the server operator or disable clone bundles via "--config ui.clonebundles=false")
   [255]
diff --git a/tests/test-http-proxy.t b/tests/test-http-proxy.t
index e58f02e2f6a903f78793f7dc54dab5a449e6dacf_dGVzdHMvdGVzdC1odHRwLXByb3h5LnQ=..73a43fe3e6fdcc59095f07beb42b21ebd4168d4b_dGVzdHMvdGVzdC1odHRwLXByb3h5LnQ= 100644
--- a/tests/test-http-proxy.t
+++ b/tests/test-http-proxy.t
@@ -81,7 +81,7 @@
 misconfigured hosts)
 
   $ http_proxy=localhost:$HGPORT2 hg clone --config http_proxy.always=True http://localhost:$HGPORT/ f
-  abort: error: (Connection refused|Protocol not supported|.* actively refused it|\$EADDRNOTAVAIL\$|No route to host) (re)
+  abort: error: (\$ECONNREFUSED\$|Protocol not supported|.* actively refused it|\$EADDRNOTAVAIL\$|No route to host) (re)
   [100]
 
 do not use the proxy if it is in the no list
@@ -99,7 +99,7 @@
 proxy can't connect to server
 
   $ http_proxy=http://localhost:$HGPORT1/ hg --config http_proxy.always=True clone http://localhost:$HGPORT2/ h
-  abort: HTTP Error 404: Connection refused
+  abort: HTTP Error 404: $ECONNREFUSED$
   [100]
 
   $ cat proxy.log
@@ -118,5 +118,5 @@
   * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
   $LOCALIP - - [$LOGDATE$] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
   $LOCALIP - - [$LOGDATE$] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=1&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
-  * - - [*] code 404, message Connection refused (glob)
+  * - - [*] code 404, message $ECONNREFUSED$ (glob)
   $LOCALIP - - [$LOGDATE$] "GET http://localhost:$HGPORT2/?cmd=capabilities HTTP/1.1" 404 - (glob)
diff --git a/tests/test-https.t b/tests/test-https.t
index e58f02e2f6a903f78793f7dc54dab5a449e6dacf_dGVzdHMvdGVzdC1odHRwcy50..73a43fe3e6fdcc59095f07beb42b21ebd4168d4b_dGVzdHMvdGVzdC1odHRwcy50 100644
--- a/tests/test-https.t
+++ b/tests/test-https.t
@@ -490,7 +490,7 @@
 
   $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --insecure https://localhost:0/
   pulling from https://localhost:0/
-  abort: error: Tunnel connection failed: 404 (Connection refused|\$EADDRNOTAVAIL\$) (re)
+  abort: error: Tunnel connection failed: 404 (\$ECONNREFUSED\$|\$EADDRNOTAVAIL\$) (re)
   [100]
 
 
diff --git a/tests/test-lfs-serve-access.t b/tests/test-lfs-serve-access.t
index e58f02e2f6a903f78793f7dc54dab5a449e6dacf_dGVzdHMvdGVzdC1sZnMtc2VydmUtYWNjZXNzLnQ=..73a43fe3e6fdcc59095f07beb42b21ebd4168d4b_dGVzdHMvdGVzdC1sZnMtc2VydmUtYWNjZXNzLnQ= 100644
--- a/tests/test-lfs-serve-access.t
+++ b/tests/test-lfs-serve-access.t
@@ -83,7 +83,7 @@
   [50]
 
   $ hg -R httpclone update default --config lfs.url=http://localhost:$HGPORT2/missing
-  abort: LFS error: *onnection *refused* (glob) (?)
+  abort: LFS error: $ECONNREFUSED$ (?)
   abort: LFS error: $EADDRNOTAVAIL$ (glob) (?)
   abort: LFS error: No route to host (?)
   (the "lfs.url" config may be used to override http://localhost:$HGPORT2/missing)