Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
If Selenium’s Firefox session hangs or fails when run as an unprivileged user, first check whether Firefox and geckodriver can both read and write the temporary profile directory. This is a documented startup problem with container-packaged Firefox, including Ubuntu’s default Snap Firefox on Ubuntu 22.04 and later. Point geckodriver at a shared, user-writable profile root—or set a process-specific TMPDIR—before changing permissions or granting extra privileges. The exact cause depends on your Firefox packaging, driver path, and runtime environment.
Why an unprivileged Firefox WebDriver session can fail
geckodriver creates a temporary Firefox profile for a WebDriver session. That profile is separate from your everyday Firefox profile: even if your usual profile is readable, the temporary directory geckodriver creates or uses can still be inaccessible. Selenium may also create a temporary directory when it creates a new profile or copies a profile you supplied.
Firefox and geckodriver both need read-write access to the temporary profile location. Container-packaged browsers such as Snap or Flatpak can see a different filesystem from the host. If Firefox cannot see or use the profile geckodriver created, startup may hang. Mozilla documents this issue for the default Firefox shipped with Ubuntu 22.04 and later; that does not mean every Ubuntu installation or every unprivileged-user failure has this cause. Mozilla’s geckodriver usage documentation describes the container-filesystem case.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
geckodriver is the WebDriver HTTP endpoint Selenium talks to, and it proxies commands to Firefox’s remote protocol. A startup failure can therefore involve the driver executable, browser executable, profile path, or the boundary between their environments—not simply the account’s general permissions. Mozilla’s geckodriver overview explains its role.
#1 Best Overall
Diagnose the browser, driver, and profile paths first
-
Identify how Firefox is installed
Check whether Firefox is installed as Snap, Flatpak, or a regular package. On Ubuntu, the default Firefox may be the Snap build. Its filesystem view can differ from the host’s, which makes the location geckodriver chooses for a temporary profile especially important.
-
Confirm which geckodriver Selenium starts
On Linux, geckodriver looks for Firefox on
PATHby default, and its binary option can select another executable. Check the geckodriver path in your environment and Selenium configuration. For Ubuntu’s default Snap Firefox, Mozilla documents/snap/bin/geckodriveras the compatible driver location. A different driver executable may be appropriate for a different Firefox installation. -
Check the Firefox executable path
If you set Selenium’s
binary_location, make sure it points to the browser executable, not a launcher that is unsuitable for the driver. For Ubuntu’s Snap Firefox, Mozilla specifies/snap/firefox/current/usr/lib/firefox/firefox. It explicitly notes that/snap/bin/firefoxis not the Firefox executable for this purpose. See Mozilla’s usage guidance.Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallSpecial offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Check the temporary profile’s location and access
geckodriver uses
/tmpby default on Unix. Determine which directory it is actually using from logs, then ask whether both Firefox and geckodriver can reach and write to that location. A readable original Firefox profile does not prove that the temporary profile or a Selenium-created copy is accessible.
Fix the profile path without broadening privileges
Option 1: Set geckodriver’s profile root
Use geckodriver’s --profile-root option to choose a directory that both Firefox and geckodriver can read and write. Choose a location available to the browser in its packaging context; a host path that a containerized Firefox cannot see will not solve the mismatch. The directory should be writable by the unprivileged account running the test.
For example, create a private directory owned by the test user and launch geckodriver with that directory as the profile root:
mkdir -p "$HOME/.cache/selenium-firefox-profiles"
geckodriver --profile-root "$HOME/.cache/selenium-firefox-profiles"
Then configure Selenium to use the geckodriver process you launched, or pass the same option through your geckodriver service configuration. Do not assume that this host path is visible inside Snap or Flatpak: verify that Firefox can access it. Mozilla states that both programs need read-write access to the selected profile root. The geckodriver flags documentation describes --profile-root.
Option 2: Set TMPDIR only for geckodriver
On Unix, setting TMPDIR for the geckodriver process changes the temporary directory used by it. This is useful when you want a per-run or per-service setting rather than changing a system-wide temporary directory. For example:
mkdir -p "$HOME/.cache/selenium-tmp"
TMPDIR="$HOME/.cache/selenium-tmp" geckodriver
Or, if Selenium starts the service, set the environment variable in that service’s process environment. Ensure the resulting path is accessible to Firefox too; changing where geckodriver writes profiles will not help if the browser’s container cannot see the chosen directory. Mozilla says TMPDIR needs to be set only in geckodriver’s environment. See Mozilla’s profile documentation.
Option 3: Run the driver in the browser’s container context
If you must keep a container-packaged Firefox, use a geckodriver setup that runs in the same container filesystem context as Firefox. This addresses the visibility boundary directly. The details depend on the package and how your system launches it; follow the packaging’s supported method rather than assuming a host path will be visible inside the browser environment. Mozilla lists running geckodriver inside the same container filesystem as one remedy for the documented issue.
Option 4: Use a non-container Firefox build
If changing the package is acceptable, Mozilla lists using a regular Firefox release together with a geckodriver release as a workaround for container-filesystem problems. This avoids that particular container boundary, but changes how Firefox is installed and updated. Use a browser and driver combination supported by your Selenium version and deployment.
Free tools Windows power users keep installed
One-click scans. No signup required.
Configure Selenium and collect useful logs
Turn on geckodriver diagnostics before changing permissions. Use --log debug or -v for debug output, and -vv for trace output. Selenium’s Firefox service can direct driver logs to a file, making it easier to inspect the executable and profile paths associated with a failed session. Mozilla’s flags reference documents the logging options; Selenium’s Firefox documentation covers Firefox service configuration and profile handling.
Example using Python Selenium 4:
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
service = Service(
executable_path="/snap/bin/geckodriver",
service_args=["--log", "debug"],
log_output="geckodriver.log",
)
options = webdriver.FirefoxOptions()
options.binary_location = "/snap/firefox/current/usr/lib/firefox/firefox"
driver = webdriver.Firefox(service=service, options=options)
try:
driver.get("https://example.com")
print(driver.title)
finally:
driver.quit()
Use those Snap paths only when they match your Ubuntu Firefox installation. If you use a different package or browser binary, select the corresponding executable and driver instead. For Selenium 4, Selenium’s Firefox page states a minimum Firefox version of 78; confirm current compatibility on that page because supported versions can change.
To apply a per-process TMPDIR when Selenium launches geckodriver, pass an environment mapping to its service:
import os
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
profile_tmp = os.path.expanduser("~/.cache/selenium-tmp")
os.makedirs(profile_tmp, exist_ok=True)
service_env = os.environ.copy()
service_env["TMPDIR"] = profile_tmp
service = Service(
executable_path="/snap/bin/geckodriver",
service_args=["--log", "debug"],
log_output="geckodriver.log",
env=service_env,
)
options = webdriver.FirefoxOptions()
options.binary_location = "/snap/firefox/current/usr/lib/firefox/firefox"
driver = webdriver.Firefox(service=service, options=options)
try:
driver.get("https://example.com")
finally:
driver.quit()
Confirm that the TMPDIR path is visible and writable to Firefox in its package environment before relying on it. For a Selenium version whose service constructor differs, check its installed API documentation rather than copying an incompatible argument list.
Choose the remedy that fits your deployment
| Approach | Best fit | Trade-off or check |
|---|---|---|
Shared profile root or process-specific TMPDIR |
Keep the existing Firefox package and choose a location both processes can access. | Verify the browser can see the path; a host directory may not cross a container boundary. |
| Driver in the same container context | Keep container-packaged Firefox and align the driver with its filesystem. | Requires a supported way to launch the driver in that context. |
| Regular Firefox build and matching geckodriver | Avoid the container-filesystem boundary. | Changes installation and update management. |
Troubleshoot common symptoms
-
Firefox startup hangs, especially with Ubuntu Snap Firefox
Check whether Firefox can access the temporary profile geckodriver created. Confirm the geckodriver and Firefox executable paths, then set a shared profile root or process-specific temporary directory. The Snap/container explanation is documented for Ubuntu 22.04 and later, but other causes remain possible.
-
“Permission denied” or profile creation fails
Inspect ownership and permissions on the selected profile root and its parent directories. Make the location writable by the unprivileged account and accessible within Firefox’s filesystem context. Avoid granting everyone write access as a shortcut.
-
The configured Firefox path does not launch
Verify that
binary_locationpoints to the actual browser executable. For Ubuntu Snap Firefox, Mozilla documents/snap/firefox/current/usr/lib/firefox/firefox, not/snap/bin/firefox. Also verify that Selenium is starting the intended geckodriver. -
The original profile is accessible, but the session still fails
Selenium or geckodriver may be creating a temporary profile or copying the supplied profile to another temporary location. Inspect the driver log for the generated profile path and correct access there, rather than changing the original profile alone.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
The failure persists after changing TMPDIR
Confirm that the variable reached the geckodriver process, that the directory exists, and that Firefox can see and write to it. Alternatively, configure
--profile-rootexplicitly and inspect debug or trace logs for the path actually used.
Do not use broad privileges as a profile-path fix
Running Selenium as root or applying chmod 777 does not address a filesystem visibility mismatch and can create unnecessary security exposure. First identify the package, executable, and temporary profile paths, then grant only the test account the access it needs.
--allow-system-access is not a general-purpose permissions switch. Mozilla says it is required for browser UI testing starting with Firefox 138, and warns that it gives WebDriver clients privileges equivalent to the Firefox UI process. Enable it only when that UI-testing use case requires it; it is not the routine fix for web-content automation or profile access. See Mozilla’s flag documentation.
Or skip the browser setup
If your goal is simply to capture a website screenshot, an API can avoid maintaining a local Firefox/geckodriver setup. ScreenshotNeo is a website screenshot API and MCP server from ScreenshotNeo. One GET request returns an image or PDF. Example cURL request:
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchescurl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for authentication and request options. Cookie banners, newsletter popups, and chat widgets are removed before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. Its MCP server lets AI agents use screenshot tools, and the free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for 1,000 free screenshots a month with no card.
Frequently Asked Questions
Does every unprivileged-user WebDriver failure come from Snap or Flatpak?
No. The documented container-profile issue is one known cause; driver selection, executable paths, or other environment-specific problems can also prevent startup.
Can I use ScreenshotNeo with an AI agent?
Yes. ScreenshotNeo provides an MCP server with the tools take_screenshot, get_page_info, and capture_pdf.
Quick Recap
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.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →

