diff --git a/tests/run-tests.py b/tests/run-tests.py
index 636cf3f7620daa554fbde7894859cff21f6fc07f_dGVzdHMvcnVuLXRlc3RzLnB5..161ab32b44a1eb67c38cc730c3dd69f682d89936_dGVzdHMvcnVuLXRlc3RzLnB5 100755
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -933,6 +933,8 @@
         hgrc.write(b'[largefiles]\n')
         hgrc.write(b'usercache = %s\n' %
                    (os.path.join(self._testtmp, b'.cache/largefiles')))
+        hgrc.write(b'[web]\n')
+        hgrc.write(b'address = localhost\n')
 
         for opt in self._extraconfigopts:
             section, key = opt.split('.', 1)
diff --git a/tests/test-basic.t b/tests/test-basic.t
index 636cf3f7620daa554fbde7894859cff21f6fc07f_dGVzdHMvdGVzdC1iYXNpYy50..161ab32b44a1eb67c38cc730c3dd69f682d89936_dGVzdHMvdGVzdC1iYXNpYy50 100644
--- a/tests/test-basic.t
+++ b/tests/test-basic.t
@@ -11,6 +11,7 @@
   ui.interactive=False
   ui.mergemarkers=detailed
   ui.promptecho=True
+  web.address=localhost
   web.ipv6=True (?)
   $ hg init t
   $ cd t
diff --git a/tests/test-commandserver.t b/tests/test-commandserver.t
index 636cf3f7620daa554fbde7894859cff21f6fc07f_dGVzdHMvdGVzdC1jb21tYW5kc2VydmVyLnQ=..161ab32b44a1eb67c38cc730c3dd69f682d89936_dGVzdHMvdGVzdC1jb21tYW5kc2VydmVyLnQ= 100644
--- a/tests/test-commandserver.t
+++ b/tests/test-commandserver.t
@@ -199,6 +199,7 @@
   ui.usehttp2=true (?)
   ui.foo=bar
   ui.nontty=true
+  web.address=localhost
   web.ipv6=True (?)
   *** runcommand init foo
   *** runcommand -R foo showconfig ui defaults
diff --git a/tests/test-http-bundle1.t b/tests/test-http-bundle1.t
index 636cf3f7620daa554fbde7894859cff21f6fc07f_dGVzdHMvdGVzdC1odHRwLWJ1bmRsZTEudA==..161ab32b44a1eb67c38cc730c3dd69f682d89936_dGVzdHMvdGVzdC1odHRwLWJ1bmRsZTEudA== 100644
--- a/tests/test-http-bundle1.t
+++ b/tests/test-http-bundle1.t
@@ -28,7 +28,7 @@
 
 #if windows
   $ hg serve -p $HGPORT1 2>&1
-  abort: cannot start server at ':$HGPORT1': * (glob)
+  abort: cannot start server at 'localhost:$HGPORT1': * (glob)
   [255]
 #else
   $ hg serve -p $HGPORT1 2>&1
@@ -32,7 +32,7 @@
   [255]
 #else
   $ hg serve -p $HGPORT1 2>&1
-  abort: cannot start server at ':$HGPORT1': Address already in use
+  abort: cannot start server at 'localhost:$HGPORT1': Address already in use
   [255]
 #endif
   $ cd ..
diff --git a/tests/test-http.t b/tests/test-http.t
index 636cf3f7620daa554fbde7894859cff21f6fc07f_dGVzdHMvdGVzdC1odHRwLnQ=..161ab32b44a1eb67c38cc730c3dd69f682d89936_dGVzdHMvdGVzdC1odHRwLnQ= 100644
--- a/tests/test-http.t
+++ b/tests/test-http.t
@@ -23,7 +23,7 @@
   [255]
 #else
   $ hg serve -p $HGPORT1 2>&1
-  abort: cannot start server at ':$HGPORT1': Address already in use
+  abort: cannot start server at 'localhost:$HGPORT1': Address already in use
   [255]
 #endif
   $ cd ..
diff --git a/tests/test-https.t b/tests/test-https.t
index 636cf3f7620daa554fbde7894859cff21f6fc07f_dGVzdHMvdGVzdC1odHRwcy50..161ab32b44a1eb67c38cc730c3dd69f682d89936_dGVzdHMvdGVzdC1odHRwcy50 100644
--- a/tests/test-https.t
+++ b/tests/test-https.t
@@ -36,7 +36,7 @@
 
 #if windows
   $ hg serve -p $HGPORT --certificate=$PRIV 2>&1
-  abort: cannot start server at ':$HGPORT':
+  abort: cannot start server at 'localhost:$HGPORT':
   [255]
 #else
   $ hg serve -p $HGPORT --certificate=$PRIV 2>&1
@@ -40,7 +40,7 @@
   [255]
 #else
   $ hg serve -p $HGPORT --certificate=$PRIV 2>&1
-  abort: cannot start server at ':$HGPORT': Address already in use
+  abort: cannot start server at 'localhost:$HGPORT': Address already in use
   [255]
 #endif
   $ cd ..