Finding Port or Address of Your Application

As you send your application to the cloud, you may want to know what its running port/hostname/ip is, here is a quick guide:

  • The port is an environment variable called app_port (eg System.getenv(“app_port”)). 

  • The hostname can be obtained via the usual means (eg InetAddress.getLocalHost().getHostName())

  • The host name will be the private name - ie it will resolve to a private IP - good for node to node communication. 

  • Public IP/hostname: perform a HTTP get (from the server) to the following URL:http://instance-data/latest/meta-data/public-hostname (will only return the public IP on the server side of course). 

There is an API in the works that will provide cluster membership (allowing you to query for changes) which will hopefully be available shortly (this is handy for building things like akka clusters).