How do I see responses from my app as sent to Heroku router?

Issue

Heroku router records unexpected errors like H17 - Poorly formatted HTTP response for my app. I want to know what is wrong.

Resolution

It is possible to run the app and send requests to the app on a single one-off dyno.

  1. Establish a bash session on a one-off dyno for the app: heroku run bash -a <app-name>,
  2. Run the web server for the app on the one-off dyno with the command defined in the Procfile for web dynos, e.g., bundle exec rails server,
  3. Send the web server to the background on the bash session with typing Ctrl-z and running the bg command, and
  4. Send a request to the web server with the curl command from the same bash session on the one-off dyno, e.g., curl -i http://localhost:$PORT. Depending upon how the app is configured, it may be necessary to add, e.g., the X-Forwarded-Proto: https request header, to mimic that the request came through HTTPS: curl -i -H 'X-Forwarded-Proto: https' http://localhost:$PORT. Then,
  5. Inspect the response header printed by the curl command.

If it is necessary to send other request headers as browsers do, it is possible to start with "Copy" the request "as cURL" from the Network tab in the developer tools on your browser, replace the scheme and host parts of the URL with http://localhost:$PORT and adding, e.g., the X-Forwarded-For request header with adding the command line option -H 'X-Forwarded-Proto: https'. Please be careful not to leak sensitive information like session tokens.

When done, terminate the one-off dyno with exiting from the bash session.

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support