diff --git a/lib/private/Setup.php b/lib/private/Setup.php
index 521a8f75f8e321a0d0e86ebcdd08f21c2151ae77..6cef1eb861d15f2d416e5876596a0728cca1a20a 100644
--- a/lib/private/Setup.php
+++ b/lib/private/Setup.php
@@ -293,6 +293,10 @@ class Setup {
 			$error[] = $l->t("Can't create or write into the data directory %s", array($dataDir));
 		}
 
+		if (!$this->validateDatabaseHost($options['dbhost'])) {
+			$error[] = $l->t('Given database host is invalid and must not contain the port: %s', [$options['dbhost']]);
+		}
+
 		if(count($error) != 0) {
 			return $error;
 		}
@@ -410,6 +414,18 @@ class Setup {
 		return $error;
 	}
 
+	/**
+	 * @param string $host
+	 * @return bool
+	 */
+	protected function validateDatabaseHost($host) {
+		if (strpos($host, ':') === false) {
+			return true;
+		}
+
+		return filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false;
+	}
+
 	public static function installBackgroundJobs() {
 		\OC::$server->getJobList()->add('\OC\Authentication\Token\DefaultTokenCleanupJob');
 	}