Nginx 提示host not found in upstream 错误解决方法

nginx的upstream配置如下:

upstream nos {
    server nos.xxx.com weight=10 max_fails=3 fail_timeout=30s;
}

检查语法报错:

root@ubuntu:~/odd/nginx/sbin# ./nginx -t
nginx: [emerg] host not found in upstream "nos.xxx.com" in /root/odd/nginx/conf/upstream/nos.conf:5
nginx: configuration file /root/odd/nginx/conf/nginx.conf test failed

猜测是dns解析域名失败,:

root@ubuntu:~/odd/nginx/sbin# ping wwww.baidu.com
ping: unknown host wwww.baidu.com

ping百度不通,无法上外网。检查/etc/resolv.conf,发现没有配置域名服务器,增加域名服务器:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
nameserver 8.8.4.4

重启网络:

root@ubuntu:~/odd/nginx/sbin# /etc/init.d/networking restart
[ ok ] Restarting networking (via systemctl): networking.service.

重新检查nginx语法:

root@ubuntu:~/odd/nginx/sbin# ./nginx -t
nginx: the configuration file /root/odd/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /root/odd/nginx/conf/nginx.conf test is successful

ok,现在成功了!

  • 5
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值