diff --git a/test/core/util/port_posix.c b/test/core/util/port_posix.c
index 55150a7cedce51b5401936f2d22dce4e4081b4e7..36f13e1b51e5a4084e3ddd74bd702498ed51949c 100644
--- a/test/core/util/port_posix.c
+++ b/test/core/util/port_posix.c
@@ -117,9 +117,10 @@ int grpc_pick_unused_port(void) {
 
   for (;;) {
     int port;
-    if (try == 0) {
+    try++;
+    if (try == 1) {
       port = getpid() % (65536 - 30000) + 30000;
-    } else if (try < NUM_RANDOM_PORTS_TO_PICK) {
+    } else if (try <= NUM_RANDOM_PORTS_TO_PICK) {
       port = rand() % (65536 - 30000) + 30000;
     } else {
       port = 0;