Selenium Server is a powerful tool for browser automation and testing. Running it in a FreeBSD jail provides isolation and security while maintaining easy management. This guide walks through setting up Selenium Server with Firefox and Geckodriver in a classic FreeBSD jail.
With a Selenium Server running in a jail, you can, run automated browser tests in isolation, integrate with CI/CD pipelines, configure grid mode for parallel testing, or use it with AI and MCP servers for browser and workflow automation.
Requirements
- Tested on FreeBSD 15.0-RELEASE
- A working jail setup (see the Creating a Classic Jail on FreeBSD guide)
- X virtual framebuffer (Xvfb) for headless browser operation
Create the Jail
Follow the standard jail creation process as outlined in the jail creation article, but with additional configuration for Selenium's requirements.
I will use "selenium" as the name for the jail. Set the jail name variable (if you are following the steps from the article):
NAME=seleniumAfter creating the jail using the standard process, you'll need to add these specific jail configuration options for Selenium.
- sysvshm/sysvsem/sysvmsg - Provide System V IPC resources needed by Firefox and the X server
- allow.mount.* - Enable mounting of procfs and fdescfs filesystems
- mount.procfs/fdescfs - Automatically mount these filesystems when the jail starts
Edit the jail configuration file:
JAIL_CONFIGS=/etc/jail.conf.d
cat << EOF >>${JAIL_CONFIGS}/${NAME}.conf
selenium {
sysvshm = new;
sysvsem = new;
sysvmsg = new;
allow.mount;
allow.mount.fdescfs;
allow.mount.procfs;
mount.procfs;
mount.fdescfs;
}
EOFInstall Required Packages and Configure
Install Selenium Server:
pkg -j selenium install -y www/seleniumIn order to use Selenium you need a browser and a 'webdriver' to control the browser. We'll use Firefox and the corresponding Geckodriver:
pkg -j selenium install -y www/firefox www/geckodriverThe final piece is an X virtual framebuffer along with required fonts and utilities:
pkg -j selenium install -y x11-servers/xorg-server@xvfb x11-fonts/xorg-fonts x11-fonts/webfonts x11/xauth x11/xkeyboard-config x11/xkbcompThere is an issue with the FreeBSD version of Selenium. It has trouble finding the web driver automatically. We'll need to manually point Selenium to use the Geckodriver for Firefox automation:
sysrc -j selenium selenium_java_opts="-Dwebdriver.gecko.driver=/usr/local/bin/geckodriver"Start and Manage Selenium
Enable the Selenium service to start automatically:
service -j selenium selenium enableStart the Selenium service:
service -j selenium selenium startCheck the service status:
service -j selenium selenium statusStop the service when needed:
service -j selenium selenium stopVerify Installation and Troubleshooting
By default, Selenium Server runs on port 4444. You can verify it's listening using "sockstat":
sockstat -4ln | grep 4444You should see output similar to:
selenium java 12345 123 tcp4 *:4444 *:*If you encounter issues, check the Selenium log file inside the jail:
jexec selenium tail -f /var/log/selenium.logCommon issues and solutions:
- Firefox fails to start - Ensure procfs and fdescfs are mounted correctly
- Display errors - Verify Xvfb is installed and the DISPLAY environment variable is set
- Permission errors - Check that the selenium user has proper permissions
- Port already in use - Ensure no other service is using port 4444
Connecting to Selenium
Once running, you can connect to Selenium Server from your test scripts using the IP address or hostname of your system on port 4444:
http://selenium.local.tld:4444Replace "selenium.local.tld" with your actual jail hostname or IP address.
- Log in to post comments

.png)