October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
browser automation

How to Run Ubuntu in Headless Mode for Browser Automation

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can run browser automation on Ubuntu without installing or opening a desktop environment: administer the Ubuntu host over SSH, install an automation framework and its browser dependencies, then run the browser in headless mode. These are two separate choices—Ubuntu can be headless while a browser is launched with a visible window, and a headless browser can also run on a machine that has a desktop.

The commands below cover Playwright and Puppeteer on Ubuntu Server. Exact dependencies and browser behavior vary with the Ubuntu release, framework version, browser build, and whether you use a physical board, virtual machine, or cloud host. Check the documentation for the versions you install before relying on a command in a production image.

What “headless” means for Ubuntu browser automation

A headless Ubuntu host has no local desktop session required for administration. You connect remotely, typically with SSH. Separately, a headless browser runs without displaying a browser window. Removing Ubuntu’s desktop does not itself install a browser, make browser automation work, or decide which browser mode your tests use.

For a server workflow, the usual setup is Ubuntu Server plus SSH, a project using Playwright or Puppeteer, and the compatible browser build and operating-system libraries. You can still choose a headed browser for debugging if you provide a display server or another display mechanism; the ordinary headless workflow does not need one.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prepare an Ubuntu host and connect over SSH

Choose an Ubuntu Server release supported for your environment, and confirm its lifecycle and package availability before building a long-lived image. Ubuntu’s documentation index lists Server guides for 26.04 LTS, 24.04 LTS, and 22.04 LTS; that listing is not a recommendation that every release fits every deployment.

Plan network access before first boot

For a physical board, virtual machine, or cloud instance, establish how it will reach the network and how you will discover its address. Depending on the environment, that may mean a static address, checking the router or provider’s console, or using mDNS/Avahi on a local network. With mDNS, a host may be reachable by a name ending in .local, if the network and host are configured for it.

Use SSH keys for unattended administration

Set up a named user and install that user’s public SSH key using the provisioning method for your host. Then connect using its known address or hostname:

ssh your-user@ubuntu-host-or-address

Canonical’s headless-board setup says password-based SSH is disabled by default there and strongly recommends leaving it disabled. The exact initial account and key setup depends on how you provisioned Ubuntu, so do not assume a board-specific setup applies unchanged to a cloud VM or another Ubuntu installation. Keep SSH access limited to the users and networks that need it.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install Playwright and its browser dependencies

Playwright’s installation command can install Chromium and the Linux dependencies it lists for the current Playwright release. Run it from your project directory after adding Playwright as a project dependency:

npm install --save-dev playwright
npx playwright install --with-deps chromium

The first command adds the framework to the project; the second installs the browser and attempts to install its required system packages. Package installation may require administrative privileges or an environment where the package manager can run. Review the command’s output and your Ubuntu release’s package behavior rather than assuming the same system changes are appropriate in every container or managed host.

Choose the Playwright Chromium build intentionally

  • Regular Playwright headless: Playwright’s standard Chromium path uses a separate Chromium headless shell. Use this when it matches the browser implementation you intend to automate.
  • Headless shell only: If you only need the shell, Playwright documents --only-shell as an install option, avoiding installation of the full browser.
  • Newer Chrome headless mode: Playwright documents selecting the chromium channel to use the newer Chrome headless implementation. Its installation guidance also describes --no-shell when you do not need the separate shell.
  • Branded Chrome or Edge: Playwright does not install branded Chrome or Edge by default. These may be appropriate when your goal is regression testing against a public browser or behavior such as particular codecs. Chromium can be ahead of branded Stable releases, so choose based on the target your users actually run.

Browser channels and command-line options are versioned. Consult the Playwright browser documentation for the installed release and record the framework and browser versions used by your CI environment.

Install Puppeteer and its browser

The puppeteer package normally downloads a compatible Chrome for Testing build and chrome-headless-shell. Install it in the project with:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
npm install --save-dev puppeteer

The default browser cache location is $HOME/.cache/puppeteer. Some package managers or configurations block dependency install scripts, so the browser download may not run when the package is installed. In that case, install the browser explicitly:

npx puppeteer browsers install

Alternatively, configure your package manager to allow the relevant install script. Puppeteer’s puppeteer-core package does not download Chrome; use it when you manage the browser separately or connect to a remote browser. That means you must supply a compatible browser and its dependencies yourself.

For version-specific download and setup details, consult the Puppeteer installation guide. Pin or record framework and browser versions if repeatable CI behavior matters; browser downloads and Linux requirements can change between releases.

Run a small headless browser check

Once the framework and browser are installed, run a minimal script from the project to verify that the browser launches and can load a page. This Playwright example opens a URL, prints its title, and closes the browser:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch({ headless: true });
  const page = await browser.newPage();
  await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
  console.log(await page.title());
  await browser.close();
})();

Save it as check.js and run node check.js. A successful run prints the page title and exits. If it fails before navigation, investigate browser installation, library resolution, sandboxing, and the selected browser mode before changing page-wait settings.

Choose the browser implementation that matches the test

“Headless Chromium” is not one interchangeable target. Playwright’s regular headless path uses its separate shell; its chromium channel selects the newer Chrome headless mode. Puppeteer also distinguishes its default headless mode from headless: 'shell' and headed mode. Test against the implementation you mean to support, rather than assuming success with one proves behavior in another.

Chrome’s old headless-shell functionality is no longer part of the Chrome binary beginning with Chrome 132, according to the Chromium project documentation; the old --headless=old behavior has no effect there. If you specifically depend on that older implementation, use the standalone headless-shell binary and confirm the current guidance for the browser version in question. See Chrome’s headless documentation and the framework’s browser-mode documentation.

Troubleshoot launch failures

Browser executable missing

  • Likely cause: The framework’s browser download did not run, or the cache is not present for the user executing the script.
  • Fix: For Puppeteer, run npx puppeteer browsers install and check the cache under the same account that launches the process. For Playwright, rerun the documented browser install command for the project’s installed version.

Shared library or shared-object error

  • Likely cause: A browser library required by that Ubuntu release and browser build is missing.
  • Fix: Inspect the browser executable’s unresolved libraries. Puppeteer documents ldd chrome as a diagnostic; run it against the actual browser binary when needed. Then install the missing packages appropriate to your Ubuntu release and browser build. Puppeteer’s troubleshooting guide covers common Debian/Ubuntu requirements related to NSS, GBM, GTK, fonts, X11, and Pango, but there is no single package list established for every version combination.

Browser exits or fails around sandboxing

Do not reflexively add --no-sandbox. Puppeteer says running without a sandbox is strongly discouraged and recommends configuring a sandbox instead. Treat disabling it as an exceptional choice only when the content is absolutely trusted and the security implications are understood. Check the current framework and host guidance for how to provide the required sandbox in your deployment.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Downloaded Chrome for Testing cannot use user namespaces

Puppeteer documents an Ubuntu AppArmor interaction: on Ubuntu 23.10 and later, an AppArmor profile applied to Chrome stable binaries may prevent downloaded Chrome for Testing binaries from using user namespaces. If the failure matches this case, follow Puppeteer’s current troubleshooting instructions for the specific Ubuntu release and browser, rather than applying a generic workaround. See Puppeteer troubleshooting.

Automation works locally but differs in CI

  • Compare the framework version, browser build or channel, and operating-system libraries between environments.
  • Confirm the process runs as the expected user and can access the installed browser cache.
  • Make sure the CI image has the dependencies installed for the browser version it actually launches.
  • Check whether the target is a headless shell, newer Chrome headless, or branded Chrome/Edge; changing modes can change the browser under test.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and reproducibility

There is no universal Ubuntu package list or browser configuration for all hosts. A physical board, container, VM, and cloud instance can differ in provisioning, permissions, network access, and available system libraries. Keep the install process aligned with the actual deployment image and framework version.

  • Make builds repeatable: Pin framework dependencies and record which browser installation command and browser channel your CI image uses.
  • Separate setup from launch: Install browsers and system dependencies during image or environment preparation, not implicitly in every test run.
  • Diagnose the layer that failed: Distinguish SSH/network access problems from package installation, browser launch, and page-navigation failures.
  • Prefer the least security-sensitive fix: Preserve the Chromium sandbox where possible and avoid broad security workarounds for a library or permission problem.

Or skip the browser setup

If you need a website screenshot rather than a locally controlled browser session, ScreenshotNeo is a screenshot API and MCP server for developers. A single GET request returns an image or PDF. Its API accepts the URL and can return PNG, JPEG, or WebP:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for parameters and response details. ScreenshotNeo accepts cookie or consent banners as a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies page verdict and billing status in headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The Free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing gives two months free, and every feature is available on every plan. Sign up for 1,000 free screenshots a month, with no card required.

Frequently Asked Questions

Does headless Ubuntu require a desktop environment?

No. SSH is sufficient for administering a server, and a headless browser does not need a visible browser window.

Should I use Playwright or Puppeteer?

Choose the framework that fits your project and the browser implementation you need to test. Both support headless automation; their browser installation and mode details differ.

Can I use Puppeteer without its downloaded Chrome?

Yes. Use puppeteer-core when the browser is managed separately or remote; it does not download Chrome for you.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.