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

如何解决从Windows无法连接VMware中Ubuntu Server的Django Web服务器问题?

Fixing Django Access from Windows to Ubuntu VM

Hey there! Let's troubleshoot this together—since you can SSH into your Ubuntu Server VM, we already know the basic network connection works. Here are the most likely fixes to get your Django app accessible from Windows:

1. Make Django Listen on All Network Interfaces

By default, when you run python manage.py runserver 127.0.0.1:8080, Django only binds to the localhost interface (127.0.0.1), which means it's only accessible from within the Ubuntu VM itself.

To let external devices (like your Windows machine) connect, start the server with this command instead:

python manage.py runserver 0.0.0.0:8080

The 0.0.0.0 tells Django to listen on all available network interfaces of the VM, including the bridged IP (192.168.1.7).

2. Open Port 8080 on Ubuntu's Firewall

Ubuntu servers often use ufw (Uncomplicated Firewall) by default, which might block incoming traffic on port 8080.

  • First, check the current firewall status:
    sudo ufw status
    
  • If you don't see a rule allowing 8080/tcp, add it:
    sudo ufw allow 8080/tcp
    
  • Reload the firewall to apply changes:
    sudo ufw reload
    

3. Verify VM Network Configuration

Double-check that your VMware bridge is set up correctly:

  • In VMware, go to your VM's Settings > Network Adapter and confirm it's set to Bridged Mode, with the checkbox for "Replicate physical network connection state" enabled.
  • On the Ubuntu VM, run ip a to confirm the IP address is still 192.168.1.7 and that it's on the same subnet as your Windows machine (check Windows IP with ipconfig in Command Prompt).

4. Test Connectivity from Windows

Once the above steps are done, test from your Windows machine:

  • Ping the VM to confirm basic connectivity:
    ping 192.168.1.7
    
  • Test the Django port directly with curl (if you have it installed) or telnet:
    curl http://192.168.1.7:8080
    
    or
    telnet 192.168.1.7 8080
    

If curl returns the HTML of your Django app or telnet connects successfully, you're good to go—just open that URL in your Windows browser!

5. Check Windows Firewall (Last Resort)

If all else fails, make sure Windows Firewall isn't blocking outgoing traffic to port 8080. You can temporarily disable it for testing, or add an outgoing rule allowing connections to 192.168.1.7:8080.

Most of the time, the first two steps (changing Django's listen address and opening the firewall port) will fix the issue. Give them a try and let me know if you run into any hiccups!

内容的提问来源于stack exchange,提问作者Khanh Quoc Nguyen

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 09:53:20