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

无法访问React开发服务器:ERR_CONNECTION_REFUSED问题求助

React本地启动后浏览器无法连接,报错ERR_CONNECTION_REFUSED

我通过npm start在本地运行React应用,控制台显示服务启动编译成功,但Chrome、Firefox浏览器均无法连接,提示ERR_CONNECTION_REFUSED错误。

控制台输出如下:

Compiled successfully!

You can now view frontend in the browser.

Local: http://localhost:3000
On Your Network: http://192.168.0.12:3000

Note that the development build is not optimized.
To create a production build, use npm run build.

webpack compiled successfully

同时我在8000端口运行Django API服务器,通过setupProxy.js配置http-proxy-middleware做路由转发,代码如下:

import { createProxyMiddleware } from "http-proxy-middleware";

export default function (app) {
  app.use(
    "/api",
    createProxyMiddleware({
      target: "http://localhost:8000",
      changeOrigin: true,
    })
  );
}

已执行以下排查步骤:

  • 检查URL拼写无误
  • 确认React服务在3000端口、Django服务在8000端口正常运行
  • 系统防火墙未阻止端口连接
  • 重启过服务器和电脑
  • 用多个浏览器测试过连接
  • 浏览器控制台无报错信息
  • 通过lsof -i :3000确认3000端口无其他进程占用
  • /etc/hosts中localhost配置正确
  • 终端ping localhost响应正常
  • 换3001端口启动React服务,问题依旧
  • 尝试通过IP地址http://192.168.0.12:3000访问,还是无法连接

恳请帮忙解决该问题,谢谢!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.22 03:07:10