Let H p (D) be the Hardy space of all holomorphic functions on the unit disk D with exponent p > 0. If D = C is a simply connected domain and f is the Riemann mapping from D onto D, then the Hardy number of D, introduced by Hansen, is the supremum of all p for which f ∈ H p (D). Comb domains are a well-studied class of simply connected domains that, in general, have the form of the entire plane minus an infinite number of vertical rays. In this paper we study the Hardy number of a class of comb domains with the aid of the quasi-hyperbolic distance and we establish a necessary and sufficient condition for the Hardy number of these domains to be equal to infinity. Applying this condition, we derive several results that show how the mutual distances and the distribution of the rays affect the finiteness of the Hardy number. By a result of Burkholder our condition is also necessary and sufficient for all moments of the exit time of Brownian motion from comb domains to be infinite.