Nginx 学习笔记(七)如何解决nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
出现:nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) 错误,有以下两种情况
1、80端口被占用
2、ipv4端口和ipv6端口冲突的问题
今天服务器安装了NodeJs,服务器实在卡的不行,就重启了,结果重启后,Nginx没有自动重启。果断的手动重启,结果问题来了
在ubuntu16.04上面尝试启动nginx,使用命令:
sudo /etc/init.d/nginx start
启动不了啊!出错了哎!提示的错误信息:
www@TinywanAliYun:~$ sudo /usr/local/openresty/nginx/sbin/nginx
nginx: [warn] could not build optimal variables_hash, you should increase either variables_hash_max_size: or variables_hash_bucket_size: ; ignoring variables_hash_bucket_size
nginx: [emerg] bind() to 0.0.0.0: failed (: Address already in use)
nginx: [emerg] bind() to 0.0.0.0: failed (: Address already in use)
nginx: [emerg] bind() to 0.0.0.0: failed (: Address already in use)
nginx: [emerg] bind() to 0.0.0.0: failed (: Address already in use)
nginx: [emerg] bind() to 0.0.0.0: failed (: Address already in use)
nginx: [emerg] still could not bind()
第一种情况,查看80端口是不是被占用了
www@TinywanAliYun:~$ netstat -anp |grep
(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:80 0.0.0.0:* LISTEN -
tcp 0 0 内网IP:50852 外网IP:80 ESTABLISHED -
unix [ ACC ] STREAM LISTENING - /var/run/nscd/socket
unix [ ] STREAM CONNECTED -
问题上面怎么没有显示进程号
尽然没有仔细的看看这句话,要root权限啊!赶紧切换
这次看来是真有了,怎么是apache2,我都不知道什么时候安装的这个:ab 测试吗?
立马卸掉
重启Openresty,看看情况
果断没报错呀,访问:https://www.tinywan.com/ 一切正常
第二种情况
遇到这种问题我先用中文搜索了一下答案,发现大家都在装逼地说要杀nginx重复的进程。我试了下发现是扯淡,于是看了谷歌搜到的第一个英文页面,老外说是nginx先监听了ipv4的80端口之后又监听了ipv6的80端口,于是就重复占用了。更加坑人的是你去看了端口占用它又把80端口释放了,是不是很囧。 解决方案是编辑nginx的配置文件
我的配置
# 配置HTTP请求重定向
server {
# 监听所有的ipv4的地址
listen default_server;
# 监听所有的ipv6的地址
listen [::]: default_server;
server_name _;
# Redirect all HTTP requests to HTTPS with a Moved Permanently response.
return https://$host$request_uri;
# 过滤爬虫
if ($http_user_agent ~* "python|curl|java|wget|httpclient|okhttp") {
return ;
}
}
修改这一段
listen [::]: default_server;
修改后
listen [::]: ipv6only=on default_server;
果断重启后,正常
分析一下问题:
刚开始我是Nginx默认开机启动的,但是我今天又搞了个Openresty开启自启动,是不是冲突掉了
直接把Nginx启动脚本删掉 rm /etc/init.d/nginx ,又重启,结果还是不行
那就安装个sysv-rc-conf 工具看看,该命令可以查看到当前系统开启机动服务的情况。
果不其然,任然在开启启动项中呀!!!
我们再来看看通启动相应的服务的脚本文件是否存在
看到了吗!也在这里啊!啊哈
http://www.hankcs.com/appos/linux/fix-nginx-bind-err.html
Nginx 学习笔记(七)如何解决nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)的更多相关文章
- 解决nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx先监听了ipv4的80端口之后又监听了ipv6的80端口,于是就重复占用了.更加坑人的是你去看了端口占用它又把80端口释放了,是不是很囧. 解决方案是编辑nginx的配置文件 修改这一段:
- nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) 错误解决
今天在做LNMP的时候,启动nginx服务,无法开启,导致网页打不开.把服务从起一下发现提示错误如下: Starting nginx: nginx: [emerg] bind() to 0.0.0.0 ...
- nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)解决
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) 报错信息 nginx: [emerg] bind() t ...
- nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address
http://blog.csdn.net/ownfire/article/details/7966645 今天在做LNMP的时候,启动nginx服务,无法开启,导致网页打不开.把服务从起一下发现提示错 ...
- Linux教程之:Nginx [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
Nginx [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use) 使用命令关闭占用80端口的程序 sudo fuser - ...
- 修改nignx报错Nginx [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
Nginx [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use) 这个错误是修改了nginx的配置时出现,表名80端口被程 ...
- nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)解决方案
前提:已经配置好静态IP以防万一,先安装好iptables服务(不管你装没装,先执行,免得后面添乱)[root@localhost ~]# yum install iptables-services[ ...
- Nginx学习笔记(三) Nginx基本数据结构
Nginx基本数据结构 话说学习一种编程语言,例如C语言,我们首先学的也是数据结构,这是以后开发程序的关键.为了更好更方便的开发Nginx,Nginx自己实现了很多适合nginx的数据结构. Ngin ...
- 【转】Nginx 学习笔记(十一)nginx下安装配置naxsi waf防火墙(附完整编译、配置)
原文地址:http://f2ex.cn/nginx-installed-configuration-naxsi-waf/ Naxsi 是第三方 nginx 模块 ,它和 Modsecurity 都是开 ...
随机推荐
- 导弹拦截(pascal)
导弹拦截 [问题描述] 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能高于前一发的高度.某天,雷达捕 ...
- vue.js初学,笔记1,安装
最近学习vue.js,下面是笔记: 说明:因为npm安装插件是从国外服务器下载,受网络影响大,可能出现异常,如果npm的服务器在中国就好了,所以我们乐于分享的淘宝团队干了这事.来自官网:"这 ...
- 关于hue安装后出现KeyError: "Couldn't get user id for user hue"的解决方法
首先说明出现此问题的原因是因为你使用的root用户安装了hue,然后在root用户下使用的build/env/bin/supervisor,如下图所示那样: 知道了原因,就容易解决问题了.首先要创建个 ...
- 对象存取器属性:getter和setter
在一个对象中,操作其中的属性或方法,通常运用最多的就是读(引用)和写了,譬如说o.a,这就是一个读的操作,而o.b = 1则是一个写的操作.事实上在除ie外最新主流浏览器的实现中,任何一个对象的键值都 ...
- hdu5353 Average
Problem Description There are n soda sitting around a round table. soda are numbered from 1 to n and ...
- 【转】Spring Bean单例与线程安全
一.Spring单例模式及线程安全 Spring框架中的Bean,或者说组件,获取实例的时候都是默认单例模式,这是在多线程开发的时候需要尤其注意的地方. 单例模式的意思是只有一个实例,例如在Sprin ...
- map对象拷贝问题
map对象赋值: HashMap<String,Object> hm = new HashMap(); HashMap<String,Object> hmCopy = new ...
- Python编程和 Lua编程的比较
Python编程和 Lua编程的比较 2016.4.21 定义函数: python: def functionname( parameters ): "函数_文档字符串" func ...
- Java SpringMVC 定时任务
1.web.xml 2.spring-mvc.xml <?xml version="1.0" encoding="UTF-8"?> <bean ...
- HTML5 桌面通知:Notification API
原文地址:http://blog.gdfengshuo.com/article/23/ 前言 Notification API 是 HTML5 新增的桌面通知 API,用于向用户显示通知信息.该通知是 ...