title: Error retrieving credentials from the instance profile metadata server
body: <p>I am attempting to upload file to s3 from a php script following a tutorial I found on YouTube</p>
  
  <p>I have the following php files</p>
  
  <p>upload.php
      
  
  <pre><code>use Aws\S3\Exception\S3Exception;
  
  require 'start.php';
  
  if(isset($_FILES['file'])){
      $file=$_FILES['file'];
  
      $name = $file['name'];
      $tmp_name = $file['tmp_name'];
  
      $file_ext = explode('.', $name);
      $file_ext = strtolower(end($file_ext));
  
      $key = md5(uniqid());
      $tmp_file_name = "{$key}.{$file_ext}";
      $tmp_file_path = "../files/{$tmp_file_name}";
  
      move_uploaded_file($tmp_name, $tmp_file_path);
      try{
          $s3 -&gt; putObject([
                  'Bucket' =&gt; $config['s3']['bucket'],
                  'Key' =&gt; 'uploads/{$key}.{$name}',
                  'Body' =&gt; fopen($tmp_file_path, 'rb'),
                  'ACL' =&gt; 'public-read'
  
          ]);
  
          unlink($tmp_file_path);
      }catch(S3Exception $e){
          die("Error uploading file");
      }
  
  
  }
  
  ?&gt;
  
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Upload&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;form action="upload.php" method="post" enctype="multipart/form-data"&gt;
              &lt;input type="file" name="file"&gt;
  
              &lt;input type="submit" value="Upload"&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Start.php</p>
  
   'latest',
              'region'  => 'us-east-1'
          ]);
      ?>
  
  <p>config.php</p>
  
  <pre><code>&lt;?php
  
  return [
      's3' =&gt; [
          'bucket' =&gt; 'umnbucket2016'
      ]
  ];
  ?&gt;
  </code></pre>
  
  <p>My file at ~/.aws/credentials contain a [default] and than my key and secret key</p>
  
  <p>When I attempt to upload a file I get the following error</p>
  
  <pre><code> Fatal error: Uncaught exception 'Aws\Exception\CredentialsException' with message 'Error retrieving credentials from the instance profile metadata server. (Error creating resource: [message] fopen(http://169.254.169.254/latest/meta-data/iam/security-credentials/): failed to open stream: Connection timed out [file] /var/www/html/AWS/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php [line] 282)' in /var/www/html/AWS/vendor/aws/aws-sdk-php/src/Credentials/InstanceProfileProvider.php:79 Stack trace: #0 /var/www/html/AWS/vendor/guzzlehttp/promises/src/Promise.php(199): Aws\Credentials\InstanceProfileProvider-&gt;Aws\Credentials\{closure}(Array) #1 /var/www/html/AWS/vendor/guzzlehttp/promises/src/Promise.php(152): GuzzleHttp\Promise\Promise::callHandler(2, Array, Array) #2 /var/www/html/AWS/vendor/guzzlehttp/promises/src/TaskQueue.php(60): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() #3 /var/www/html/AWS/vendor/guzzlehttp/promises/src/Promise.php(240): GuzzleHttp\Promise\TaskQueue-&gt;run(true) #4 /var/www/html/AWS in /var/www/html/AWS/vendor/aws/aws-sdk-php/src/Credentials/InstanceProfileProvider.php on line 79   
  </code></pre>
  
  <p>I originally had the config.php store my key and secret ID but changed that in favor of the credentials file</p>
  
  <p>Any help would be appreciated. </p>