Maybe a stupid question with an obvious answer, but I don't know the solution. I'm new with the command line and especially Apple and iTerm2.
In iTerm2 I open a new session for my PHP project with php -S localhost:port
Now I accidentally closed this tab once and now I don't know how to terminate that session.
When I want to open another project on that port (8000
) it says, ofcourse, Failed to listen on 127.0.0.1:8000 (reason: Address already in use)
Can someone help me on how to terminate this session, so I can start another project on this port instead of using 8001, 8002, 8003 etc.
Thanks in advance
1 Answer. Show activity on this post. There is the option to save a log of your session to a file, however, by default this isn't done. To activate the session logs, go to iTerm2 Preferences (⌘,), select the "Profiles" tab, then the "Session" tab.
iTerm2 allows you to divide a tab into many rectangular "panes", each of which is a different terminal session. The shortcuts cmd-d and cmd-shift-d divide an existing session vertically or horizontally, respectively. You can navigate among split panes with cmd-opt-arrow or cmd-[ and cmd-].
If Preferences>General>Save copy/paste history and command history to disk is enabled, then command history will be preserved across runs of iTerm2 (up to 200 commands per user/hostname).
The primary use of the mouse in iTerm2 is to select text, and (by default) text is copied to the clipboard immediately upon being selected. You can click and drag to perform a normal selection. Double-clicking selects a whole word. Triple-clicking selects an entire line.
I fixed it myself, but since I can't be the only one wondering this, here is my solution:
Enter this into the terminal:
lsof -i TCP:8000
It will yield a result that might look something like this:
renaebair@siren ~/workspace/intridea/newsite (master)
→ lsof -i TCP:3000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ruby 68780 renaebair 6u IPv4 0x10898278 0t0 TCP *:hbci (LISTEN)
Grab the process number (a.k.a. PID) (in this case it was 68780) and then type “kill #{that_pid}”
:
kill 68780
Then try restarting your server and all should be well!
I think that this might work, at least in my unix machine it does.
sudo kill $(fuser -n tcp 8000 2> /dev/null)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With