无法使用我的服务器监听端口80 [英] Can't listen on port 80 with my server

查看:979
本文介绍了无法使用我的服务器监听端口80的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这种问题上是非常新的,我正在尝试在端口80上启动服务器(使用此特定端口对我来说很重要).

Very new on this kind of issue, i am trying to launch a server on the port 80 (it's important to me to use this specific port).

它失败了,但是它可以在其他端口上工作(当我是root时甚至是<1024,但在端口80上仍然失败).

It's fails, but it works on other ports (even < 1024 when i am root, but still fail on the port 80).

我可能在端口80上运行了某些设备,我想对其进行标识以更改其侦听端口.

I probably have something running on the port 80, i would like to identify it in order to change its listening port.

我看到此cmd可以帮助查看特定端口的状态:netstat -ano|grep 80|grep LISTEN,但我不确定您是否对结果了解得很好.

I saw this cmd can help to see the state of a specific port: netstat -ano|grep 80|grep LISTEN but i am not sure tu understand well the result.

这就是我得到的:

tcp        0      0 127.0.0.1:28017         0.0.0.0:*               LISTEN      off (0.00/0/0)
tcp6       0      0 :::80                   :::*                    LISTEN      off (0.00/0/0)
unix  2      [ ACC ]     STREAM     LISTENING     8805     /tmp/mongodb-27017.sock
unix  2      [ ACC ]     STREAM     LISTENING     13112    /home/me/.pulse/04d802bb34ddb9da49b1f9060000000b-runtime/native

我在第2行上看到端口80似乎没有在监听,但对此没有进一步的了解.

I read on the line 2 that the port 80 seems to be not listening, but don't understand further.

更新:

sudo lsof -i :80

COMMAND    PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
apache2   1107     root    4u  IPv6   7630      0t0  TCP *:http (LISTEN)
apache2   1131 www-data    4u  IPv6   7630      0t0  TCP *:http (LISTEN)
apache2   1132 www-data    4u  IPv6   7630      0t0  TCP *:http (LISTEN)
apache2   1133 www-data    4u  IPv6   7630      0t0  TCP *:http (LISTEN)
apache2   1134 www-data    4u  IPv6   7630      0t0  TCP *:http (LISTEN)
apache2   1136 www-data    4u  IPv6   7630      0t0  TCP *:http (LISTEN)
ubuntu-ge 2095     me    7u  IPv4  82145      0t0  TCP me-Ubuntu.local:43345->mulberry.canonical.com:http (CLOSE_WAIT)

谢谢(我正在使用ubuntu)!

Thanks (i am using ubuntu) !

推荐答案

如果这是Linux(也许不是MacOS,也可能是其他一些UNIX),请尝试运行以下命令:

If this is Linux (and perhaps some other UNIXes as well, though not MacOS), try running the following:

sudo netstat -lnp

您将获得类似于以下内容的输出:

You'll get output similar to the following:

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:80              0.0.0.0:*               LISTEN     26156/apache2       
...

我将列出有趣的部分:

  • 本地地址: 0.0.0.0:80 -有问题的地址是所有接口上的端口80.
  • 状态: LISTEN -正在监听
  • PID/程序名称- 26156/apache2 -正在侦听端口的进程的ID和名称.
  • Local Address: 0.0.0.0:80 - The address in question is port 80 on all interfaces.
  • State: LISTEN - It's listening
  • PID/Program name - 26156/apache2 - The ID and name of the process that's listening to the port.

您基本上想确保上面提到的程序没有运行(例如,对于我来说,我必须关闭apache2守护程序,并将操作系统配置为在下次启动时不自动启动它).

You basically want to to make sure the program mentioned above isn't running (e.g., in my case, I'd have to shutdown the apache2 daemon, and configure the OS to not automatically start it up on next boot).

另一方面,如果您只是想快速解决此问题,则可以终止该过程:

On the other hand, if you just want to get this fixed quickly, you can kill the process:

kill -9 <pid>

在我的示例中:

kill -9 26156

当您下次重新启动或有人启动该服务时,问题当然会再次出现.

The problem will of course return the next time you reboot, or someone starts up that service.

这篇关于无法使用我的服务器监听端口80的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆