diff --git a/build/pgo/profileserver.py b/build/pgo/profileserver.py
index 6017810c873f6be5a5d133dc9386f7cd8879e81b..6d399e0c8135d2c27157c81d75515de04c39f1d7 100755
--- a/build/pgo/profileserver.py
+++ b/build/pgo/profileserver.py
@@ -18,7 +18,13 @@ from mozprofile import FirefoxProfile, Preferences
 from mozprofile.permissions import ServerLocations
 from mozrunner import CLI, FirefoxRunner
 
-PORT = 8888
+import socket
+def find_free_port():
+    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
+        s.bind(('', 0))
+        return s.getsockname()[1]
+
+PORT = find_free_port()
 
 PATH_MAPPINGS = {
     "/webkit/PerformanceTests": "third_party/webkit/PerformanceTests",
