我正试图把我的端口7979连接到nginx,但它不起作用。我在localhost上:7979/myproject/app/index.php,但是当我重新启动我的mac并更新它时,我现在看到了错误消息:
ERR_CONNECTION_REFUSED
当我尝试sudo nginx时,我会看到以下消息。
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] still could not bind()80号港口正在运作。如果我转到localhost:80,我会在html页面中看到以下消息:
默认网站祝贺,您的Nginx似乎工作得很好。:)
为什么我不能使用端口7979?
发布于 2017-12-20 01:54:59
我更改了根和端口,它在站点可用/默认情况下工作。在默认情况下,根不是很好,我不知道为什么在我重新启动我的mac时它会改变。THan
发布于 2017-12-20 02:05:29
很难用这个小信息来排除故障。所以首先:
像nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)这样的错误消息表明某些东西已经在监听端口80,因此nginx在启动它时也不能这样做。
假设您的配置文件完全正常,那么您必须弄清楚端口80、443和306上已经侦听的是什么。它可能是nginx的一个实例,它运行的配置较旧,但没有更多的细节,这只是猜测而已。
查看正在运行的进程:
$ ps -ax
查看是否有一个nginx实例正在运行:
$ ps -ax | grep nginx
Netstat可以告诉您正在侦听哪些端口:
$ nestat -an | grep LISTEN
要找出哪个进程正在侦听给定端口:
$ sudo lsof -i :631
(631只是一个例子)
我怀疑的是:你正在启动nginx,而它已经在运行了。如果它已经在运行,您应该重新启动它,而不是启动一个新的副本。
这可能会有所帮助:https://serverfault.com/questions/225948/how-to-restart-nginx-on-mac-os-x在本质上是:
$ sudo nginx -s reload
只是一个警告,我没有在macOS上运行nginx,但是如果macOS上的nginx像在FreeBSD上那样( macOS使用它作为一个很远的基础),它应该能工作。
https://stackoverflow.com/questions/47896154
复制相似问题