{"id":246,"date":"2015-06-14T19:22:22","date_gmt":"2015-06-15T01:22:22","guid":{"rendered":"http:\/\/www.n8williams.com\/devblog\/?p=246"},"modified":"2015-06-14T19:22:22","modified_gmt":"2015-06-15T01:22:22","slug":"tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx","status":"publish","type":"post","link":"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx","title":{"rendered":"TCP versus unix socket sock connection refused failure for php5 fpm and nginx"},"content":{"rendered":"<p><code>[error] 13169#0: *7 connect() failed (111: Connection refused) while connecting to upstream, client: XXX.XXX.XXX.XXX, server: test.local, request: &quot;GET \/index.php HTTP\/1.1&quot;, upstream: &quot;fastcgi:\/\/127.0.0.1:9000&quot;, host: &quot;test.local&quot;<\/code><\/p>\n<p>When setting up nginx to work with php-fpm on ubuntu 14.04, this happened when I was using some config templates from a bit older server. It seems to result from nginx being configured to listen with a socket connection versus TCP, and the virtual host being configured to listen with TCP. The fix was somewhat intuitive, but I never would have thought to look in <code>\/etc\/php5\/fpm\/pool.d\/www.conf<\/code>.<\/p>\n<p>The fix for me: In <code>\/etc\/php5\/fpm\/pool.d\/www.conf<\/code>, change<br \/>\n<code>listen = \/var\/run\/php5-fpm.sock<\/code><br \/>\nTO<br \/>\n<code>listen = 127.0.0.1:9000<\/code> <\/p>\n<p>This should match the php line in your <code>\/etc\/nginx\/sites-enabled\/WHATEVERCONFIG<\/code>. Mine uses TCP with the line<br \/>\n<code>fastcgi_pass 127.0.0.1:9000;<\/code><br \/>\nas opposed to<br \/>\n<code>fastcgi_pass unix:\/var\/run\/php5-fpm.sock;<\/code><\/p>\n<p><a href=\"http:\/\/stackoverflow.com\/questions\/15852884\/nginx-connect-failed-error\">http:\/\/stackoverflow.com\/questions\/15852884\/nginx-connect-failed-error<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[error] 13169#0: *7 connect() failed (111: Connection refused) while connecting to upstream, client: XXX.XXX.XXX.XXX, server: test.local, request: &quot;GET \/index.php HTTP\/1.1&quot;, upstream: &quot;fastcgi:\/\/127.0.0.1:9000&quot;, host: &quot;test.local&quot; When setting up nginx to work with php-fpm on ubuntu 14.04, this happened when I was using some config templates from a bit older server. It seems to result from nginx &hellip; <a href=\"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;TCP versus unix socket sock connection refused failure for php5 fpm and nginx&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8,13],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.11 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>TCP versus unix socket sock connection refused failure for php5 fpm and nginx - The Dev Pages<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"TCP versus unix socket sock connection refused failure for php5 fpm and nginx - The Dev Pages\" \/>\n<meta property=\"og:description\" content=\"[error] 13169#0: *7 connect() failed (111: Connection refused) while connecting to upstream, client: XXX.XXX.XXX.XXX, server: test.local, request: &quot;GET \/index.php HTTP\/1.1&quot;, upstream: &quot;fastcgi:\/\/127.0.0.1:9000&quot;, host: &quot;test.local&quot; When setting up nginx to work with php-fpm on ubuntu 14.04, this happened when I was using some config templates from a bit older server. It seems to result from nginx &hellip; Continue reading &quot;TCP versus unix socket sock connection refused failure for php5 fpm and nginx&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx\" \/>\n<meta property=\"og:site_name\" content=\"The Dev Pages\" \/>\n<meta property=\"article:published_time\" content=\"2015-06-15T01:22:22+00:00\" \/>\n<meta name=\"author\" content=\"Nate Admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@admin\" \/>\n<meta name=\"twitter:site\" content=\"@admin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nate Admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx#article\",\"isPartOf\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx\"},\"author\":{\"name\":\"Nate Admin\",\"@id\":\"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757\"},\"headline\":\"TCP versus unix socket sock connection refused failure for php5 fpm and nginx\",\"datePublished\":\"2015-06-15T01:22:22+00:00\",\"dateModified\":\"2015-06-15T01:22:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx\"},\"wordCount\":106,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757\"},\"articleSection\":[\"PHP\",\"Ubuntu\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx\",\"url\":\"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx\",\"name\":\"TCP versus unix socket sock connection refused failure for php5 fpm and nginx - The Dev Pages\",\"isPartOf\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/#website\"},\"datePublished\":\"2015-06-15T01:22:22+00:00\",\"dateModified\":\"2015-06-15T01:22:22+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/n8williams.com\/devblog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"TCP versus unix socket sock connection refused failure for php5 fpm and nginx\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/n8williams.com\/devblog\/#website\",\"url\":\"https:\/\/n8williams.com\/devblog\/\",\"name\":\"The Dev Pages\",\"description\":\"A knowledge base for web applications development (and beyond)\",\"publisher\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/n8williams.com\/devblog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757\",\"name\":\"Nate Admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/19d7bc7602072ac846e912622704a628?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/19d7bc7602072ac846e912622704a628?s=96&d=mm&r=g\",\"caption\":\"Nate Admin\"},\"logo\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/n8williams.com\",\"https:\/\/twitter.com\/admin\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"TCP versus unix socket sock connection refused failure for php5 fpm and nginx - The Dev Pages","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx","og_locale":"en_US","og_type":"article","og_title":"TCP versus unix socket sock connection refused failure for php5 fpm and nginx - The Dev Pages","og_description":"[error] 13169#0: *7 connect() failed (111: Connection refused) while connecting to upstream, client: XXX.XXX.XXX.XXX, server: test.local, request: &quot;GET \/index.php HTTP\/1.1&quot;, upstream: &quot;fastcgi:\/\/127.0.0.1:9000&quot;, host: &quot;test.local&quot; When setting up nginx to work with php-fpm on ubuntu 14.04, this happened when I was using some config templates from a bit older server. It seems to result from nginx &hellip; Continue reading \"TCP versus unix socket sock connection refused failure for php5 fpm and nginx\"","og_url":"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx","og_site_name":"The Dev Pages","article_published_time":"2015-06-15T01:22:22+00:00","author":"Nate Admin","twitter_card":"summary_large_image","twitter_creator":"@admin","twitter_site":"@admin","twitter_misc":{"Written by":"Nate Admin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx#article","isPartOf":{"@id":"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx"},"author":{"name":"Nate Admin","@id":"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757"},"headline":"TCP versus unix socket sock connection refused failure for php5 fpm and nginx","datePublished":"2015-06-15T01:22:22+00:00","dateModified":"2015-06-15T01:22:22+00:00","mainEntityOfPage":{"@id":"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx"},"wordCount":106,"commentCount":0,"publisher":{"@id":"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757"},"articleSection":["PHP","Ubuntu"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx#respond"]}]},{"@type":"WebPage","@id":"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx","url":"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx","name":"TCP versus unix socket sock connection refused failure for php5 fpm and nginx - The Dev Pages","isPartOf":{"@id":"https:\/\/n8williams.com\/devblog\/#website"},"datePublished":"2015-06-15T01:22:22+00:00","dateModified":"2015-06-15T01:22:22+00:00","breadcrumb":{"@id":"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/n8williams.com\/devblog\/php\/tcp-versus-unix-socket-sock-connection-refused-failure-for-php5-fpm-and-nginx#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/n8williams.com\/devblog\/"},{"@type":"ListItem","position":2,"name":"TCP versus unix socket sock connection refused failure for php5 fpm and nginx"}]},{"@type":"WebSite","@id":"https:\/\/n8williams.com\/devblog\/#website","url":"https:\/\/n8williams.com\/devblog\/","name":"The Dev Pages","description":"A knowledge base for web applications development (and beyond)","publisher":{"@id":"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/n8williams.com\/devblog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757","name":"Nate Admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/19d7bc7602072ac846e912622704a628?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/19d7bc7602072ac846e912622704a628?s=96&d=mm&r=g","caption":"Nate Admin"},"logo":{"@id":"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/n8williams.com","https:\/\/twitter.com\/admin"]}]}},"_links":{"self":[{"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/posts\/246"}],"collection":[{"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/comments?post=246"}],"version-history":[{"count":4,"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/posts\/246\/revisions"}],"predecessor-version":[{"id":250,"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/posts\/246\/revisions\/250"}],"wp:attachment":[{"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/media?parent=246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/categories?post=246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/tags?post=246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}