8

I have tried to run my project on my localhost but it is saying Something is already running on your port 3000.

enter image description here

Penny Liu
  • 15,447
  • 5
  • 79
  • 98
vijay kumar.G
  • 101
  • 1
  • 1
  • 3
  • [Maybe this could help?](https://stackoverflow.com/questions/3855127/find-and-kill-process-locking-port-3000-on-mac) – Tholle Nov 05 '18 at 11:10

10 Answers10

22

You can run this Command npx kill-port 3000 . This command keeps empty your 3000 port

Munni
  • 731
  • 5
  • 20
7

If your os is windows some processes (mostly hyper-v) may cause this problem by reserving some port ranges

you can see your reserved port ranges with this command

netsh interface ipv4 show excludedportrange protocol=tcp

If you see port 3000 is included in the list of reserved ranges you can solve the problem by excluding port 3000

command for excluding port 3000:

net stop winnat
netsh int ipv4 add excludedportrange tcp startport=3000 numberofports=1 store=persistent
net start winnat

then you may need to restart your PC

  • This is a 10/10 response, I searched everywhere for what was going on with my environment and only this worked. It clearly showed that port 3000 was reserved and this fixed it. Definitely to do with hyper-v since I use workstation player occasionally. Thank you! – Jlove Sep 10 '22 at 16:58
  • Agreed, freshly booted up Windows and the port was reportedly in use where it worked fine yesterday. Some GPO must have got pushed down that reserved these ports and this resolved my issue as well. Thanks! – DSN Sep 28 '22 at 22:42
6

I know this is late , but if anyone faces the same issue might want to try this

sudo kill -9 $(sudo lsof -t -i:9001)

where, 9001 is your port number.

0xAnon
  • 847
  • 9
  • 20
3

You can either stop all your tasks running under Nodejs environment to make sure nothing is allocated on PORT 3000, or you can just modify the scripts part of package.json from:

"start": "react-scripts start"

to

"start": "PORT=3006 react-scripts start"

then run "npm start" on a new terminal session.

P.S. The second approach would be a bit of an overkill.

Sabbir Ahmed
  • 1,468
  • 2
  • 16
  • 21
1

If you're using Linux, you can run the following commands on your console:

fuser -n tcp 3000

The command above will return the task ID of the program that is currently using the port. Then you will have to run

kill -9 [#task]

with the task ID. (Just replace all the '[#task]' by the task ID returned)

Zoe
  • 27,060
  • 21
  • 118
  • 148
Felipe Toledo
  • 599
  • 1
  • 10
  • 16
1

Use the command below:

You can run this Command npx kill-port 3000 . This command keeps empty your 3000 port

psmni@SuperManReturns MINGW64 /d/FSD/React/airbnb_psm (main) $ npm start

airbnb_psm@0.1.0 start react-scripts start

Something is already running on port 3000.

psmni@SuperManReturns MINGW64 /d/FSD/React/airbnb_psm (main) $ npx kill-port 3000 npm WARN exec The following package was not found and will be installed: kill-port Process on port 3000 killed

psmni@SuperManReturns MINGW64 /d/FSD/React/airbnb_psm (main) $ npm start

airbnb_psm@0.1.0 start react-scripts start

(node:10464) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: 'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option. (Use node --trace-deprecation ... to show where the warning was created) (node:10464) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option. Starting the development server...

Compiled successfully!

You can now view airbnb_psm in the browser.

0

Launch Task Manager, find all the programs/tasks that are related Nodejs and stop them.

Brian Le
  • 2,646
  • 18
  • 28
0

You could just restart your IDE. That appears to work 99% of the time. No libraries, no secret cammand-line tricks.

Christian
  • 51
  • 7
-3

 

On React - you can run an already created React single-page application (SPA) by

npm start command.

That may start your locally hosting development server and runs your app at:

http://localhost:3000/ which is equivalent to: 127.0.0.1:3000 address

127.0.0.1 is the default localhost IP number while the default port number set by

create-react-app package is 3000.

When getting: “Something is already running on port 3000" failure error message you may think that the port captured by another process running on your machine but you’ll find that it is captured permanently as if it runs on 0.0.0.0:3000 address

Solution:

In your project libraries created by create-react-app script navigate to:

node_modules/react-scripts/scripts/start.js

While running npm start command - the start.js script is being called and executed

There at start.js file in you editor find the above line:

const HOST = process.env.HOST || '0.0.0.0';

 and change it to:

const HOST = process.env.HOST || '127.0.0.1';

 

save and run your web app again at: http://localhost:3000/ or http://127.0.0.1:3000

 

 

 

-4

After all the googled advices failed to solve the problem of why already working project started failing:

First running: npm install

then running: npm start worked for me.

Jérôme
  • 1,254
  • 2
  • 20
  • 25