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

MrMooky's avatar

EACCES error on production server

I'm using Browsershot by Spatie to generate PDF files for certain views in a Laravel app. It works fine on my local machine, but only sometimes on my production server (Ubuntu 20, PHP 8).

I'm using Horizon to generate the PDF files. Sometimes, it works directly on the first try, but most of the time the job fails with the below error. When I re-try the job, the file is generated without errors. Not sure how to fix this.

Error Output:
================
glob error [Error: EACCES: permission denied, scandir '/root/.npm/_logs'] {
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/root/.npm/_logs'
}
TimeoutError: Navigation timeout of 30000 ms exceeded
    at /usr/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/LifecycleWatcher.js:106:111
 at /home/..../releases/20210629110947/vendor/spatie/browsershot/src/Browsershot.php:797)

It's obviously a permission issue, but I'm not sure how to fix it, as it works fine the second time. Anybody got an idea?

0 likes
2 replies
MrMooky's avatar

I actually just installed it as described here and have not much knowledge about server stuff. :/

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget libgbm-dev
sudo npm install --global --unsafe-perm puppeteer
sudo chmod -R o+rx /usr/lib/node_modules/puppeteer/.local-chromium

Please or to participate in this conversation.