SNMP error with port already in use

僤鯓⒐⒋嵵緔 提交于 2019-12-05 23:00:05

By using netstat command.

Specifically,

netstat -s [PORT_NO]

For example,

netstat -s 161

  1. http://www.techrepublic.com/blog/security/list-open-ports-and-listening-services/443
  2. http://www.speedguide.net/faq_in_q.php?qid=115

By just starting your application. If it gets a BindException, the port is in use. If it doesn't, your application can run. Knowing that ahead of time doesn't really buy you anything.

Just additional remark. I think you may be forbidden to use low port numbers (security policy if not a root user) - try using higher numbers i.e. 10161.

1)ps -efww | grep 161   

2)netstat -anp | grep 161

On Windows you can use netstat and tasklist. For example,

netstat -aon | findstr 161

Its output should be

C:\Program Files\Microsoft Visual Studio 9.0\VC>netstat -aon |findstr 161
  UDP    0.0.0.0:161            *:*                                    1620
  UDP    [::]:161               *:*                                    1620

Then use tasklist

tasklist /fi "PID eq 1620"

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
snmp.exe                      1620 Services                   0      1,172 K

In my case obviously it is Windows SNMP services who uses port 161. In your case, it may be another process.

following statement works for me.

netstat -lnp

sample usage:

appuser@-app:~$ sudo netstat -lnp |grep 162
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      1162/mysqld
udp6       0      0 127.0.0.1:162           :::*                                6830/java
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!