diff --git a/html/scripts/hbmon.js b/html/scripts/hbmon.js
index 1ef37b4..3dc2d50 100644
--- a/html/scripts/hbmon.js
+++ b/html/scripts/hbmon.js
@@ -12,7 +12,7 @@
opb_table = document.getElementById('opb');
peers_table = document.getElementById('peers');
- wsuri = "ws://" + window.location.hostname + ":9000";
+ wsuri = (((window.location.protocol === "https:") ? "wss://" : "ws://") + window.location.hostname + ":9000");
if ("WebSocket" in window) {
sock = new WebSocket(wsuri);