{"id":1780,"date":"2017-12-16T16:51:50","date_gmt":"2017-12-17T00:51:50","guid":{"rendered":"https:\/\/www.cloudinsidr.com\/content\/?p=1780"},"modified":"2018-11-29T16:19:35","modified_gmt":"2018-11-30T00:19:35","slug":"heres-fix-nginx-error-failed-read-pid-file-linux","status":"publish","type":"post","link":"https:\/\/www.cloudinsidr.com\/content\/heres-fix-nginx-error-failed-read-pid-file-linux\/","title":{"rendered":"How to fix the NGINX error &#8220;Failed to read PID from file&#8221;, quick and easy"},"content":{"rendered":"<p>Here&#8217;s a tip on how to fix the error message:<\/p>\n<pre>nginx.service: Failed to read PID from file \/run\/nginx.pid: Invalid argument<\/pre>\n<p>quick and easy. This fix should do it for you.<\/p>\n<p><!--more--><\/p>\n<p>This behavior is a known bug, caused by a race condition between\u00a0nginx and systemd. Systemd is expecting the PID file to be populated before nginx had the time to create it.<\/p>\n<p>To fix the error, you have basically two options.<\/p>\n<h3>Option 1: create the PID file<\/h3>\n<p>To fix the error, you have to create the PID file manually.<\/p>\n<h4>Step 1. Create the directory\u00a0\/etc\/systemd\/system\/nginx.service.d<\/h4>\n<p>Create a directory named nginx.service.d in \/etc\/systemd\/system\/:<\/p>\n<pre>mkdir \/etc\/systemd\/system\/nginx.service.d<\/pre>\n<p>Should the system complain that it already exists, ignore and\u00a0 move on to Step 2.<\/p>\n<h4>Step 2.\u00a0Print data to file<\/h4>\n<p>Execute:<\/p>\n<pre>printf \"[Service]\\nExecStartPost=\/bin\/sleep 0.1\\n\" &gt; \/etc\/systemd\/system\/nginx.service.d\/override.conf<\/pre>\n<p>This is a one-liner. printf will write its output into the configuration file \/etc\/systemd\/<wbr \/>system\/<wbr \/>nginx.service.<wbr \/>d\/override.<wbr \/>conf.<\/p>\n<h4>Step 3. Reload the daemon<\/h4>\n<p>Reload systemd manager configuration:<\/p>\n<pre>systemctl daemon-reload<\/pre>\n<p>This will rerun all generators, reload all unit files and recreate the entire systemd dependency tree.<\/p>\n<h4>Step 4. Restart NGINX<\/h4>\n<p>This line will restart NGINX for you:<\/p>\n<pre>systemctl restart nginx<\/pre>\n<p>The error should be fixed now.<\/p>\n<h3>Option 2: an alternative workaround<\/h3>\n<p>Another workaround is\u00a0removing the PIDFile option and adding the line:<\/p>\n<pre>ExecStopPost=<wbr \/>\/bin\/rm -f \/run\/nginx.pid<\/pre>\n<p>&nbsp;<\/p>\n<p>You can find the full documentation of this bug at:<\/p>\n<pre>https:\/\/bugs.launchpad.net\/ubuntu\/+source\/nginx\/+bug\/1581864<\/pre>\n<pre><\/pre>\n<p>If you experience this problem, SELinux could be preventing php-fpm from accessing a port. Just a hint. Try<\/p>\n<pre>journalctl -xe<\/pre>\n<p>for guidance on your next steps.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a tip on how to fix the error message: nginx.service: Failed to read PID from file \/run\/nginx.pid: Invalid argument quick and easy. This fix should do it for you.<\/p>\n","protected":false},"author":1,"featured_media":76,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[109],"tags":[7,215],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to fix the NGINX error &quot;Failed to read PID from file&quot;, quick and easy - CloudInsidr<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.cloudinsidr.com\/content\/heres-fix-nginx-error-failed-read-pid-file-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to fix the NGINX error &quot;Failed to read PID from file&quot;, quick and easy - CloudInsidr\" \/>\n<meta property=\"og:description\" content=\"Here&#8217;s a tip on how to fix the error message: nginx.service: Failed to read PID from file \/run\/nginx.pid: Invalid argument quick and easy. This fix should do it for you.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.cloudinsidr.com\/content\/heres-fix-nginx-error-failed-read-pid-file-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"CloudInsidr\" \/>\n<meta property=\"article:published_time\" content=\"2017-12-17T00:51:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-11-30T00:19:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2015\/11\/cloudinsidr_logo_900px-wide.png\" \/>\n\t<meta property=\"og:image:width\" content=\"900\" \/>\n\t<meta property=\"og:image:height\" content=\"326\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#website\",\"url\":\"https:\/\/www.cloudinsidr.com\/content\/\",\"name\":\"CloudInsidr\",\"description\":\"Cyber security, infotech\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.cloudinsidr.com\/content\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/heres-fix-nginx-error-failed-read-pid-file-linux\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2015\/11\/cloudinsidr_logo_900px-wide.png\",\"width\":900,\"height\":326,\"caption\":\"cloudinsidr.com logo (900px wide)\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/heres-fix-nginx-error-failed-read-pid-file-linux\/#webpage\",\"url\":\"https:\/\/www.cloudinsidr.com\/content\/heres-fix-nginx-error-failed-read-pid-file-linux\/\",\"name\":\"How to fix the NGINX error \\\"Failed to read PID from file\\\", quick and easy - CloudInsidr\",\"isPartOf\":{\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/heres-fix-nginx-error-failed-read-pid-file-linux\/#primaryimage\"},\"datePublished\":\"2017-12-17T00:51:50+00:00\",\"dateModified\":\"2018-11-30T00:19:35+00:00\",\"author\":{\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#\/schema\/person\/dd6ee9cb21cf05763fd7cff3d6f11b2b\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.cloudinsidr.com\/content\/heres-fix-nginx-error-failed-read-pid-file-linux\/\"]}]},{\"@type\":[\"Person\"],\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#\/schema\/person\/dd6ee9cb21cf05763fd7cff3d6f11b2b\",\"name\":\"Cloud Insidr\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8b2fa1415b3d573b97d818b8f8f83b7c?s=96&d=mm&r=g\",\"caption\":\"Cloud Insidr\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/posts\/1780"}],"collection":[{"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/comments?post=1780"}],"version-history":[{"count":7,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/posts\/1780\/revisions"}],"predecessor-version":[{"id":2433,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/posts\/1780\/revisions\/2433"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/media\/76"}],"wp:attachment":[{"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/media?parent=1780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/categories?post=1780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/tags?post=1780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}