diff --git a/lib/private/request.php b/lib/private/request.php
index 619eae3e9b5c094ae31d88d0dc6ec44a84c46b01..5fd5b3a7197d2cd5fb336d48ca7ed5a29a5273a2 100755
--- a/lib/private/request.php
+++ b/lib/private/request.php
@@ -95,7 +95,7 @@ class OC_Request {
 	 * reverse proxies
 	 */
 	public static function serverHost() {
-		if(OC::$CLI) {
+		if (OC::$CLI && defined('PHPUNIT_RUN')) {
 			return 'localhost';
 		}