Heroku Request

I am attempting to grab some information off of a Heroku app I set up, however I am hit with Heroku's 404 page. I tested a similar request with a simple Python script, which worked fine.

The Arduino Code:

if (!client.connected()) {
    if (client.connect(serverName, 80)) {
      // Make a HTTP request
      client.println("GET / HTTP/1.0");
      while (!client.available());
      // If data can be read from te server, print it
      while (client.available()) {
        char c = client.read();
    } else {
      // If you didn't get a connection to the server:
      Serial.println("connection failed");

For the record, as this is different from the example, you may question whether the altered algorithm works. It does, the exact same thing sending a request to Google works fine.

Python Code:

import httplib

h = httplib.HTTPConnection("ruby-coffee-maker.herokuapp.com")

h.request("GET", "/")

r = h.getresponse()
data = r.read()

print r.status, r.reason, "\"" + data + "\""


Thanks in advance for any help!

It is necessary to send a Host header so Heroku knows which app to route your request to:

From http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html:

       GET /pub/WWW/ HTTP/1.1
       Host: www.w3.org


      client.println("GET / HTTP/1.0");

You are asking for an unnamed script at the root of the unnamed server to be executed.

Without knowing what server you are pointing the request to, all we can surmise is that you are doing it wrong.

@billroy: I tried replacing "GET /" with "GET /pub/WWW/", to no avail. Also, Heroku does not support HTTP 1.1.

@PaulS: My bad, I left that bit out. Here you are:

char serverName[] = "ruby-coffee-maker.herokuapp.com";

I was a bit concerned that "-" was an illegal character, but changing it on the server side to not have hyphens yielded a net gain of nada.

  1. That was an example from the link I provided. It is necessary to adapt it to your code.

  2. You need a Host: header. Did you try that?


@billroy: I tried a few Host: headers, which still yielded 404s. What would the header code look like for this case?

Did you consider trying the Heroku application hostname you are attempting to connect to?


@ billroy: I tried it to no avail.