Access AI-Toolkit UI from Colab with CloudflaredAccess AI-Toolkit UI from Colab with CloudflaredAccess AI-Toolkit UI from Colab with Cloudflared

2026::02::05
2 min
AUTHOR:Z.SHINCHVEN

Running AI tools in Google Colab is powerful, but accessing web interfaces can sometimes be tricky. This guide shows you how to expose the AI-Toolkit UI to the public internet securely using cloudflared.

Quick Command

Copy and paste the following code block into a cell in your Google Colab notebook to start the UI and generate a public access URL.

#@title Run AI Tooklit UI
%cd /content/ai-toolkit/ui

import subprocess
import threading
import time
import socket
import urllib.request

def iframe_thread(port):
  while True:
      time.sleep(0.5)
      sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      result = sock.connect_ex(('127.0.0.1', port))
      if result == 0:
        break
      sock.close()
  print("\nAI-Toolkit UI finished loading, trying to launch cloudflared (if it gets stuck here cloudflared is having issues)\n")

  p = subprocess.Popen(["cloudflared", "tunnel", "--url", "http://127.0.0.1:{}".format(port)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  for line in p.stderr:
    l = line.decode()
    if "trycloudflare.com " in l:
      print("This is the URL to access AI Tookit UI:", l[l.find("http"):], end='')
    #print(l, end='')


threading.Thread(target=iframe_thread, daemon=True, args=(8675,)).start()

# Replace YOUR_SUPER_SECRET_PASSWORD_HERE with your own password
!AI_TOOLKIT_AUTH=YOUR_SUPER_SECRET_PASSWORD_HERE npm run build_and_start

How It Works

  1. Port Monitoring: The script runs a background thread that continuously checks if port 8675 (the default port for AI-Toolkit UI) is open on localhost.
  2. Cloudflared Tunnel: Once the port is active, it launches cloudflared to create a secure tunnel pointing to http://127.0.0.1:8675.
  3. URL Extraction: It parses the output from Cloudflare to find the trycloudflare.com URL and prints it for you to click.
  4. Secure Access: The application starts with AI_TOOLKIT_AUTH enabled, ensuring that only users with the password can access your instance.
RackNerd Billboard Banner
Share Node:

RELATED_DATA_STREAMS

SCANNING_DATABASE_FOR_CORRELATIONS...