You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

RSelenium无法连接Docker Toolbox远程服务器问题求助

Fixing RSelenium Connection Refused Error with Docker Toolbox

Hey there! Let's work through that connection issue you're having with RSelenium and Docker Toolbox. The "connection refused" error usually boils down to a small mix-up with how Docker Toolbox handles network access—let's break it down step by step:

1. First, confirm your Selenium container is running

That long string you got after running docker run -d -p 4445:4444 selenium/standalone-firefox is your container ID, which means the container was created successfully. But we need to make sure it's actually up and running.

In your Docker Toolbox terminal, run this command:

docker ps

Look for a row with selenium/standalone-firefox in the IMAGE column. If the STATUS says Up X minutes, you're good here. If not, start the container with:

docker start e735076ce3ddcb183fe72...  # Use your full container ID here

2. Use the Docker Toolbox VM IP instead of localhost

Here's the key gotcha with Docker Toolbox: it runs Docker inside a VirtualBox virtual machine, not directly on your host OS. That means localhost in your R script points to your actual computer, not the VM where Docker is running.

To get the VM's IP address, run this in your Docker Toolbox terminal:

docker-machine ip default

You'll get an IP like 192.168.99.100—this is the address you need to use in your RSelenium setup.

3. Update your RSelenium code to use the VM IP

Modify your R script to point to the VM IP instead of localhost:

library(RSelenium)
# Replace "192.168.99.100" with the IP you got from docker-machine ip default
remDr <- remoteDriver(
  remoteServerAddr = "192.168.99.100",
  port = 4445L,
  browserName = "firefox"
)
remDr$open()

4. Double-check port mapping (just to be safe)

Your docker run command maps port 4445 on the VM to port 4444 in the container, which is correct since Selenium listens on 4444 by default. As long as you're using port 4445 in your RSelenium setup, this part should work.

Give these steps a try, and you should be able to connect to the remote server without issues!

内容的提问来源于stack exchange,提问作者mjoudy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:55:50