title: 404 Not Found nginx/1.12.2 - in foreach with File_get_contents
body: <p>I've tried in several ways and still can not solve. I have an array with many urls, I use foreach to access the site and extract data with <code>file_get_contents()</code></p>
  
  <p>But <code>404 Not Found nginx/1.12.2</code> is the error that appears after approximately 2 minutes and registering approximately 280 records. </p>
  
  <p>In addition to trying to execute <code>max_execution_time</code> and <code>mysql.connect_timeout</code> by inserting in the code also changing in the <code>ini.php</code> the value of <code>0</code> or <code>1200</code>, the result is always the same, after 2 minutes it displays the error <code>404 Not Found nginx / 1.12.2</code></p>
  
  <p>in the code I tried to use <code>set_time_limit (0);</code> and <code>sleep (1)</code> but it is not solving the problem either</p>
  
  <pre><code>ini_set('mysql.connect_timeout','0');   
  ini_set('max_execution_time', '0');   
  
  function create_wordpress_post_with_code() {
  
      if( isset( $_POST['mysubmitbtn'] ) ) {
          set_time_limit(0);
  
          $myGetCsv = function ($str) {
              return str_getcsv($str, ';');
          };
  
          $lines = array_map($myGetCsv, file(''.get_template_directory_uri() . '/list.csv', FILE_IGNORE_NEW_LINES));    
  
          foreach($lines as list($var1, $var2)){
  
              set_time_limit(0);  
  
          $html = file_get_contents( 'https://example.com/'.$var1.'/'.$var2' ); 
          $document = new DOMDocument();              
          @$document-&gt;loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
          $domxpath = new DOMXPath($document);
  
           // more code here
  
                  $post_id = wp_insert_post(
                              array(
                                  'comment_status'    =&gt;   'open',
                                  'ping_status'       =&gt;   'closed',
                                  'post_author'       =&gt;   $author_id,
                                  'post_name'         =&gt;   $slug,
                                  'post_title'        =&gt;   $title,
                                  'post_content'      =&gt;   $content,
                                  'post_status'       =&gt;   'publish',
                                  'post_type'         =&gt;   'post'
                              )
                          );
           sleep(1);
  
          }
  
      }
  
  
  } 
  add_action( 'init', 'create_wordpress_post_with_code' );
  </code></pre>
  
  <p>What can I do to resolve this error? Or what are the probable reasons that this error is happening besides possibly because of the execution time?</p>