Connecting to reddit

Has anyone tried to connect to reddit via the Ethernet Shield? I’ve been having no luck.
Here’s my code:

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x30, 0x57 };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(198,41,209,140);  // numeric IP for Google (no DNS)
char server[] = "";    // name address for Google (using DNS)

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192,168,0,177);

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup() {
 // Open serial communications and wait for port to open:

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  // give the Ethernet shield a second to initialize:

  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    // Make a HTTP request:
    client.println("GET /api/multi/all");
  else {
    // kf you didn't get a connection to the server:
    Serial.println("connection failed");

void loop()
  // if there are incoming bytes available
  // from the server, read them and print them:
  if (client.available()) {
    char c =;

  // if the server's disconnected, stop the client:
  if (!client.connected()) {

    // do nothing forevermore:

THis is what the Arduino returns:

<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en-US"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en-US"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->
<title>Direct IP access not allowed | 11f11 | CloudFlare</title></title>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" />
<link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/cf.errors.css" type="text/css" media="screen,projection" />
<!--[if lt IE 9]><link rel="stylesheet" id='cf_styles-ie-css' href="/cdn-cgi/styles/" type="text/css" media="screen,projection" /><![endif]-->
<style type="text/css">body{margin:0;padding:0}</style>
<!--[if lte IE 9]><script type="text/javascript" src="/cdn-cgi/scripts/jquery.min.js"></script><![endif]-->
<!--[if gte IE 10]><!--><script type="text/javascript" src="/cdn-cgi/scripts/zepto.min.js"></script><!--<![endif]-->
<script type="text/javascript" src="/cdn-cgi/scripts/cf.common.js"></script>

  <div id="cf-wrapper">
    <div class="cf-alert cf-alert-error cf-cookie-error" id="cookie-alert" data-translate="enable_cookies">Please enable cookies.</div>
    <div id="cf-error-details" class="cf-error-details-wrapper">
      <div class="cf-wrapper cf-header cf-error-overview">
          <span class="cf-error-type" data-translate="error">Error</span>
          <span class="cf-error-code">1003</span>
          <small class="heading-ray-id">Ray ID: 1a2a91d2085a040c</small>
        <h2 class="cf-subheadline" data-translate="error_desc">Direct IP access not allowed</h2>
      </div><!-- /.header -->

      <section></section><!-- spacer -->

      <div class="cf-section cf-wrapper">
        <div class="cf-columns two">
          <div class="cf-column">
            <h2 data-translate="what_happened">What happened?</h2>
            <p>You've requested an IP address that is part of the <a data-orig-proto="https" data-orig-ref="" target="_blank">CloudFlare</a> network.</p>

          <div class="cf-column">
            <h2 data-translate="what_can_i_do">What can I do?</h2>
            <p>If you are interested in learning more about CloudFlare, please <a data-orig-proto="https" data-orig-ref="" target="_blank">visit our website</a>.</p>
      </div><!-- /.section -->

      <div class="cf-error-footer cf-wrapper">
    <span class="cf-footer-item">CloudFlare Ray ID: <strong>1a2a91d2085a040c</strong></span>
    <span class="cf-footer-separator">&bull;</span>
    <span class="cf-footer-item"><span data-translate="your_ip">Your IP</span>:</span>
    <span class="cf-footer-separator">&bull;</span>
    <span class="cf-footer-item"><span data-translate="performance_security_by">Performance &amp; security by</span> <a data-orig-proto="https" data-orig-ref="" id="brand_link" target="_blank">CloudFlare</a></span>
</div><!-- /.error-footer -->

    </div><!-- /#cf-error-details -->
  </div><!-- /#cf-wrapper -->

  <script type="text/javascript">
  window._cf_translation = {};



Anybody know why CloudFlare isn’t letting me connect?

I was struggling with this for awhile but finally figured it out. I assume we're both trying to build some IoT devices that connect to reddit.

Basically, Reddit's hosting company, CloudFare, does not allow direct IP access (something about anycast or whatever). You have to convince the server that you're trying to reach or rather than

The trick is in how your HTTP headers are set up. In your code, you just connect to the server and

client.println("GET /api/multi/all");

Now, if you were to curl reddit, that's not what your computer is using:

curl --verbose
* About to connect() to port 80 (#0)
*   Trying
* Connected to ( port 80 (#0)
> GET /test/ HTTP/1.1
> User-Agent: curl/7.29.0
> Host:
> Accept: */*

You'll want to use HTTP headers like this...

client.println("GET /api/multi/all HTTP/1.1\r\nHost:\r\nAccept: */*");

..Or end the url with .json and accept application/json if that's what you're looking for