npm start reports “Something is already running on port XXX” no matter what XXX is

六月ゝ 毕业季﹏ 提交于 2019-12-24 15:16:06

问题


I am trying to npm start my web app's frontend, and npm start gives me following:

Something is already running on port 3000.

I tried lsof -i :3000 and nothing's running on 3000. I tried modifying package.json to change to another port to start my app, but it still says Something is already running on port XXX no matter what that port is, 3000, 30006, or anything. If I point my browser to localhost:XXX it will just say ERR_CONNECTION_REFUSED because nothing's running there.

I'm pretty sure it's not the code's problem because the app can be started on another machine. Anyway, really desperate for suggestions here. I pasted my package.json as follows:

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "axios": "^0.18.0",
    "node-sass": "^4.10.0",
    "react": "^16.5.0",
    "react-dom": "^16.5.0",
    "react-scripts": "1.1.5"
  },
  "scripts": {
    "start": "PORT=30006 react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "proxy": "http://localhost:3001",
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

回答1:


Thanks for all the comments, actually this answer helps https://stackoverflow.com/a/49520791/7203672.

I literally tried all methods to kill the process or find the process or reinstall the dependecies but it just never occurred to me that this is a problem with my /etc/hosts. And the problem is I have 126.0.0.1 localhost instead of 127.0.0.1, I probably made a typo some days back, I have no idea.

Lessons learned, should've tried every answer under that post before posting the question.



来源:https://stackoverflow.com/questions/55328752/npm-start-reports-something-is-already-running-on-port-xxx-no-matter-what-xxx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!