Assume is not compact then there exists a sequence with no accumulation points. Construct another sequence as follows such that where (we can guarantee that since is connected and so the singletons are not open). and have the same accum. points and so both are closed and disjoint but their distance is by construction.
For a counter-example take any infinite set with the discrete metric.