Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guess what app is already running in port 3000 #441

Closed
vjeux opened this issue Aug 14, 2016 · 11 comments
Closed

Guess what app is already running in port 3000 #441

vjeux opened this issue Aug 14, 2016 · 11 comments

Comments

@vjeux
Copy link
Contributor

vjeux commented Aug 14, 2016

https://twitter.com/somebody32/status/764805492505997312

Would be nice to go one step further and give the name of the process that is using port 3000. Otherwise the next step is going to be to google how to figure out what is running on a port, which is a bit annoying and we can solve for the user :)

@gaearon
Copy link
Contributor

gaearon commented Aug 14, 2016

Oh, that would be really cool 👍

@vjeux
Copy link
Contributor Author

vjeux commented Aug 14, 2016

On MacOS, you can do

  1. Get the PID of the process that listens on port 3000
> lsof -P | grep TCP | grep :3000
node      36663 vjeux   22u    IPv6 0x3c581a030a2b0e47        0t0     TCP *:3000 (LISTEN)
  1. Get the command that started it
> ps -o command -p 36663
COMMAND
node /Users/vjeux/random/test/node_modules/react-scripts/scripts/start.js

I'm not going to implement it, so if anybody feels like it, please grab this task, should be a good first task and pretty impactful :)

@millerm
Copy link

millerm commented Aug 14, 2016

Looking for a first task to try. Would it be alright if I gave it a shot? @vjeux

@vjeux
Copy link
Contributor Author

vjeux commented Aug 14, 2016

@millerm absolutely, go for it!

@lacker
Copy link
Contributor

lacker commented Aug 16, 2016

I'm guessing in most cases it is another copy of a create-react-app app.

@chhuang
Copy link

chhuang commented Aug 16, 2016

Rails' default port is on 3000 too.

@clessg
Copy link

clessg commented Aug 22, 2016

This command runs much faster for me:

lsof -i -n -P | grep TCP | grep :3000

The -i option restricts output to opened network connections rather than all open files. -n shows IP addresses, if applicable, rather than host names. Both of these options result in much faster execution.

@clessg
Copy link

clessg commented Aug 22, 2016

By the way, to get the raw process number, you can use the -t option:

lsof -i:3000 -P -t

So:

ps -o command -p "$(lsof -i:3000 -P -t)"

(In this case the -n option is not needed for performance, I believe.)

@fleischie
Copy link

losf is no standard command in every Linux distro (not on mine anyways). ss should be installed though. (Tested on fairly updated Arch, Debian and Ubuntu Distros.)

@talkingtab
Copy link

Getting process information may be OS specific. An alternative way to solve this problem is to document the process of specifying a port. For example changing package.json to:
"startport": "PORT=4444 npm run start",
"start": "react-scripts start",
Will start the webpack dev server on port 4444

@ianmcnally
Copy link
Contributor

#816 was just merged, so I believe this can be closed now.

@fson fson added this to the 0.8.0 milestone Nov 23, 2016
@fson fson closed this as completed Nov 23, 2016
@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants