diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionOptions.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionOptions.java index 66ac70994f2..6e991816ab6 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionOptions.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionOptions.java @@ -1005,7 +1005,7 @@ static String determineHost( // The leading '//' is already included in the regex for the connection URL, so we don't need // to add the leading '//' to the host name here. host = matcher.group(Builder.HOST_GROUP); - if (ConnectionOptions.Builder.EXTERNAL_HOST_FORMAT.equals(matcher.pattern().pattern()) + if (Builder.EXTERNAL_HOST_FORMAT.equals(matcher.pattern().pattern()) && !host.matches(".*:\\d+$")) { host = String.format("%s:15000", host); }