503 Service Unavailable 原因与解决办法

今天打开网站无故出现如下错误:

Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

中文翻译如下:

服务不可用

由于维护停机或容量问题,服务器暂时无法为您的请求提供服务。请稍后再试。

 

Service Unavailable The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

 

解决办法

通常只要出现503 Service Unavailable 都是服务器内部或搭建环境出了问题,我的服务器是lamp环境。

 

1、先测试是否能访问网站根目录下的txt文件或图片文件......我做了测试,都能正常访问,只是遇到php文件的时候就会出现“503 Service Unavailable”;

 

2、查看php、apache是否正常启动?我都重新启动了php、apache都没有问题。

 

3、查看php日志和apache日志,我查看了php日志,没有任何问题。我查看apache error.log日志的时候出现了大量的报错,如下:

[Wed Sep 06 18:01:56.725923 2017] [proxy:error] [pid 18682] (111)Connection refused: AH00957: FCGI: attempt to connect to 127.0.0.1:10000 (*) failed

[Wed Sep 06 18:01:56.725971 2017] [proxy_fcgi:error] [pid 18682] [client 119.29.125.32:39155] AH01079: failed to make connection to backend: 127.0.0.1

 

从日志可以看出,连接到”127.0.0.1:10000“失败,相信大家都知道,我的环境是apache+php,只要网站遇到php文件默认都应该去找:127.0.0.1:9000对吗?因为我们启动的php-fpm时候,它默认的配置端口就是9000;

 

我马上去linux服务器找到 php-fpm.conf 文件,发现监听的是:127.0.0.1:9000,但日志报错却是监听的端口是10000。

 

我只好把:127.0.0.1:9000 修改为 127.0.0.1:10000;

 

4、重启php,网站已经可以正常访问!

 

注意:

上面是我解决“503 Service Unavailable ”的一个思路,你可以按照我的这个思路去解决属于你自己的问题,如果不能解决,也是可以来找博主的!

 


 

今天一位朋友也现了 503 Service Unavailable,他的网站是用宝塔搭建的,只要访问php后缀的文件就会报 Service Unavailable 这个错误,由于Q上找到我,我就顺便去帮忙解决 一下。结果,查看了他的 error.log日志,发现了大量类似的如下错误提示:

[Tue Apr 28 18:48:07.156601 2020] [proxy:error] [pid 1056:tid 140634929157888] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /tmp/php-cgi-00.sock (*) failed

[Tue Apr 28 18:48:07.156685 2020] [proxy_fcgi:error] [pid 1056:tid 140634929157888] [client 60.255.139.35:44260] AH01079: failed to make connection to backend: httpd-UDS, referer: http://175.24.35.236/files/%E5%BE%AE%E8%A8%80.html

中文翻译

2020年4月28日星期二18:48:07.156601] [proxy:error] [pid 1056:tid 140634929157888](2)没有这样的文件或目录:AH02454:FCGI:尝试连接到Unix域套接字 /tmp/php-cgi-00.sock (*)失败

[2020年4月28日星期二18:48:07.156685] [proxy_fcgi:error] [pid 1056:tid 140634929157888] [客户端60.255.139.35:44260] AH01079:无法建立与后端的连接:httpd-UDS,引荐来源:http:// 175.24.35.236/files/%E5%BE%AE%E8%A8%80.html

503 Service Unavailable 尝试连接到Unix域套接字 /tmp/php-cgi-00.sock (*)失败

 

我的解决方法步骤如下:

1、根据日志报错,我依然按照文章上面所讲的思路去查看PHP,发现PHP各方面都是正常运行的,并没有任何的错误。结果,我上“宝塔 - 网站设置 - 站点修改 - PHP版本”,仔细一年,他并没有选择任何的PHP版本,他居然用的是纯静态

PHP版本 纯静态

 

2、因此,我只需要选择一个PHP版本即可恢复正常。

    A+
发布日期:2017年09月06日 19:41:50  所属分类:PHP
最后更新时间:2020-04-28 19:08:39
评分: (2 票;平均数5.00 ;最高评分 5 ;用户总数2;总得分 10;百分比100.00)
付杰
wordpress站群服务 泛解析二级域名 二级目录站群
wordpress站群服务 泛解析二级域名 二级目录站群
  • ¥ 1999.9元
  • 市场价:4800元
免费SSL证书 HTTPS申请 安装 配置 支持通配符*
免费SSL证书 HTTPS申请 安装 配置 支持通配符*
  • ¥ 199.9元
  • 市场价:20000元
刷流量 刷人气 刷点击 刷收藏 刷APP关键词
刷流量 刷人气 刷点击 刷收藏 刷APP关键词
  • ¥ 1.0元
  • 市场价:9.9元
SEO顾问 中小型网站 单站最低99.9元 全方位优化
SEO顾问 中小型网站 单站最低99.9元 全方位优化
  • ¥ 99.9元
  • 市场价:5000元

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:8   其中:访客  4   博主  4

  1. 头像 巅峰对决 0

    Thu Jun 25 09:20:30.678804 2020] [proxy:error] [pid 10877:tid 140028315186944] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /usr/local/php72/sockets/armvscom.sock (*) failed
    [Thu Jun 25 09:20:30.678893 2020] [proxy_fcgi:error] [pid 10877:tid 140028315186944] [client 172.68.141.15:13256] AH01079: failed to make connection to backend: httpd-UDS
    [Thu Jun 25 09:21:08.363311 2020] [proxy:error] [pid 10957:tid 140028306794240] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /usr/local/php72/sockets/armvscom.sock (*) failed
    [Thu Jun 25 09:21:08.363396 2020] [proxy_fcgi:error] [pid 10957:tid 140028306794240] [client 172.68.189.228:64452] AH01079: failed to make connection to backend: httpd-UDS
    [Thu Jun 25 09:21:32.322710 2020] [proxy:error] [pid 10957:tid 140028399113984] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /usr/local/php72/sockets/armvscom.sock (*) failed
    [Thu Jun 25 09:21:32.322758 2020] [proxy_fcgi:error] [pid 10957:tid 140028399113984] [client 43.225.169.213:40695] AH01079: failed to make connection to backend: httpd-UDS
    [Thu Jun 25 09:22:44.535495 2020] [proxy:error] [pid 10877:tid 140028298401536] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /usr/local/php72/sockets/armvscom.sock (*) failed
    [Thu Jun 25 09:22:44.535561 2020] [proxy_fcgi:error] [pid 10877:tid 140028298401536] [client 43.225.169.186:57318] AH01079: failed to make connection to backend: httpd-UDS
    [Thu Jun 25 09:24:17.543978 2020] [proxy:error] [pid 10957:tid 140028466255616] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /usr/local/php72/sockets/armvscom.sock (*) failed
    [Thu Jun 25 09:24:17.544013 2020] [proxy_fcgi:error] [pid 10957:tid 140028466255616] [client 173.245.54.140:13876] AH01079: failed to make connection to backend: httpd-UDS
    [Thu Jun 25 09:25:50.761126 2020] [proxy:error] [pid 10877:tid 140028298401536] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /usr/local/php72/sockets/armvscom.sock (*) failed
    [Thu Jun 25 09:25:50.761180 2020] [proxy_fcgi:error] [pid 10877:tid 140028298401536] [client 172.69.34.27:22880] AH01079: failed to make connection to backend: httpd-UDS
    [Thu Jun 25 09:26:54.383626 2020] [proxy:error] [pid 10957:tid 140028466255616] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /usr/local/php72/sockets/armvscom.sock (*) failed
    [Thu Jun 25 09:26:54.383657 2020] [proxy_fcgi:error] [pid 10957:tid 140028466255616] [client 43.225.171.250:46306] AH01079: failed to make connection to backend: httpd-UDS
    [Thu Jun 25 09:29:28.246945 2020] [proxy:error] [pid 10957:tid 140028642502400] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /usr/local/php72/sockets/armvscom.sock (*) failed
    [Thu Jun 25 09:29:28.246979 2020] [proxy_fcgi:error] [pid 10957:tid 140028642502400] [client 43.225.169.225:49257] AH01079: failed to make connection to backend: httpd-UDS
    [Thu Jun 25 09:29:55.670324 2020] [proxy:error] [pid 10877:tid 140028315186944] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /usr/local/php72/sockets/armvscom.sock (*) failed
    [Thu Jun 25 09:29:55.670366 2020] [proxy_fcgi:error] [pid 10877:tid 140028315186944] [client 43.225.214.34:41521] AH01079: failed to make connection to backend: httpd-UDS
    部分错误提示 php版本切换到7.2 出现 无法访问网络。

    • 付杰 付杰

      @巅峰对决 你这个是PHP压根没有启动起来,sock都连接不上。

  2. 头像 趁我热情未改 0

    我有一个导出数据的功能,里面有循环函数在连接数据库,原来在阿里的服务器能导出来,就是慢一点,迁移到百度的服务器后导不出来,报错跟文章一样,我用的是宝塔,我看了各方面的配置什么的,都没有什么问题,不知道怎么解决?而且执行导出的时候服务器CPU和内存也就占30%左右。

    • 付杰 付杰

      @趁我热情未改 由于你加我QQ群了,群里问到我了,我就顺便帮忙看了一下,由于你是apache+php+mysql,apache日志没有,我就继续看php日志,php日志最主要的部份如下:

      
      [08-Apr-2020 11:01:58] NOTICE: fpm is running, pid 2336
      [08-Apr-2020 11:01:58] NOTICE: ready to handle connections
      [08-Apr-2020 11:02:13] NOTICE: Finishing ...
      [08-Apr-2020 11:02:13] NOTICE: exiting, bye-bye!
      [08-Apr-2020 11:02:14] NOTICE: fpm is running, pid 2358
      [08-Apr-2020 11:02:14] NOTICE: ready to handle connections
      [08-Apr-2020 11:02:54] WARNING: [pool www] child 2359, script '/www/wwwroot/sxt***/index.php' (request: "POST /index.php") executing too slow (30.112484 sec), logging
      [08-Apr-2020 11:02:54] NOTICE: child 2359 stopped for tracing
      [08-Apr-2020 11:02:54] NOTICE: about to trace 2359
      [08-Apr-2020 11:02:54] NOTICE: finished trace of 2359
      [08-Apr-2020 11:03:54] WARNING: [pool www] child 2374, script '/www/wwwroot/sxt***/index.php' (request: "POST /index.php") executing too slow (30.002253 sec), logging
      [08-Apr-2020 11:03:54] WARNING: [pool www] child 2367, script '/www/wwwroot/sxt***/index.php' (request: "POST /index.php") executing too slow (37.141216 sec), logging
      [08-Apr-2020 11:03:54] NOTICE: child 2367 stopped for tracing
      [08-Apr-2020 11:03:54] NOTICE: about to trace 2367
      [08-Apr-2020 11:03:54] NOTICE: finished trace of 2367
      [08-Apr-2020 11:03:54] NOTICE: child 2374 stopped for tracing
      [08-Apr-2020 11:03:54] NOTICE: about to trace 2374
      [08-Apr-2020 11:03:54] NOTICE: finished trace of 2374
      [08-Apr-2020 11:05:04] WARNING: [pool www] child 2374, script '/www/wwwroot/sxt***/index.php' (request: "POST /index.php") execution timed out (100.011164 sec), terminating
      [08-Apr-2020 11:05:04] WARNING: [pool www] child 2374 exited on signal 15 (SIGTERM) after 160.029150 seconds from start
      [08-Apr-2020 11:05:04] NOTICE: [pool www] child 2414 started

      从这个日志可以推算出:
      由于PHP执行时间过长,导致了php-fpm child进程崩溃了,child都结束了,出现这个错误就很正常了。
      建议你优化代码,可以去看一下PHP的慢日志。
      由于你以前用的阿里云Windows服务器是可以的,这是因为价格的问题。果然,你说老板为了便宜换成了百度云的Linux服务器。我看了一下你的现在服务器配置:CPU是1个物理CPU,两个核心,四个线程的,内存是8G。

  3. 腾蛙 0

    升级插件出现了这个提示

    • 付杰 付杰

      @腾蛙 你是指升级wordpress插件吗?503都是属于服务器的错误。

  4. 头像 止戈为武 0

    为什么我杀掉php-fpm后,直接/usr/local/php/sbin/php-fpm启动不了!报:
    Usage: /usr/local/php/sbin/php-fpm {start|stop|quit|restart|reload|logrotate}

    • 付杰 付杰

      @止戈为武 有可能php版本的原因吧,报错其实已经说了,是语法的问题。用以下命令“启动”就行:
      /usr/local/php/sbin/php-fpm start