nginx报错:connect() failed (111: Connection refused) while connecting to upstream

nginx错误日志有如下报错:
2021/06/21 14:24:47 [error] 12112#0: *7807990 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xx.xx, server: localhost, request: “GET /itms/cpe/cpe.listPage.action HTTP/1.1”, upstream: “http://[::1]:xxxx/itms/cpe/cpe.listPage.action”, host: “xx.xx.xx.xx:xxxx”, referrer: “http://xx.xx.xx.xx:xxxx/itms/index.menu.action”

我这里是nginx配置有问题,针对这种情况,解决方式如下:

ifconfig 查看 lo
在这里插入图片描述
::1 指的是本地ipv6地址

查看nginx配置
vim /usr/local/nginx/conf/nginx.conf
proxy_pass 中,如果配置的是localhost,就是转发到本地ipv4和ipv6,即报文章开头的错误。
在这里插入图片描述
改成127.0.0.1,不再有报错
在这里插入图片描述
改完重启nginx,
/usr/local/nginx/sbin/nginx -s reload

完毕。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值