Home > database >  Error: cannot open display: :0 geckodriver selenium
Error: cannot open display: :0 geckodriver selenium

Time:06-17

I'm trying to run a flask application that when the user inputs a link it runs a selenium script with that link and then returns some info. I'm in the process of trying to deploy it right now but running into some issues with setting up the X server. This was working fine a couple days ago not sure why it stopped working. When entering a url selenium runs into an error and the geckodriverlog file says this:

1655398364982   geckodriver INFO    Listening on 127.0.0.1:60701
1655398365537   mozrunner::runner   INFO    Running command: "/usr/bin/firefox" "--marionette" "--remote-debugging-port" "57429" "--remote-allow-hosts" "localhost" "-no-remote" "-profile" "/tmp/rust_mozprofileqf4HKQ"
No protocol specified
Unable to init server: Could not connect: Connection refused
Error: cannot open display: :0

I tried the solution in this post which tells me to run the server through a virtual frame buffer but doing that didn't seem to help at all. I also tried the solution in this post but writing the whole ip for my display variable gives me the same error with also a new error:

1655398078139   geckodriver INFO    Listening on 127.0.0.1:60065
1655398078684   mozrunner::runner   INFO    Running command: "/usr/bin/firefox" "--marionette" "--remote-debugging-port" "48811" "--remote-allow-hosts" "localhost" "-no-remote" "-profile" "/tmp/rust_mozprofilelQkVrP"
Unable to init server: Broadway display type not supported: (my_servers_ip):0
Error: cannot open display: (my_servers_ip):0

command used: /home/dummy/project/venv/bin/gunicorn --chdir /home/dummy/project -w 9 main:app

CodePudding user response:

I think the frame buffer should be the right method, the problem maybe the command you use. Try the following command:

xvfb-run -d -s '-screen 0 1920x1080x24' /home/dummy/project/venv/bin/gunicorn --chdir /home/dummy/project -w 9 main:app  # remove -d option or use -a option instead
  • Related