diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index fb3fc55a94c2813a69b454d046551fd8cbd88dd1..81511ac55596a0d690cfc7a4e5e46ab73de94606 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -1195,6 +1195,16 @@ class LLEstablishAgentCommunication : public LLHTTPNode
 	virtual void post(ResponsePtr response, const LLSD& context, const LLSD& input) const
 	{
         if (LLApp::isExiting())
+        {
+            return;
+        }
+
+        if (gDisconnected)
+        {
+            return;
+        }
+
+        if (!LLWorld::instanceExists())
         {
             return;
         }
@@ -1207,8 +1217,13 @@ class LLEstablishAgentCommunication : public LLHTTPNode
             return;
 		}
 
-		LLHost sim(input["body"]["sim-ip-and-port"].asString());
-	
+        LLHost sim(input["body"]["sim-ip-and-port"].asString());
+        if (sim.isInvalid())
+        {
+            LL_WARNS() << "Got EstablishAgentCommunication with invalid host" << LL_ENDL;
+            return;
+        }
+
 		LLViewerRegion* regionp = LLWorld::getInstance()->getRegion(sim);
 		if (!regionp)
 		{
@@ -1217,7 +1232,7 @@ class LLEstablishAgentCommunication : public LLHTTPNode
 			return;
 		}
 		LL_DEBUGS("CrossingCaps") << "Calling setSeedCapability from LLEstablishAgentCommunication::post. Seed cap == "
-				<< input["body"]["seed-capability"] << LL_ENDL;
+				<< input["body"]["seed-capability"] << " for region " << regionp->getRegionID() << LL_ENDL;
 		regionp->setSeedCapability(input["body"]["seed-capability"]);
 	}
 };