Deploy Deploy Moli Headless Browser
Lightweight Rust headless browser for AI agents over CDP
Just deployed
Deploy and Host self hosted Moli (Headless Browser) on Railway
This template deploys Moli, an open-source Rust headless browser for AI agents, behind a secret token path exposing its CDP endpoint over HTTPS.
About Hosting Moli open-source software on Railway (self hosted Moli template)
This template runs one Moli service on Railway, built from the community-maintained onepush-dev/moli:1.1.22 image. Inside the container, Moli listens on internal port 9223 and nginx serves public port 8080.
Why Deploy Moli, the open-source headless browser on Railway (Railway Free Trial)
Moli on Railway is a lightweight Chromium alternative you control end to end. Railway's trial credit may be enough to test the deployment and connect a client, depending on your usage.
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying Moli on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Railway vs Other Hosting Providers and VPS for Moli self hosting
Moli runs as one stateless Railway service with little host setup.
| Provider | What You Get with Railway | What You Get with the Other Provider |
|---|---|---|
| DigitalOcean | A managed service that builds from the Docker image, sets MOLI_TOKEN and MOLI_CDP_URL, and exposes a public HTTPS domain. | A Droplet you control, where you set up Docker, nginx, TLS, and OS patching yourself. |
| AWS | A template deploy with no VPC or security group design, and automatic restarts on failure. | Broad control over networking and sizing, with more configuration to finish before Moli serves traffic. |
| Hetzner | A managed deploy that keeps the browser endpoint behind a token path with no firewall rules to maintain. | Low-cost servers with generous resources, where you manage the OS, reverse proxy, and Moli process. |
Common Use Cases for hosted Moli
- CDP automation: Point Playwright or Puppeteer at your hosted endpoint with connectOverCDP or browserURL, and drive pages from a remote agent without installing Chromium on your own machine.
- Semantic page extraction: Pull Markdown or a compact semantic text tree from pages that need JavaScript to render, which keeps the payload small enough to feed straight into a model prompt.
- Testing pages from remote clients: Run browser checks from outside your network through the same token-protected endpoint.
- Browser tasks for agents: Let an agent navigate, click, and read results through the endpoint while Moli runs on Railway.
- WebDriver integrations: Connect WebDriver Classic or BiDi clients to the same endpoint if your tooling already uses them.
Dependencies for Moli Docker hosted on Railway
This template runs Moli as a single service built from the onepush-dev/moli:1.1.22 image. No database or volume is involved.
Deployment Dependencies for Managed Moli Service (one stateless service, Rust binary and nginx, no database or volume)
The service needs only Railway. Without a volume, sessions and profiles do not survive a restart or redeploy. Keep replicas at one.
- MOLI_TOKEN: the secret path segment guarding the endpoint, enforced by this template's nginx wrapper. Rotate it to revoke access. Stock upstream Moli does not authenticate with this variable, and the standalone binary does not read it.
- MOLI_CDP_URL: the full endpoint in the form https://your-domain/t/token, pasted into your client.
- MOLI_SERVE_ARGS: optional, defaults to --layout --block-private-networks.
Implementation Details for Moli (onepush-dev/moli:1.1.22 uses sha256-verified upstream binary and nginx token-path gate)
The image is a community packaging of upstream Moli v1.1.22, with the binary checked against a sha256 checksum at build time. Treat MOLI_CDP_URL as a password and keep it out of logs. The token path is enforced by the nginx wrapper in this template, not by upstream Moli.
How does Moli compare against other tools
Moli vs Chromium (Chromium Alternative)
- Not Chromium: Moli is a standalone Rust browser kernel, not a Chromium wrapper, so rendering can differ from Chrome.
- Lighter by default: Moli runs layout and paint only when requested, suiting DOM-first agent work.
- Where Chromium wins: Chromium offers broader compatibility and visual fidelity for pixel-accurate rendering.
Moli vs Browserless (Browserless Alternative)
- Self-hosted control: Moli is open-source (Apache-2.0 OR MIT) and runs as one service you own.
- Protocol surface: Moli exposes CDP, WebDriver Classic, and WebDriver BiDi from one endpoint.
- Where Browserless wins: It is managed, so scaling and support are handled.
Moli vs Lightpanda (Lightpanda Alternative)
- Shared focus: Both target agent-oriented headless workloads rather than full visual browsing.
- Layout on demand: Moli adds layout, screenshots, and coordinate input only when the layout flag is enabled.
- Where Lightpanda wins: It may fit your workload better, so test both against real pages.
Moli on a VPS vs Railway (VPS Alternative)
- Setup effort: Railway deploys the token-gated endpoint from a template, while a VPS needs manual binary, proxy, and TLS setup.
- Operations: Railway manages the host, while a VPS gives you direct control over OS and network rules.
- Where a VPS wins: More hardware and networking control matters for sustained heavy use.
How to use Moli on Railway?
- Open the deployed service and copy the value of MOLI_CDP_URL. Treat it as a secret, since the token path in the URL grants access to the browser.
- Connect Playwright with
chromium.connectOverCDP(url), or pass the URL asbrowserURLin Puppeteer. - Expect a 404 if you open the bare host or
/json/versiondirectly. The token path is required. - Check health by requesting
/healthzon your domain. - You do not need to browse as a user or supply a model API key to get started.
import { chromium } from "playwright";
const browser = await chromium.connectOverCDP(process.env.MOLI_CDP_URL);
const context = browser.contexts()[0];
const page = context.pages()[0] ?? await context.newPage();
await page.goto("https://example.com");
console.log(await page.locator("body").innerText());
await browser.close();
How to self host Moli on other VPS Services (Moli self hosting guide)
Clone the Repository
Pull the Moli source at the v1.1.22 tag so your build matches the release this template uses.
git clone --branch v1.1.22 https://github.com/lexmount/moli.git
cd moli
Install Dependencies
Use the upstream release binary rather than building from source on a small VPS. Review the installer script before running it.
curl --proto '=https' --tlsv1.2 -fsSL \
https://github.com/lexmount/moli/releases/latest/download/moli-installer.sh | sh
Configure Environment Variables
Generate a long random token and keep it secret, since it guards the browser endpoint. Store it in your shell or a secrets manager, never in a committed file.
export MOLI_TOKEN="$(openssl rand -hex 32)"
Start the Moli Application
Upstream Moli binds to 127.0.0.1:9222 by default. Keep it on loopback, verify it is listening only on loopback, and add your own authenticated TLS reverse proxy before any public exposure. Never expose raw CDP publicly.
moli serve --layout --block-private-networks
Confirm the listener is loopback-only, for example with ss -ltn | grep 9222, before adding any public route.
Your own reverse proxy should terminate TLS, require authentication, and forward only to 127.0.0.1:9222. On Railway, the template's nginx wrapper and Railway's TLS handle this for you.
Official Pricing of Moli (Moli pricing)
Moli is open-source under Apache-2.0 OR MIT, so self-hosting costs nothing in license fees. This template requires no paid tier.
Moli hosted vs self hosted comparison (Pricing, features, costs, and more)
Moli is open-source and free to self-host, and this template does not include a paid hosted plan.
Monthly cost of self hosting Moli on Railway
Railway bills by usage, so cost depends on RAM, CPU, and other services you run. This template creates no volume. Check Railway's pricing page for current rates.
System Requirements for Hosting Moli on a VPS
Moli is a single Rust binary behind nginx with no separate database, so it runs on modest hardware. Benchmark your workload before committing.
Frequently Asked Questions (FAQs)
Where is the Moli endpoint?
Your Railway service exposes Moli on public port 8080, and the nginx gate forwards only requests under the token path. Clients connect to the full secret URL in the MOLI_CDP_URL variable.
Does the URL need the secret?
Yes. The token path is required, and a bare /json/version request returns a 404 from the nginx gate. Treat the full URL as a password and redact it from logs and screenshots.
Does Moli persist sessions between restarts?
No. With no volume, cookies and profile data are not kept across restarts or redeploys, so start each session fresh.
Can Moli reach private hosts?
No, by default. The server runs with --block-private-networks, so requests to private or loopback addresses are blocked. This is a deliberate guard against server-side request forgery.
Why are images missing from my pages?
Image and other optional resource families are not fetched by default. Add the --resource flag through MOLI_SERVE_ARGS to enable them, keeping in mind that the resource policy still applies to what is loaded.
Is Moli Chromium?
No. Compatibility and rendering behavior differ from Chromium, so test your target pages before relying on them.
Template Content

