'R: Selenium server signals port = 4567 is already in use
It seems this is a recurrent question, but I haven't found the solution to my problem.
I am running the following:
link <- 'https://www.google.com/'
rD <- rsDriver(verbose = TRUE,
port=4567L,
browserName = 'chrome',
chromever = '83.0.4103.39',
check = TRUE)
remDr <- rD$client
remDr$navigate(link)
When I run the first I get the error:
Error in wdman::selenium(port = port, verbose = verbose, version = version, : Selenium server signals port = 4567 is already in use.
I have the chrome driver in the same folder as of my R project.
How do I make this work? I have literally followed the documentation and nothing seems to work!!!
Any help would be much appreciated!
Br
Solution 1:[1]
I had this issue recently, I just assigned a random portal number i.e. port= 4837L and then reran the code and it worked fine for me. Hope it works!
Solution 2:[2]
You got two options to kill processes
## Option 1
system("taskkill /im java.exe /f", intern=FALSE, ignore.stdout=FALSE)
## Option 2
system(paste0("Taskkill /F /T" ," /PID ", pid = rD$server$process$get_pid()))
These are validated in Windows. Somebody please check and review these for OSx/Unix/Linux.
Solution 3:[3]
I found that this worked well for me so that you don't have to keep reassigning random port numbers...
library(netstat)
rD <- rsDriver(verbose = TRUE,
port= free_port(),
browserName = 'chrome',
chromever = '83.0.4103.39',
check = TRUE)
Solution 4:[4]
I know this is an old question. But i think the answers here do no solve the root cause of the issue. Therefore for other readers here is my answer.
Add the following command at the end of your code, to stop the server and release to port 4567.
rD[["server"]]$stop()
Solution 5:[5]
Doing all three of the below should cover most cases:
remDr$close()
rm(rD)
gc()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ERC |
| Solution 2 | ishonest |
| Solution 3 | |
| Solution 4 | BerndGit |
| Solution 5 | dca |
