Moli v1.1 Headless Browser for AI Agents (CDP)

Moli is an open-source headless browser for AI agents, written in Rust by Lexmount, with one endpoint for CDP, WebDriver Classic and WebDriver BiDi. This template runs Moli 1.1.22 always on behind a token gate, with no database and no volume.

What you get

  • Moli 1.1.22 from the official release binary, checksum-verified, listening on loopback only
  • A token gate on the public domain that requires MOLI_TOKEN on every request and WebSocket and rewrites CDP discovery to your wss:// address
  • Session limits: MOLI_MAX_SESSIONS (default 10) and an idle timeout (MOLI_IDLE_TIMEOUT, default 1800 s)
  • A block on pages reaching private networks, including *.railway.internal, enabled by default
  • BROWSER_WS_ENDPOINT and private-network variants for Playwright, Puppeteer, Selenium and browser-use

Good for

  • A remote browser for AI agents such as browser-use or Stagehand, or your own Playwright code
  • Scraping and extracting JavaScript-heavy pages: DOM, text, screenshots and PDFs
  • Link previews, screenshots and page monitoring for apps on Railway over the private network
  • A stand-in for code that reads BROWSER_WS_ENDPOINT from a Browserless service

Cost

No measurement on Railway. The template notes the gate at about 50 to 60 MB RSS measured locally on Node 24, and upstream's public-web crawl benchmark reporting a median RSS of 73 MiB for Moli. Its dollar figures are estimates, so check your own usage. Responses over the public domain count as egress.

Services in this template

  • Moli · from baranberkay96/moli-railway

Questions people ask

How do I connect?

Copy BROWSER_WS_ENDPOINT from the Variables tab; it looks like wss://{your-domain}?token={MOLI_TOKEN}. From another service in the project reference BROWSER_WS_ENDPOINT_PRIVATE, which uses the private network and adds no egress. The token can also be sent as a Bearer header or Basic auth password.

Is it Chromium?

No. Moli is its own engine. Most automation works, but some complex web apps, Canvas/WebGL and media playback behave differently, and unsupported protocol calls return explicit errors.

Is anything persisted?

No. Cookies and site storage are temporary, like an incognito window, and reset when Moli restarts. Log in from your script or set cookies per run.

Can I run replicas?

Keep one replica: each replica is a separate browser, and discovery and WebDriver sessions are not shared. Raise CPU and memory, or deploy a second service.

What are the usage rules and licence?

Respect each site's terms and robots.txt and do not use it for abuse or to get around access controls; Railway's Fair Use Policy applies. The NOTICE file lists Moli as Apache-2.0 or MIT at your option. Moli is young and changes quickly, so read its release notes before upgrading.

Full template README

Deploy and Host Moli with Railway

Moli is an open-source headless browser for AI agents, written in Rust by Lexmount. One endpoint speaks CDP, WebDriver Classic and WebDriver BiDi, so Playwright, Puppeteer, Selenium and browser-use connect to it like a remote Chrome. This template runs Moli 1.1.22 always on, behind a token.

About Hosting Moli

Moli has no login of its own, and its automation server only accepts local connections. An exposed browser is a free proxy for anyone who finds it. This community template keeps Moli on loopback and puts a small gate on the Railway domain. The gate requires a token generated at deploy on every request and WebSocket. It rewrites CDP discovery so clients get your public wss:// address. It also caps open sessions, closes idle ones and restarts Moli if it exits. Pages cannot reach your Railway private network by default. One service, no database, no volume.

Common Use Cases

  • A remote browser for AI agents (browser-use, Stagehand, LangChain tools, your own Playwright code) without running Chrome locally
  • Scraping and extraction of JavaScript-heavy pages: DOM, text, HTML, screenshots and PDFs
  • Link previews, screenshots and page monitoring for apps hosted on Railway, over the private network
  • A drop-in for code that reads BROWSER_WS_ENDPOINT from a Browserless service, for CDP clients

Dependencies for Moli Hosting

  • Moli 1.1.22, the official Linux release binary, checksum-verified (included)
  • A token gate built from this repository on Node.js 24 LTS (included)
  • A CDP or WebDriver client: Playwright, Puppeteer, Selenium, browser-use, chromedp or raw WebSockets

Deployment Dependencies

Implementation Details

Service Source Purpose
Moli Dockerfile in services/moli (Debian trixie slim, Moli 1.1.22, Node.js 24.22.2) Gate on PORT 8080 (public domain, /health healthcheck); moli serve on 127.0.0.1:9222

Connect. Copy BROWSER_WS_ENDPOINT from the service's Variables tab. It looks like wss://{your-domain}?token={MOLI_TOKEN}. From another service in the same project, reference ${{Moli.BROWSER_WS_ENDPOINT_PRIVATE}}: it uses the private network, which is faster and adds no egress.

Playwright (Node.js). Use one context per job; contexts keep cookies and storage apart:

import { chromium } from "playwright";

const browser = await chromium.connectOverCDP(process.env.BROWSER_WS_ENDPOINT);
const context = await browser.newContext();
const page = await context.newPage();
await page.goto("https://example.com");
console.log(await page.title());
await context.close();
await browser.close();

Playwright (Python) works the same way: await p.chromium.connect_over_cdp(os.environ["BROWSER_WS_ENDPOINT"]). To keep the token out of the URL, connect to https://{your-domain} and pass headers={"Authorization": "Bearer {MOLI_TOKEN}"}.

Puppeteer:

import puppeteer from "puppeteer-core";

const browser = await puppeteer.connect({ browserWSEndpoint: process.env.BROWSER_WS_ENDPOINT });

browser-use and other CDP tools: pass the same wss:// URL as the CDP URL. Prefer it over the https:// form for clients that append paths to the URL you give them.

Selenium (Python 4.26 or later). Moli's browser name is moli, so use plain options rather than ChromeOptions:

import os
from selenium import webdriver
from selenium.webdriver.common.options import ArgOptions
from selenium.webdriver.remote.client_config import ClientConfig

url = os.environ["BROWSER_WEBDRIVER_ENDPOINT"]
options = ArgOptions()
options.set_capability("browserName", "moli")
driver = webdriver.Remote(
    command_executor=url,
    options=options,
    client_config=ClientConfig(remote_server_addr=url, username="moli", password=os.environ["MOLI_TOKEN"]),
)

Add options.set_capability("webSocketUrl", True) for WebDriver BiDi; the returned BiDi URL already points to your domain.

Authentication. Every path except /health and /robots.txt needs MOLI_TOKEN, sent as ?token=, as Authorization: Bearer, or as the Basic auth password (any user name). The gate removes the token before the request reaches Moli. Requests from a browser page on another site are refused; list trusted origins in MOLI_ALLOWED_ORIGINS if you need that. To rotate the token, change MOLI_TOKEN and redeploy. Discovery URLs (/json/version, /json/list) include the token, so treat their output like the token itself.

Modes. MOLI_MODE picks what Moli computes:

  • layout (default): real layout, screenshots, PDFs and coordinate input, built only when a request needs them. Best for Playwright and browser-use.
  • dom: DOM, JavaScript and network only. Uses the least CPU, but screenshots and element boxes are not real.
  • full: layout plus images, fonts, audio, video and other media. Closest to Chrome for screenshots, uses the most bandwidth.

MOLI_EXTRA_ARGS passes more flags to moli serve, such as --user-agent "MyAgent/1.0" or --http-proxy socks5://host:1080.

Limits. MOLI_MAX_SESSIONS (default 10) caps open WebSocket connections; extra ones get HTTP 429. MOLI_IDLE_TIMEOUT (default 1800 s) closes connections with no traffic. MOLI_SESSION_TIMEOUT (default off) caps a connection's lifetime. One Playwright or Puppeteer connection can hold many pages, and WebDriver Classic sessions are not counted.

Private networks. MOLI_BLOCK_PRIVATE_NETWORKS=true (default) stops pages from reaching private, loopback and link-local addresses, including *.railway.internal and cloud metadata. Set it to false only to browse your own internal services. Traffic sent through --http-proxy is filtered by the proxy, not by Moli.

Scaling and cost. Keep one replica: each replica is a separate browser, and discovery and WebDriver sessions are not shared between replicas. Raise CPU and memory instead, or deploy a second service. Moli is light: upstream's public-web crawl benchmark reports a median RSS of 73 MiB, and the gate adds roughly 50 to 60 MB. Estimates at Railway prices, not measurements: about $1/month idle, $5 to $10/month for an agent working a few hours a day, $30 to $60/month for around ten busy sessions. Responses sent over the public domain count as egress. Trial works for light use; Hobby is the practical plan.

Persistence. None: cookies and site storage are temporary, like an incognito window, and reset when Moli restarts. Log in from your script or set cookies per run.

Pinning and upgrades. Moli and Node.js versions and their SHA-256 checksums are build arguments at the top of services/moli/Dockerfile. Change them to a newer release and redeploy. Moli is young and changes quickly; read its release notes before upgrading.

Compatibility. Moli is its own engine, not Chromium. Most automation works, but some complex web apps, Canvas/WebGL and media playback behave differently. Unsupported protocol calls return explicit errors.

Fair use. Respect the terms of service and robots.txt of the sites you visit, keep request rates reasonable, and do not use this browser for abuse, spam, credential stuffing or to get around access controls. Railway's Fair Use Policy applies to your deployment. This is a community template, not affiliated with or endorsed by Lexmount.

Why Deploy Moli on Railway?

Railway gives Moli an HTTPS domain, private networking to your other services and usage-based billing, with nothing to administer. Your agents get a browser that is always on and protected by a token, and costs little while it waits.

Guides for this template

View Moli v1.1 Headless Browser for AI Agents (CDP) on railway.com

Similar templates

TemplateCategoryDeploymentsDeploys
N8N (w/ workers)
A powerful workflow automation tool for technical people
Automation114,737
n8n
n8n [Nov '26] (Workflows/Integrations/API Automation/AI Coding) Self Host
Automation17,560
Typebot
Build advanced chatbots visually
Automation8,968
n8n
n8n workflow automation on PostgreSQL, webhooks and secrets preconfigured
Automation5,850
n8n with workers
A complete setup for n8n with workers
Automation4,040
N8N (w/ webhook processors)
A powerful workflow automation tool for technical people
Automation3,386