嗯哼,刚装了个ubuntu的lnmp,我的天啊,踩的坑比我脂肪还多了

比如刚装完的时候访问显示502,

也不知道什么问题,就去看了一下nginx日志  /var/log/nginx/error.log,发现了这个错误

2018/06/03 13:38:23 [error] 21332#21332: *301 connect() failed (111: Connection refused) while connecting to upstream, client: 115.159.183.71, server: 202.182.116.84, request: "GET /phpmyadmin/index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "202.182.116.84"
去搜了一下,这样的错误有两个解决方式

 1.php-fpm没有运行
执行如下命令查看是否启动了php-fpm,如果没有则启动你的php-fpm即可

netstat -ant | grep 

2.php-fpm队列满了
php-fpm.conf(/etc/php/7.0/fpm/php-fpm.conf)配置文件pm.max_children修改大一点,重启php-fpm并观察日志情况

呵呵,但是呢,姐姐岂止是普通人,这两个都看了还是不行,解决完了才发现,没想到啊,自己竟然有一个这么大的错误

来啊从配置文件开始看起吧,

3、修改配置文件

因为nginx和php有两种链接方式,一种是

fastcgi_pass 127.0.0.1:9000;

另一种是这个
fastcgi_pass unix:/run/php/php7.0-fpm.sock;

这个具体怎么用要去php fpm里面去看他的配置文件
/etc/php/7.0/fpm/pool.d/www.conf里面的Listen

如果Listen是端口就写127.0.0.1:9000;

如果是路径,nginx的配置文件也要学路径,unix:/run/php/php7.0-fpm.sock;

重新访问就好了

所以说修改一下配置文件,在重启一下nginx,就好了。其实按理说不能发生这种事的,但是呢?自己搭的时候,几乎所有的事都有可能发生。记录下来,以防再次入坑。

nginx 解决 connect() failed (111: Connection refused) while connecting to upstream,的更多相关文章

  1. 解决connect() failed (111: Connection refused) while connecting to upstream

    使用nginx时, 有可能遇到connect() failed (111: Connection refused) while connecting to upstream的问题. 如果upstrea ...

  2. Nginx报错 connect() failed (111: Connection refused) while connecting to upstream 的解决方法

    今天访问公司的网站突然报错,抛出一些英文,提示看一下Nginx的error.log日志: cd  /usr/local/nginx/logs/  看到了error.log ,下一步 tail -n 2 ...

  3. [nginx] connect() failed (111: Connection refused) while connecting to upstream, client: 101.18.123.107, server: localhost,

    nginx一直报错, 2016/12/02 10:23:19 [error] 1472#0: *31 connect() failed (111: Connection refused)while c ...

  4. nginx访问502 gateway,*1 connect() failed (111: Connection refused) while connecting to upstream

    安装好nginx,php环境后,配置虚拟主机,结果访问后就报502 gateway,查看日志文件后,显示错误如下: 2019/04/29 16:24:39 [error] 19433#19433: * ...

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

    公司网站搬迁到新服务器后,发现站点访问不了,network里面提示502,查看相关的server配置,感觉没有什么问题,经过测试发现txt.html.等非php文件能够直接访问,也就是php访问不了, ...

  6. connect() failed (111: Connection refused) while connecting to upstream

    配置好lamp后,在浏览器中运行程序后,出现上面的错误. 转自:http://www.xuejiehome.com/blread-1828.html I'm experiencing 502 gate ...

  7. 配置nginx.config 报错:connect() failed (111: Connection refused) while connecting to upstream解决

    php-fpm没有运行 执行如下命令查看是否启动了php-fpm,如果没有则启动你的php-fpm即可 查看: netstat -ant | grep 9000 执行 /usr/local/php/s ...

  8. connect() failed (111: Connection refused) while connecting to upstream的解决

    遇到这种情况, 首先 1.检查php-fpm是否启动---------如果没启动->启动, 2.用命令 netstat -ant | grep 9000 查看php-fpm进程,如果没启动-&g ...

  9. connect() failed (111: Connection refused) while connecting to upstream报错处理

    新lnmp环境调试项目时,nginx报错如下: 解决: 发现php-fpm.conf是以套接字方式通信,而nginx是以端口方式通信,见下图: 将nginx.conf修改为如下,重新reload即可

随机推荐

  1. Python入门7 —— 赋值运算符补充

    增量赋值 x = 10 x += 1 #就是:x = x+1 交叉赋值 a = 10 b = 20 print(a,b) temp=b # temp=20 b=a # b = 10 a=temp # ...

  2. Codeforces Round #601 (Div. 2) D Feeding Chicken

    //为了连贯,采取一条路形式,从第一行开始 也就是s型 #include <bits/stdc++.h> using namespace std; ; char str[MAXN][MAX ...

  3. Vue.js ---Hello---1

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  4. selenium获取短暂出现元素的xpath路径

    1. pip install beautifulsoup4  :安装beautifulsoup4 2. from bs4 import BeautifulSoup 3. bs = BeautifulS ...

  5. 安装破解pycharm2018版

    1.安装2018版pycharm: 2.把破解补丁放在一个地方(目录无中文,无空格): 3.在 Pycharm安装目录的\bin目录下找到 pycharm.exe.vmoptions 和 pychar ...

  6. xrdp---远程桌面连接

    xrdp is an Open Source Remote desktop Protocol server, which allows you to RDP to your Linux server ...

  7. Linux system 初步

    快捷键: open a new terminal: ctrl+alt+T; close current terminal: ctrl+shift+W; switch windows: alt+tab ...

  8. linux网卡

    手动启动 ifup eth0 查询网卡配置信息 vim /etc/udev/rules.d/70-persistent-net.rules 备注:可以修改网卡名称和MAC地址

  9. unity的一些特殊目录

    Hidden Folders Folders that start with a dot (e.g. ".UnitTests/", ".svn/") are i ...

  10. web项目中设置首页

    1.在web.xml中设置以下代码: <welcome-file-list> <welcome-file>login.jsp</welcome-file> < ...