diff --git a/test/jdk/sun/tools/jstatd/JstatdTest.java b/test/jdk/sun/tools/jstatd/JstatdTest.java
index bec5ee4582e..b193b92984e 100644
--- a/test/jdk/sun/tools/jstatd/JstatdTest.java
+++ b/test/jdk/sun/tools/jstatd/JstatdTest.java
@@ -65,6 +65,8 @@ public final class JstatdTest {
     private static final int JSTAT_GCUTIL_INTERVAL_MS = 250;
     private static final String JPS_OUTPUT_REGEX = "^\\d+\\s*.*";
 
+    private static final int MAX_JSTATD_TRIES = 10;
+
     private boolean useDefaultPort = true;
     private boolean useDefaultRmiPort = true;
     private String port;
@@ -288,7 +290,7 @@ private void addToolArg(JDKToolLauncher launcher, String name, String value) {
     private ProcessThread tryToSetupJstatdProcess() throws Throwable {
         portInUse = false;
         ProcessThread jstatdThread = new ProcessThread("Jstatd-Thread",
-                JstatdTest::isJstadReady, getJstatdCmd());
+                JstatdTest::isJstatdReady, getJstatdCmd());
         try {
             jstatdThread.start();
             // Make sure jstatd is up and running
@@ -308,8 +310,8 @@ private ProcessThread tryToSetupJstatdProcess() throws Throwable {
         return jstatdThread;
     }
 
-    private static boolean isJstadReady(String line) {
-        if (line.contains("Port already in use")) {
+    private static boolean isJstatdReady(String line) {
+        if (line.contains("Port already in use") || line.contains("Could not bind")) {
             portInUse = true;
             return true;
         }
@@ -328,8 +330,9 @@ private void runTest(boolean useShortSyntax) throws Throwable {
         }
 
         ProcessThread jstatdThread = null;
+        int tries = 0;
         try {
-            while (jstatdThread == null) {
+            while (jstatdThread == null && ++tries <= MAX_JSTATD_TRIES) {
                 if (!useDefaultPort) {
                     port = String.valueOf(Utils.getFreePort());
                 }
@@ -345,10 +348,11 @@ private void runTest(boolean useShortSyntax) throws Throwable {
                         continue;
                     }
                 }
-
                 jstatdThread = tryToSetupJstatdProcess();
             }
-
+            if (jstatdThread == null) {
+                throw new RuntimeException("Cannot start jstatd.");
+            }
             runToolsAndVerify();
         } finally {
             cleanUpThread(jstatdThread);