title: Hadoop2- YARN - ApplicationMaster UI - Connection refused issue
body: <p>I'm getting below issue while accessing ApplicationMaster UI from the RM WebUI (hadoop 2.6.0). There is no standalone WebProxy server running. The Proxy is running as a part of ResourceManager.  </p>
  
  <pre>
  "HTTP ERROR 500
  Problem accessing /proxy/application_1431357703844_0004/. Reason:
      Connection refused"
  </pre>
  
  <p>Log entries in resourcemanager logs:</p>
  
  <pre>
  2015-05-11 19:25:01,837 INFO  webproxy.WebAppProxyServlet (WebAppProxyServlet.java:doGet(330)) - ubuntu is accessing unchecked http://slave1:51704/ which is the app master GUI of application_1431357703844_0004 owned by ubuntu
  2015-05-11 19:25:01,845 WARN  mortbay.log (Slf4jLog.java:warn(76)) - /proxy/application_1431357703844_0004/: java.net.ConnectException: Connection refused
  </pre>
  
  <p>When I do wget of the AppMaster Url from RM, below is the output</p>
  
  <pre>
  ubuntu@resource-manager:/mnt/logs/yarn$ wget -O- "http://slave1:51704/"
  --2015-05-11 19:26:47--  http://slave1:51704/
  HTTP request sent, awaiting response... 302 Found
  Location: http://slave1:51704/mapreduce [following]
  --2015-05-11 19:26:47--  http://slave1:51704/mapreduce
  HTTP request sent, awaiting response... 302 Found
  Location: http://slave1:8088/proxy/application_1431357703844_0004/mapreduce [following]
  --2015-05-11 19:26:47--  http://slave1:8088/proxy/application_1431357703844_0004/mapreduce
  Connecting to slave1|:8088... failed: Connection refused.
  </pre>
  
  <p>When i do wget of same AppMaster URL from the node where appMaster is running, I got 200 response.</p>
  
  <pre>
  ubuntu@slave1:~$ wget -O- http://slave1:51704/
  --2015-05-11 19:31:13--  http://slave1:51704/
  Connecting to slave1|:51704... connected.
  HTTP request sent, awaiting response... 302 Found
  Location: http://slave1:51704/mapreduce [following]
  --2015-05-11 19:31:13--  http://slave1:51704/mapreduce
  HTTP request sent, awaiting response... 200 OK
  Length: 6846 (6.7K) [text/html]
  </pre>
  
  <p>The main difference to note here is, when the request was made from RM, the nodemanager redirected to a different URL  "<a href="http://slave1:8088/proxy/application_1431357703844_0004/mapreduce" rel="nofollow">http://slave1:8088/proxy/application_1431357703844_0004/mapreduce</a>" which resulted in "Connection refused". But when the request was made from where NM was running, it didn't redirect to above URL, but resulted in 200 response.</p>
  
  <p>Please help me understand the differential behaviour of redirection and resolve the issue. </p>