diff --git a/server/HtmlOrphans.hs b/server/HtmlOrphans.hs
index b90ea6d162a9067f0400e0f480bb137c8c6b4754..ee30773e0584db07e7e9f4a66583915908634bab 100644
--- a/server/HtmlOrphans.hs
+++ b/server/HtmlOrphans.hs
@@ -75,7 +75,8 @@ instance ToHtml JobStatus where
         p_ "you should probably ping an admin about this or sth"
       where
         autoReloadScript = script_
-          "let ws = new WebSocket('ws://localhost:8080' + window.location.pathname + 'realtime');\n\
+          "let proto = window.location.protocol === 'https://' ? 'wss' : 'ws://';\
+          \let ws = new WebSocket(proto + window.location.host + window.location.pathname + 'realtime');\n\
           \ws.onmessage = (event) => {\n\
           \  let resp = JSON.parse(event.data);\n\
           \  if (resp == 'RelintPending') {\n\