How can I determine which localhost port is running? - macos

I just find out that when I simply type 'localhost' in the url without anything more in the path, the browser displays a message from a local backend test project in Express that I've made days ago.
I'm trying to stop this process.
I was sure that to have started this server on port 3001 but when I try to kill it , it says that there is no process running on this port.
I tried to kill 8080 as well, but the message is still displayed.
Obviously, I refreshed the page, I tried on several different browser, even restarted my computer.
How can i determine which port is running?
How can I stop the process?
[Edit]:
Here's what I keep receiving :
<html><head></head><body><h1>It works!</h1>
</body></html>

You could use lsof:
lsof -i #localhost

Can you try this command :
sudo lsof -nP -i4TCP:80

Related

Netstat failed to show result

I am trying to run an application on port 8080 but I received a message that says "Web server failed to start. Port 8080 was already in use." I tried to access localhost:8080 on my browser and it says "unable to connect". I searched on how to handle this problem and it was to kill whatever activity is going on in port 8080. It didn't work. I tried the command netstat -a -n -o | find "8080" and netstat -ano | findstr :, but it didn't produce any results. I even tried to run as administrator but it still wouldn't show any results. According to the solutions that I found, I expect to find something along the lines of TCP and LISTENING. I accessed localhost:8080 a couple of days back and it was fine. Can anyone tell me what went wrong?
picture attached
The only recent changes I made was to enable VMX on my laptop a few days ago. Other than that, I did not change nor configure any settings whatsoever.
Simply running "netstat -ab" will display all ports taken. Try to run it and see which process is using port 8080. It always lists all ports taken.

Cannot create Solr core on localhost - ERROR: Connection reset

I'm running Solr 8.2 on OSX 10.13.5. The Solr dashboard is accessible in my browser (via http://localhost:8983), yet when I run the terminal command "bin/solr create -c test" to create a core, after a few moments I end up with:
ERROR: Connection reset
I've tried booting Solr as sudo, and the result is the same. I'm at a bit of a loss here. How can I resolve this connection error and create a core? Thanks!
I figured this out. It turns out that port 8983 was still in TIME_WAIT mode. I obtained the port's PID with:
sudo lsof -i :8983
Then closed the port with:
kill PID
Where 'PID' is the numerical PID of the port. With the port now being free of traffic, the core creation worked just fine. I'm leaving this posted in case any other Solr beginners hit this snag!

Cannot kill local Jenkins on port 8080

I have a local instance of Jenkins running on port 8080 on my mac machine. I want to kill this process and have tried doing so, like below :
lsof -i tcp:8080
kill -9 <the pid>
This closes my chrome instance. But when I open Chrome again and go to localhost:8080, Jenkins is still running over there. Any ideas as to why these commands don't kill it? Also how to kill the process?
Thanks
Try using the below :
Try to identify the Jenkins instance/process id , like something below:
ps -ef| grep jenkins
Go to the server (like apache) where your Jenkins is installed and kill the process id like below :
$ kill -9 1001(processId)
lost -i tcp:8080 will also list processes that connect to port 8080, e.g. chrome. What happens if you repeat above commands after you've quit chrome? Then hopefully Jenkins should be the only process working on port 8080.
If you installed Jenkins via the OSX Installer you'll need to follow these instructions to edit the plist file via the command line (manually doing it is a pain).
When you've made necessary changes, such as running
sudo defaults write /Library/Preferences/org.jenkins-ci httpPort [YOUR DESIRED PORT HERE]
you'll need to 'unload' Jenkins:
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist.
And now Jenkins is dead. To undead Jenkins just swap load for unload in the above command.

Port localhost:3000 does not respond

I use Windows and I ran the .msi.
localhost:3000 does not respond. I activated and rested iis and cannot see anything under 3000. How can I check if the port is active and if anybody s listening? I tried lsof -i in cmd and I get the error "lsof unrecognized batch file"
Also, when I run meteor from the directory with the example or dummy, I do not have anything else following like
..running, port localhost:3000 active
It doesn't look like the command 'meteor' does anything on my machine.
Do I need to put my meteor folder inside the installation one (i.e. C:/Program Files(x86)/meteor)
Since this question was posted, Meteor has gotten an official Windows installer. See if it works now.

cannot start sinatra process - eventmachine "no acceptor"

I have a Sinatra app that I run as a daemon, using Apache port-forwarding to mediate between port 80 and port 7655. This has been working fine in the past. Today, not so well. I cannot figure out why.
Problem: sudo ruby my_process.rb returns:
/var/lib/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:526:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)
Tried: updating all system packages, updating all gems. No help (except for the more clear error message from eventmachine).
When I run sudo lsof -i :7655 I get nothing back. When I run sudo ps aux I don't see any Ruby processes at all. Which I find highly irregular, given the nature of the error message!
So is there something I'm missing in finding out why the port is unavailable?
Also:
Tried changing ports, nothing. I wonder if it is related to "localhost"? When I ping localhost I get all dropped packets. That doesn't seem normal.
Turns out these two lines in the main Sinatra script provided the most information:
set bind: "localhost"
set port: 7655
The problem was with localhost. The loopback interface was not properly configured. ifconfig showed the lo interface, but it hadn't been assigned the IP 127.0.0.1. To resolve, ran the following commands in the shell (on an Ubuntu Linux system):
ifdown lo
ifup lo
When you close term sometime you forget to stop [CTRL+C] the actual server, just run the following command to kill all ruby process like sinatra, and run-it again
killall ruby
You can see your actual ruby process by running
ps -ef | grep ruby

Resources