Linux系统下服务端口被占用处理方法

odoo系统一直起不来,提示我地址被占用

odoo@vm:~/odoo12$ ./odoo-bin -i base -d odoo
2022-01-21 07:14:23,048 7984 INFO ? odoo: Odoo version 12.0
2022-01-21 07:14:23,049 7984 INFO ? odoo: addons paths: ['/opt/odoo/.local/share/Odoo/addons/12.0', '/opt/odoo/odoo12/odoo/addons', '/opt/odoo/odoo12/addons']
2022-01-21 07:14:23,049 7984 INFO ? odoo: database: default@default:default
2022-01-21 07:14:23,303 7984 INFO ? odoo.addons.base.models.ir_actions_report: You need Wkhtmltopdf to print a pdf version of the reports.
Exception in thread odoo.service.httpd:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/odoo/odoo12/odoo/service/server.py", line 437, in http_thread
    self.httpd = ThreadedWSGIServerReloadable(self.interface, self.port, app)
  File "/opt/odoo/odoo12/odoo/service/server.py", line 150, in __init__
    handler=RequestHandler)
  File "/opt/odoo/.local/lib/python3.6/site-packages/werkzeug/serving.py", line 698, in __init__
    HTTPServer.__init__(self, server_address, handler)
  File "/usr/lib/python3.6/socketserver.py", line 456, in __init__
    self.server_bind()
  File "/opt/odoo/odoo12/odoo/service/server.py", line 165, in server_bind
    super(ThreadedWSGIServerReloadable, self).server_bind()
  File "/usr/lib/python3.6/http/server.py", line 136, in server_bind
    socketserver.TCPServer.server_bind(self)
  File "/usr/lib/python3.6/socketserver.py", line 470, in server_bind
    self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use

通过命令查看

odoo@vm:~/odoo12$ netstat  -anp  |grep 8069
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:8069            0.0.0.0:*               LISTEN      3292/python

确实被python占用了

再确认一遍

odoo@vm:~/odoo12$ netstat   -nultp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:25324           0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:81              0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:8883            0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:43013         0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:8069            0.0.0.0:*               LISTEN      3292/python
tcp        0      0 0.0.0.0:5671            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:5000            0.0.0.0:*               LISTEN      -
tcp6       0      0 :::81                   :::*                    LISTEN      -
tcp6       0      0 :::8883                 :::*                    LISTEN      -
tcp6       0      0 :::22                   :::*                    LISTEN      -
tcp6       0      0 :::5432                 :::*                    LISTEN      -
tcp6       0      0 :::443                  :::*                    LISTEN      -
tcp6       0      0 :::5671                 :::*                    LISTEN      -
tcp6       0      0 :::5000                 :::*                    LISTEN      -
udp        0      0 127.0.0.1:25224         0.0.0.0:*                           -
udp        0      0 127.0.0.53:53           0.0.0.0:*                           -
udp        0      0 10.0.0.5:68             0.0.0.0:*                           -

无误,使用kill命令杀掉该进程

odoo@vm:~/odoo12$ kill -9 3292
odoo@vm:~/odoo12$
odoo@vm:~/odoo12$ netstat  -anp  |grep 8069
(No info could be read for "-p": geteuid()=990 but you should be root.)

稍后重启系统,发现可以正常启动。

PS:

如果netstat 查看到pid进程号为空,则可以通过 top 命令查看系统进程。

或者  ps -u odoo 命令找到odoo 用户占用 的 python3 pid,则它就是需要被kill 的pid。

参见:

https://www.cnblogs.com/hindy/p/7249234.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值