44
31

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

nginxで、connect() failed (111: Connection refused) while connecting to upstreamってエラーにハマった。

Posted at

#エラーは突然に
ある瞬間、ステージ環境(EC2)にアクセスすると502を返すようになった。
昨日まで難なく動いていたのに。結合環境は動くのでソースのせいではないようだ。
受入試験真っ只中、どうする、私。

##とりあえず、エラーは?
nginxのエラーは以下の通りです。

error.log
2018/02/06 04:31:01 [error] 3107#0: *3318 connect() failed (111: Connection refused) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "hoge.com"

キーワードは「upstream」と「fastcgi」なんじゃないかなぁと推測。

#解決方法
php-fpm.confの「listen」とnginx.confの「fastcgi_pass」は同じでなければなりません。

  • php-fpm.confの確認
  • listen = /var/run/php-fpm.sock
  • nginx.confの確認
  • fastcgi_pass 127.0.0.1:9000;

あってなくね?

nginx.confのfastcgi_passの部分をphp-fpm.confと揃えてあげればいいので

nginx.conf
 fastcgi_pass   unix:/var/run/php-fpm.sock;

ってして、reloadしてあげれば解決。
(nginxのreloadって本当に便利)

44
31
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
44
31

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?