diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php
index fdda19ff700fe21e994b220bec8d340511d05193..927d93689c79e4be3f3c7dd8008b481f974490f7 100644
--- a/lib/private/Files/ObjectStore/S3ConnectionTrait.php
+++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php
@@ -90,8 +90,8 @@ trait S3ConnectionTrait {
 		}
 		$this->connection = new S3Client($options);
 
-		if (!S3Client::isBucketDnsCompatible($this->bucket)) {
-			throw new \Exception("The configured bucket name is invalid.");
+		if (!$this->connection->isBucketDnsCompatible($this->bucket)) {
+			throw new \Exception("The configured bucket name is invalid: " . $this->bucket);
 		}
 
 		if (!$this->connection->doesBucketExist($this->bucket)) {