something listen in 8080 port but not appear with any network related command

Hi,

I was trying to boot up a vagrant machine but fails saying that port 8080 was used by other application, so I try to identify that applicaction to close it with:


enric@makalu:~$ sudo lsof -n -i4TCP:8080

enric@makalu:~$


or with netstat:


enric@makalu:~$ netstat -nlatp tcp | grep LISTEN

tcp4 0 0 127.0.0.1.2222 *.* LISTEN

tcp4 0 0 10.95.140.100.62871 *.* LISTEN

tcp4 0 0 *.57621 *.* LISTEN

tcp4 0 0 127.0.0.1.4380 *.* LISTEN

tcp4 0 0 127.0.0.1.4370 *.* LISTEN

tcp4 0 0 127.0.0.1.4371 *.* LISTEN

tcp4 0 0 127.0.0.1.4381 *.* LISTEN

tcp6 0 0 ::1.5001 *.* LISTEN

....


but nothing appears, but if I check with nmap:

enric@makalu:~$ nmap localhost -p 8080

Starting Nmap 6.47 ( http://nmap.org ) at 2015-06-03 15:38 CEST

Nmap scan report for localhost (127.0.0.1)

Host is up (0.00018s latency).

PORT STATE SERVICE

8080/tcp open http-proxy

Nmap done: 1 IP address (1 host up) scanned in 0.05 seconds


Or vía telnet:

enric@makalu:~$ telnet localhost 8080

Trying ::1...

Connected to localhost.

Escape character is '^]'.

get / http/1.1

Connection closed by foreign host.


Any suggestion about how can I identify the process that is using the port?


Cheers

Kike

MacBook Pro, OS X Yosemite (10.10.3)

Posted on Jun 3, 2015 6:46 AM

Reply
10 replies

Jun 3, 2015 7:44 AM in response to enricMac

1. This procedure is a diagnostic test. It changes nothing, for better or worse, and therefore will not, in itself, solve the problem. But with the aid of the test results, the solution may take a few minutes, instead of hours or days.

The test works on OS X 10.7 ("Lion") and later. I don't recommend running it on older versions of OS X. It will do no harm, but it won't do much good either.

Don't be put off by the complexity of these instructions. The process is much less complicated than the description. You do harder tasks with the computer all the time.

2. If you don't already have a current backup, back up all data before doing anything else. The backup is necessary on general principle, not because of anything in the test procedure. Backup is always a must, and when you're having any kind of trouble with the computer, you may be at higher than usual risk of losing data, whether you follow these instructions or not.

There are ways to back up a computer that isn't fully functional. Ask if you need guidance.

3. Below are instructions to run a UNIX shell script, a type of program. As I wrote above, it changes nothing. It doesn't send or receive any data on the network. All it does is to generate a human-readable report on the state of the computer. That report goes nowhere unless you choose to share it. If you prefer, you can act on it yourself without disclosing the contents to me or anyone else.

You should be wondering whether you can believe me, and whether it's safe to run a program at the behest of a stranger. In general, no, it's not safe and I don't encourage it.

In this case, however, there are a couple of ways for you to decide whether the program is safe without having to trust me. First, you can read it. Unlike an application that you download and click to run, it's transparent, so anyone with the necessary skill can verify what it does.

You may not be able to understand the script yourself. But variations of it have been posted on this website thousands of times over a period of years. The site is hosted by Apple, which does not allow it to be used to distribute harmful software. Any one of the millions of registered users could have read the script and raised the alarm if it was harmful. Then I would not be here now and you would not be reading this message. See, for example, this discussion.

Another indication that the test is safe can be found in this thread, and this one, for example, where the comment in which I suggested it was recommended by one of the Apple Community Specialists, as explained here.

Nevertheless, if you can't satisfy yourself that these instructions are safe, don't follow them. Ask for other options.

4. Here's a general summary of what you need to do, if you choose to proceed:

☞ Copy a particular line of text to the Clipboard.

☞ Paste into the window of another application.

☞ Wait for the test to run. It usually takes a few minutes.

☞ Paste the results, which will have been copied automatically, back into a reply on this page.

These are not specific instructions; just an overview. The details are in parts 7 and 8 of this comment. The sequence is: copy, paste, wait, paste again. You don't need to copy a second time.

5. Try to test under conditions that reproduce the problem, as far as possible. For example, if the computer is sometimes, but not always, slow, run the test during a slowdown.

You may have started up in safe mode. If the system is now in safe mode and works well enough in normal mode to run the test, restart as usual. If you can only test in safe mode, do that.

6. If you have more than one user, and the one affected by the problem is not an administrator, then please run the test twice: once while logged in as the affected user, and once as an administrator. The results may be different. The user that is created automatically on a new computer when you start it for the first time is an administrator. If you can't log in as an administrator, test as the affected user. Most personal Macs have only one user, and in that case this section doesn’t apply. Don't log in as root.

7. Load this linked web page (on the website "Pastebin.") The title of the page is "Diagnostic Test." Below the title is a text box headed by three small icons. The one on the right represents a clipboard. Click that icon to select the text, then copy it to the Clipboard on your computer by pressing the key combination command-C.

If the text doesn't highlight when you click the icon, select it by triple-clicking anywhere inside the box. Don't select the whole page, just the text in the box.

8. Launch the built-in Terminal application in any of the following ways:

☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)

☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.

☞ Open LaunchPad and start typing the name.

Click anywhere in the Terminal window to activate it. Paste from the Clipboard into the window by pressing command-V, then press return. The text you pasted should vanish immediately.

9. If you see an error message in the Terminal window such as "Syntax error" or "Event not found," enter

exec bash

and press return. Then paste the script again.

10. If you're logged in as an administrator, you'll be prompted for your login password. Nothing will be displayed when you type it. You will not see the usual dots in place of typed characters. Make sure caps lock is off. Type carefully and then press return. You may get a one-time warning to be careful. If you make three failed attempts to enter the password, the test will run anyway, but it will produce less information. If you don't know the password, or if you prefer not to enter it, just press return three times at the password prompt. Again, the script will still run.

If you're not logged in as an administrator, you won't be prompted for a password. The test will still run. It just won't do anything that requires administrator privileges.

11. The test may take a few minutes to run, depending on how many files you have and the speed of the computer. A computer that's abnormally slow may take longer to run the test. While it's running, a series of lines will appear in the Terminal window like this:

[Process started]

Part 1 of 8 done at … sec

Part 8 of 8 done at … sec

The test results are on the Clipboard.

Please close this window.

[Process completed]

The intervals between parts won't be exactly equal, but they give a rough indication of progress. The total number of parts may be different from what's shown here.

Wait for the final message "Process completed" to appear. If you don't see it within about ten minutes, the test probably won't complete in a reasonable time. In that case, press the key combination control-C or command-period to stop it and go to the next step. You'll have incomplete results, but still something.

12. When the test is complete, or if you stopped it because it was taking too long, quit Terminal. The results will have been copied to the Clipboard automatically. They are not shown in the Terminal window. Please don't copy anything from there. All you have to do is start a reply to this comment and then paste by pressing command-V again.

At the top of the results, there will be a line that begins with the words "Start time." If you don't see that, but instead see a mass of gibberish, you didn't wait for the "Process completed" message to appear in the Terminal window. Please wait for it and try again.

If any private information, such as your name or email address, appears in the results, anonymize it before posting. Usually that won't be necessary.

13. When you post the results, you might see an error message on the web page: "You have included content in your post that is not permitted," or "The message contains invalid characters." That's a bug in the forum software. Please post the test results on Pastebin, then post a link here to the page you created.

14. This is a public forum, and others may give you advice based on the results of the test. They speak for themselves, not for me. The test itself is harmless, but whatever else you're told to do may not be. For others who choose to run it, I don't recommend that you post the test results on this website unless I asked you to.

______________________________________________________________

Copyright © 2014, 2015 by Linc Davis. As the sole author of this work (including the referenced "Diagnostic Test"), I reserve all rights to it except as provided in the Use Agreement for the Apple Support Communities website ("ASC"). Readers of ASC may copy it for their own personal use. Neither the whole nor any part may be redistributed.

Jun 3, 2015 7:48 AM in response to enricMac

Hello enricMac,

You can try running netstat with sudo too. It sounds like this is launchd listening on that port as a proxy. When there is activity, it will fire up whatever software is defined in whatever launchd config file that has defined this entry. Since you are running Vagrant, you might try checking for an old install of Tomcat or something.

Jun 3, 2015 8:04 AM in response to etresoft

Hi etresoft,

same result with sudo:


enric@makalu:~$ sudo netstat -anlp tcp | grep 8080

enric@makalu:~$


nothing appears using 8080 port.


To test it I search for SSH port too:


enric@makalu:~$ sudo netstat -anlp tcp | grep LISTEN | grep 22

tcp4 0 0 127.0.0.1.2222 *.* LISTEN

tcp4 0 0 *.22 *.* LISTEN

tcp6 0 0 *.22 *.* LISTEN


2222 is a vagrant machine.


enric@makalu:~$ sudo lsof -n -i4TCP:8080

enric@makalu:~$ sudo lsof -n -i4TCP:22

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

launchd 1 root 39u IPv4 0x120129169decbad1 0t0 TCP *:ssh (LISTEN)

launchd 1 root 42u IPv4 0x120129169decbad1 0t0 TCP *:ssh (LISTEN)


And as you can see, it works as expected with SSH port.


Cheers

Kike

Jun 3, 2015 9:21 AM in response to enricMac

Thousands of users of this site have run variations of that script without a single report of harm done, as you can verify, but as I wrote earlier, if you don't think it's safe you shouldn't run it. Apparently some third-party software that you installed is binding port 8080, but it's not clear why the lsof output doesn't show it. If you don't know and can't guess what that software is, you will have to erase the startup volume, reinstall OS X, and restore only user files from a backup. Then reinstall all third-party software one step at a time, taking care to test after each step to make sure you haven't restored the problem.

Jun 3, 2015 10:26 AM in response to enricMac

Hello again enricMac,

Can you clarify where you get the message "port 8080 was used by other application"? Is it possible that this is some service running under Vagrant itself? Depending on how your network is configured, that service could show up as an allocated port on the Mac side. Was Vagrant running when you ran nmap on the Mac?

Jun 3, 2015 10:35 AM in response to enricMac

enricMac wrote:


Hi Linc Davis,

about your response......isn't it better a git repository to keep your code? and a script with correct indent will be more understandable (and confiable) that what you have on that pastebin page. Of course I'm not going to run that script on my machine, and my advise to any other is not running it at all.


Cheers

Kike

Hello again enricMac,

Linc's script is safe to run. It just prints out various configuration files and maybe log messages. Apple Support Communities is pretty heavily moderated by Apple employees. If there were anything malicious, it would have been spotted a long time ago. It could be helpful. I would suggest running it. However, it is designed to be obfuscated and to be interpreted by Linc alone. There's a story there. 🙂

Jun 3, 2015 11:26 PM in response to etresoft

Hi etresoft,

the message about the port shows up when I try to launch a vagrant machine with a Vagrantfile using that port:


enric@makalu:~/media/src/opengvp_puppet (develop u=)$ vagrant up

Bringing machine 'opengvp_with_provisioning' up with 'virtualbox' provider...

==> opengvp_with_provisioning: Importing base box 'opengvp'...

==> opengvp_with_provisioning: Matching MAC address for NAT networking...

==> opengvp_with_provisioning: Setting the name of the VM: opengvp_puppet_opengvp_with_provisioning_1433398780425_65490

==> opengvp_with_provisioning: Clearing any previously set forwarded ports...

Vagrant cannot forward the specified ports on this VM, since they

would collide with some other application that is already listening

on these ports. The forwarded port to 8080 is already in use

on the host machine.



To fix this, modify your current projects Vagrantfile to use another

port. Example, where '1234' would be replaced by a unique host port:



config.vm.network :forwarded_port, guest: 8080, host: 1234



Sometimes, Vagrant will attempt to auto-correct this for you. In this

case, Vagrant was unable to. This is usually because the guest machine

is in a state which doesn't allow modifying port forwarding.


No other vagrant machine was up when I run this command or when I run nmap last time.


About Linc script, I prefer not to run it, as I said if it was a nicely indented script that can be interpreted that's OK for me, obfuscated code..not in my machine.


Cheers

Kike

Jun 4, 2015 6:57 AM in response to enricMac

Hello again enricMac,

I'm glad you got it sorted out. It's not cool of Cisco to grab a popular port like that. I'm still curious about why it wouldn't show up and how to identify which ports launchd has allocated like this. OS X is really starting to diverge from other *NIX variants and some people would like to know more about what is going on underneath. It is very difficult to get Apple to help. In Yosemite they ported launchd from iOS and really radically changed how processes and VM are managed by the OS. Apple won't say anything about these changes to anyone. I've even tried to use my Developer Technical Support requests, but Apple just says no and credits them back to my account.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

something listen in 8080 port but not appear with any network related command

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.