Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

anuzpandey's avatar

Failed to Launch Browser Process and Permissions Problem

Description:

I'm encountering an issue with the Browsershot package in my Laravel application while generating PDFs in a queue worker using Supervisor. The application works fine in my local environment but throws an error in my production setup on Ubuntu 22. I have tried various solutions, but I'm unable to resolve the issue.

Problem 1: Failed to Launch Browser Process:

When the queue worker tries to use Browsershot, it throws the following error:

Error: Failed to launch the browser process!
cmd_run.go:1046: WARNING: cannot create user data directory: cannot create snap home dir: mkdir /var/www/snap: permission denied
/system.slice/supervisor.service is not a snap cgroup

Problem 2: Permissions Issue:

After changing the user in Supervisor's configuration to www-data, I started encountering permission-related issues. For instance, Browsershot requires the www-data user to create directories and files for generating PDFs, but I'm unsure about the correct way to grant these permissions without compromising security.

What I've Tried:

  • Adjusted ownership and permissions using chown and chmod for relevant directories.
  • Confirmed that the www-data user has proper ownership for Laravel files and directories.
  • Verified that Supervisor is configured to use the www-data user.
  • Ensured that the system's temporary directory has appropriate permissions for the www-data user.

Environment:

  • Laravel version: 10
  • Browsershot version: 2.58
  • Ubuntu version: Ubuntu 22
  • Web server: Nginx
  • Puppeteer: 17.1.3

Supervisor Config:

[program:your_queue]
process_name=%(program_name)s_%(process_num)02d
command=php /path/to/your/project/artisan queue:work --tries=3
autostart=true
autorestart=true
user=www-data
numprocs=4
redirect_stderr=true
stdout_logfile=/var/log/your_queue.log

Question:

  1. How can I resolve the "Failed to launch the browser process" error that is occurring in my production environment?
  2. What is the correct and secure way to grant the www-data user permissions to create directories and files for Browsershot PDF generation?

I would greatly appreciate any guidance or insights into resolving these issues. Thank you in advance for your help!

0 likes
4 replies
markokaup's avatar

Facing same problem. Did you figure this out?

lex_ivashchenko's avatar

I had time with this issue yesterday. Tried different approaches but only had success with one.

Environment: PHP 8.3 Laravel 11 Ubuntu 24.04 LTS NGINX Node (v18.19.1) (latest for today) Spatie/Browsershot (Puppeteer, Chrome 128.0.6613.119)

I tried to use the latest versions despite Spatie wanting me to install outdated Node/Puppeteer versions.

Steps to make it work:

  1. Create a real www-data user with /home/www-data directory.
  2. Install Laravel into /home/www-data/laravel directory.
  3. Install Puppeteer globally.
  4. Ask Puppeteer to install Chrome browser.
  5. Use Puppeteer Chrome browser to generate PDF.

Detailed instructions: https://stackoverflow.com/a/78956369/3163536

1 like

Please or to participate in this conversation.