Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR Error starting Chrome browser. Error: EACCES: permission denied, open '/tmp/flaresolverr.txt' #120

Closed
jstraten opened this issue May 6, 2021 · 7 comments
Labels
bug Something isn't working
Milestone

Comments

@jstraten
Copy link

jstraten commented May 6, 2021

Environment
FlareSolverr Version: 1.2.5

Docker: No

OS: Ubuntu 20.04

Are you using a proxy or VPN? No

Using Captcha Solver: Yes

If using captcha solver, which one: hcaptcha-solver

Description

  • Installed FlareSolverr at /opt/flaresolverr
  • Created flaresolverr user with adduser -system -group flaresolverr
  • Added my_user with adduser <my_user> flaresolverr
  • Ran chown -R flaresolverr:flaresolverr /opt/flaresolverr
  • Created flaresolverr.service as shown below:
[Unit]
Description=Flaresolverr Daemon
After=network.target

[Service]
User=flaresolverr
Group=flaresolverr

Environment="CAPTCHA_SOLVER=hcaptcha-solver"

Type=simple
WorkingDirectory=/opt/flaresolverr
ExecStart=/opt/flaresolverr/flaresolverr

TimeoutStopSec=30
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

Problem
The service doesn't start and so I am trying to get FlareSolverr to run manually. This gives me the following output:

2021-05-06T18:05:15.507Z INFO FlareSolverr v1.2.5
2021-05-06T18:05:15.508Z DEBUG Debug log enabled
2021-05-06T18:05:15.508Z DEBUG Testing Chrome installation...
2021-05-06T18:05:15.509Z ERROR Error starting Chrome browser. Error: EACCES: permission denied, open '/tmp/flaresolverr.txt'
    at Object.openSync (fs.js:461:3)
    at Object.fs.openSync (pkg/prelude/bootstrap.js:487:32)
    at Object.writeFileSync (fs.js:1387:35)
    at testChromeInstallation (/snapshot/FlareSolverr/dist/index.js:41:8)
    at Object.<anonymous> (/snapshot/FlareSolverr/dist/index.js:110:1)
    at Module._compile (pkg/prelude/bootstrap.js:1320:22)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1218:10)
    at Module.load (internal/modules/cjs/loader.js:1047:32)
    at Function.Module._load (internal/modules/cjs/loader.js:935:14)
    at Function.Module.runMain (pkg/prelude/bootstrap.js:1375:12) {
  errno: -13,
  syscall: 'open',
  code: 'EACCES',
  path: '/tmp/flaresolverr.txt'
}

I have checked the /tmp directory and it has a file named flaresolverr.txt.

Maybe I am missing a dependency? However, the output doesn't give me any clue what it might be.

@Elegary
Copy link

Elegary commented May 10, 2021

I got the same problem, it was a file already existing in /tmp/flaresolverr.txt
I just edited the output file in src/index.ts with changing const filePath = path.join(os.tmpdir(), 'flaresolverr.txt') into const filePath = path.join(os.tmpdir(), 'flaresolverr-1.txt') (line 42)

Then, recompile with npm run build

@jstraten
Copy link
Author

jstraten commented May 12, 2021

@Elegary Thnak you for getting back to me! Oddly enough the problem went away with a reboot for me, but I also found the flareresolverr.txt file to be gone as well after the reboot.

After solving some puppeteer dependencies, I am now able to run flaresolverr from the command line. However, I still cannot run it at a service as shown above.

When I run journalctl -u flaresolverr, I am getting the following output:

May 06 17:27:54 user systemd[1]: Started Flaresolverr Daemon.
May 06 17:27:54 user flaresolverr[33469]: 2021-05-06T17:27:54.542Z INFO FlareSolverr v1.2.5
May 06 17:27:54 user flaresolverr[33469]: 2021-05-06T17:27:54.568Z ERROR Error starting Chrome browser. Error: Failed to launch the browser process!
May 06 17:27:54 user flaresolverr[33469]: /opt/flaresolverr/chrome/chrome: error while loading shared libraries: libX11-xcb.so.1: cannot open shared object file: No such file or directory
May 06 17:27:54 user flaresolverr[33469]: TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md
May 06 17:27:54 user flaresolverr[33469]:     at onClose (/snapshot/FlareSolverr/node_modules/puppeteer/lib/launcher/BrowserRunner.js:159:20)
May 06 17:27:54 user flaresolverr[33469]:     at Interface.<anonymous> (/snapshot/FlareSolverr/node_modules/puppeteer/lib/launcher/BrowserRunner.js:149:65)
May 06 17:27:54 user flaresolverr[33469]:     at Interface.emit (events.js:327:22)
May 06 17:27:54 user flaresolverr[33469]:     at Interface.close (readline.js:424:8)
May 06 17:27:54 user flaresolverr[33469]:     at Socket.onend (readline.js:202:10)
May 06 17:27:54 user flaresolverr[33469]:     at Socket.emit (events.js:327:22)
May 06 17:27:54 user flaresolverr[33469]:     at endReadableNT (_stream_readable.js:1224:12)
May 06 17:27:54 user flaresolverr[33469]:     at processTicksAndRejections (internal/process/task_queues.js:84:21)
May 06 17:27:54 user systemd[1]: flaresolverr.service: Main process exited, code=exited, status=1/FAILURE
May 06 17:27:54 user systemd[1]: flaresolverr.service: Failed with result 'exit-code'.
May 06 17:27:54 user systemd[1]: flaresolverr.service: Scheduled restart job, restart counter is at 2.
May 06 17:27:54 user systemd[1]: Stopped Flaresolverr Daemon.

I am taking a wild guess here, but I believe the service is not looking to find Chrome as a subdirectory of flaresolverr.

My environment is headless and I have already followed the available dependency guides for puppeteer.

Any help is appreciated!

@jstraten
Copy link
Author

I did some more research and found that the service doesn't start because it doesn't understand the environment variable in service file.
Environment="CAPTCHA_SOLVER=hcaptcha-solver"
Is this no longer valid or am I using the wrong format?

@LeoShivas
Copy link

Maybe you've done the same mistake of mine. Before I can launch FlareSolverr by systemd (with a dedicated user named "flaresolverr"), I launched it with my current user ("root" by example).

So, the first time the /tmp/flaresolverr.txt was created, it got the root:root permissions. So, the Error: EACCES: permission denied, open '/tmp/flaresolverr.txt' error message was normal and explicit.

By attributing the correct ownership, I successfully started flaresolverr.

Here is my /etc/systemd/system/flaresolverr.service file :

[Unit]
Description=FlareSolverr Daemon
After=network.target

[Service]
SyslogIdentifier=flaresolverr
Restart=always
RestartSec=5
Type=simple
User=flaresolverr
Group=flaresolverr
WorkingDirectory=/opt/flaresolverr/current
ExecStart=/opt/flaresolverr/current/flaresolverr
TimeoutStopSec=30

[Install]
WantedBy=multi-user.target

Pretty similar as yours, no ? :-)

@ngosang
Copy link
Member

ngosang commented May 30, 2021

FlareSolverr v1.2.6 released.

@rhayy
Copy link

rhayy commented Sep 9, 2022

I have got the same issue on Ubuntu.
I solved it by adding the depencies listed here depending on your distribution.

@rhayy
Copy link

rhayy commented Sep 9, 2022

My flaresolverr.service looks like this:

[Unit]
Description=FlareSolverr Daemon
After=syslog.target network.target prowlarr.service
Requires=prowlarr.service

[Service]
Type=simple
User=flaresolverr
Group=flaresolverr
ExecStart=/opt/flaresolverr/flaresolverr
TimeoutStopSec=20
KillMode=process
Restart=on-failure
Environment="HOST=127.0.0.1

[Install]
WantedBy=multi-user.target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants