diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh
index a6723fc9f86624738499c4408924816d03ce0b6c..795c67886003f69dad780e18411d502c8099108d 100755
--- a/scripts/run-tests.sh
+++ b/scripts/run-tests.sh
@@ -250,7 +250,7 @@ function simpletest_script_init() {
   // Get url from arguments.
   if (!empty($args['url'])) {
     $parsed_url = parse_url($args['url']);
-    $host = $parsed_url['host'];
+    $host = $parsed_url['host'] . (isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '');
     $path = $parsed_url['path'];
   }