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

VS Code Live Server始终使用公网IP,如何切换至localhost本地启动?

解决Live Server强制用公网IP启动的问题

你的配置里存在关键冲突项:"liveServer.settings.useLocalIp": true,这个设置会强制Live Server使用本地IP(部分环境下会被识别为公网IPv4地址),直接覆盖了host: "localhost"的配置。按以下步骤修改即可:

  • 打开VS Code的settings.json配置文件,将"liveServer.settings.useLocalIp": true改为"liveServer.settings.useLocalIp": false
  • 确保"liveServer.settings.host": "localhost"的配置保留且正确
  • 保存配置后,重启VS Code或者通过命令面板(Ctrl+Shift+P)执行Reload Window重载窗口
  • 再次启动Live Server,此时应该会以http://localhost:端口号/index.html的形式打开页面

如果修改后仍有问题,可以尝试:

  • 检查Live Server扩展是否为最新版本,更新到最新版再试
  • 暂时关闭系统防火墙或代理工具,排除外部干扰
// 修改后的核心配置片段
{
  "liveServer.settings.useLocalIp": false,
  "liveServer.settings.host": "localhost"
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.20 18:28:00