大网数据广告活动
服务器运维问答

VirtualBox and Windows 10: can't connect to a server hosted on VirtualBox

· 52CE 我爱测

Not a duplicate - I searched a lot and tried to use suggestions from many articles, including answers to this question: VirtualBox: How to set up networking so both host and guest can access internet and talk to each other and th…

问题原文

原帖链接 · user64675 · CC BY-SA 3.0

Not a duplicate - I searched a lot and tried to use suggestions from many articles, including answers to this question: VirtualBox: How to set up networking so both host and guest can access internet and talk to each other and this article. But in the end I get "ERR_CONNECTION_TIMED_OUT".

I have Windows 10, latest VirtualBox with CentOS 7 on it. I installed nginx and configured server to listen to port 8080, server name localhost. I want to connect to the nginx server from host (windows).

I tried NAT, Bridged network, Host-only e.t.c. Same result. Tried to set up static IP on CentOS. Tried to allow all input/output network requests from/to IPs: 192.168.56.1 (according to VirtualBox, this is host local IP) and 192.168.56.110 in Windows Firewall.

I can ping/check with curl that my nginx server is working fine. So this is not the case.

社区高分解答

原帖链接 · Xcat · CC BY-SA 4.0

Assuming you are trying to access the VM from Win10.

  1. Configure network Right-click the VM icon in the Oracle VM VirtualBox Manager window which you want to access from the host and click settings on the menu. Go to the Network tab and set up the VM network to NAT Network.

  2. Configure forwarding Click File->Preferences on the Oracle VM VirtualBox Manager window, and then click the Network tab. You will see a network listed(if not, just click the Add icon to add one), click the network name and then click the edit icon.

On the NAT Networks Details windows, click the Port Forwarding.

Click Add icon to add a port forwarding rule, like

and then click OK OK OK to save the rule. Please note, the Guest IP is your CentOS VM IP.

  1. Set up VM. Now back to your CentOS VM, set the ipv4.method to auto(since you've changed the default IP configuration before) and then restart the network service.
  2. Add firewall rule. You should add a rule for port 8080 by

    firewall-cmd --add-port=8080/tcp --permanent

Then you may access port 8080 on VM form you Win 10 host.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-04-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。