title: Failed to load resource: net::ERR_CONNECTION_REFUSED for only selective images from instagram API
body: <p>I am currently making a <code>GET</code> request to the instagram API to get a bunch of photos with a particular tag, and returning the JSON object I get in Rails back to the caller in JS, and setting the HTML with the img links and thumbnails etc. in the DOM. </p>
  
  <p>What is weird is that, after restarting my server, I get this error: </p>
  
  <pre><code>Failed to load resource: net::ERR_CONNECTION_REFUSED 
  </code></pre>
  
  <p>for only some but not all of the photos which are returned by the instagram API. </p>
  
  <pre><code>  var formdata = {tag: "myflsadventure"};
   $.ajax({
      url: "application/get_instagram_photos",
      type: "POST",
      datatype: 'json',
      data: formdata,
      success: function(response){
       htmlz = "&lt;div class='container'&gt;&lt;div class='row'&gt;";
        count = 0;
        rounded_style = " style='border:1px solid #; -webkit-border-radius: 20px; -moz-border-radius: 20px; border-radius: 20px;'"
        $.each(response.data, function(i, item) {
          if (count == 0 ){
            htmlz += "&lt;div class='col-md-6'&gt;&lt;img src='"+item.images.standard_resolution.url+ "'" + rounded_style+"&gt;&lt;/div&gt;&lt;div class='col-md-6'&gt;&lt;div class='no-top'&gt;";
            count = count + 1;
          }
          else if (count == 9){
            htmlz += "&lt;/div&gt;&lt;div class='row'&gt;&lt;div class='col-md-6'&gt;&lt;div class='no-top'&gt;&lt;div class='row'&gt;&lt;div class='col-md-6'&gt;&lt;img src='" + item.images.low_resolution.url+ "'" + rounded_style + "&gt;&lt;/div&gt;";
            count = count + 1;
           }
          else if (count == 13){
            htmlz += "&lt;div class='col-md-6'&gt;&lt;img src='" + item.images.standard_resolution.url+ "'" + rounded_style + "&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;";
           count = count + 1;
           }
          else if (count ==5){
             htmlz += "&lt;/div&gt;&lt;div class='row'&gt;&lt;div class='col-md-3'&gt;&lt;img src='" +item.images.low_resolution.url+ "'" +rounded_style+ "&gt;&lt;/div&gt;";
            count = count + 1;
          }
           else if ((count == 4) || (count == 12)){
             htmlz += "&lt;div class='col-md-6'&gt;&lt;img src='"+item.images.low_resolution.url+ "'" + rounded_style +"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;";
             count = count + 1;
          }
          else if ((count == 6)  || (count == 7) || (count == 8)  ){
             htmlz += "&lt;div class='col-md-3'&gt;&lt;img src='"+ item.images.low_resolution.url+ "'" + rounded_style + "&gt;&lt;/div&gt;";
             count = count + 1;
           }
          else if ((count == 3) || (count == 11)){
             htmlz += "&lt;div class='top'&gt;&lt;div class='row'&gt;&lt;div class='col-md-6'&gt;&lt;img src='" + item.images.low_resolution.url + "'" + rounded_style + " &gt;&lt;/div&gt;";
             count = count + 1;
          }
           else if ( count == 1){
             htmlz += "&lt;div class='row'&gt;&lt;div class='col-md-6'&gt;&lt;img src='" + item.images.low_resolution.url + "'" + rounded_style + " &gt;&lt;/div&gt;";
             count = count + 1;
          }
          else{
             htmlz += "&lt;div class='col-md-6'&gt;&lt;img src='"+ item.images.low_resolution.url+ "'"+ rounded_style + "&gt;&lt;/div&gt;&lt;/div&gt;";
            count = count + 1;
          }
        });
         $("#myflsadventure").append(htmlz);
         reapportion_les_fotos();
      }
      });
  </code></pre>
  
  <p>Here is my Routes and finally my controller which makes the API call</p>
  
  <pre><code>  post '/application/get_instagram_photos', to: 'school_applications#get_instagram_photos'
  </code></pre>
  
  <p>Controller method</p>
  
  <pre><code>  def get_instagram_photos
  respond_to do |format|
    uri = URI("https://api.instagram.com/v1/tags/#{params[:tag]}/media/recent?client_id=myIDc&amp;count=14")
    response = Net::HTTP.get(uri)
    format.json {render :json =&gt; response}
  end
  </code></pre>
  
  <p>end</p>
  
  <p>UPDATE: </p>
  
  <p>This is only happening on my development machine. After pushing to Heroku and viewing from other computers, the photos load fine except for still on my main work machine. It seems browser independent (tried Opera, Firefox, Safari, and Chrome) and adblock independent (Tried it on Chrome incognito as per a suggestion found on a similar SO post).</p>