Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My VPN client sometimes can't bind to the UDP port (500) it uses. It seems to leave behind a "bind" to port 500 on a previous run, even though it has quit.

The port is reported as "already in use" (Mac os X), but doesn't have an associated process:

$ sudo netstat -na | grep "udp.*\.500\>"

udp4       0      0     *.*                               
udp4       0      0     *.*                               

But sudo lsof doesn't show a process on port 500 (ie sudo lsof -i:500 -P reports nothing).

I can successfully use the VPN client after rebooting the machine, but am hoping for a less disruptive way to clear the state.

share|improve this question

migrated from Nov 12 '12 at 20:40

This question came from our site for professional and enthusiast programmers.

Port 500 is isakmp, used by IPsec VPNs.

Look in /sbin/ifconfig for any virtual network interfaces that might be configured to use that.

share|improve this answer
There is no virtual network interface in ifconfig or in the "System Pref / Networking" screen. I do use a VPN client called IPSecuritas, but it doesn't register itself as a virtual interface. I believe it's badly behaved in some circumstances, but I can't figure out how to clean up after it. – Chocohound Nov 12 '12 at 16:50
Also, if what you were saying is the issue, wouldn't there be a process listed by lsof? – Chocohound Nov 12 '12 at 16:52
@Chocohound if it's implemented in the kernel then there needn't be a process. – Alnitak Nov 12 '12 at 16:53
Alnitak, good point. But the issue still remains -- there is no virtual network interface listed... – Chocohound Nov 12 '12 at 17:39

Another useful command on OS X will help you make sure there is no process set for a particular UDP or TCP port:

lsof -Pan -i tcp -i udp
share|improve this answer

Try using netstat -nap to determine which program has the port open. I don't have an OSX system to test on, but on Linux, kernel ports show - as the program.

EDIT: A quick search for OSX ipsec disable indicates that OSX may have IPSEC enabled by default. If so, you would need to disable it to free the port.

share|improve this answer
-p flag doesn't exist on Mac. In general netstat can't show PIDs on mac, so you can't tell whether the kernel or some other process has / had the port. The only difference between lines in "netstat -na" is that the "state" field is blank (but I think that's true of all the UDP ports). – Chocohound Nov 12 '12 at 22:39
@Chocohound UPD is stateles, so I would expect it to be blank for UDP. I've updated my answer. Is there a reason you are using an assigned port in your code? – BillThor Nov 12 '12 at 23:14
Sorry, disregard "my code" - it was just a test client to confirm the issue for me. My problem is that I have a VPN client (IPsecuritas) which usually works, but sometimes fails to clean itself up on quitting. I can't figure out how to deallocate it. And if I try to start the VPN client again it fails with an "address already in use". – Chocohound Nov 13 '12 at 0:04
@Chocohound I find a case like this is usually the program failing to finish exiting. However, it may be using kernel services and not shutting them down. Check the logs for the daemon to see if it reports any problems. – BillThor Nov 13 '12 at 1:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .