0

I'm trying to get the host name of the for the machine I am running on in Heroku. What i want to get is something like this: https://gentle-hollows-7643-243.com

What I am using right now is the getCannoncialHostName inside of the InetAddress class. This is giving me a value like this:

String hostName = java.net.InetAddress.getLocalHost.getCannonicalHostName
//returns the following
//be24dfaf-671d-4c37-8468-e1826ea26507.prvt.dyno.rt.heroku.com

This is not what I am expecting to receive, which is https://gentle-hollows-7643-243.com

Am I misunderstanding the intent for getCannonicalHostName or is this working incorrectly because the Heroku architecture?

Chris Stewart
  • 1,641
  • 2
  • 28
  • 60

2 Answers2

1

I don't think you'll be able to get what you're after. The Heroku dyno runs behind a proxy that routes traffic to it. So the actual host name for the process is not the one you'd use from a browser. Another possible solution is to set a config var like APP_NAME to "gentle-hollows-7643-243" and then use that in your app like System.getenv("APP_NAME");

codefinger
  • 10,088
  • 7
  • 39
  • 51
0

Please have a look at this

getCanonicalName() method will return fully qualified domain name

Host Name Vs Canonical Host Name

Community
  • 1
  • 1
sathya_dev
  • 513
  • 3
  • 15