6. Let $n$ be a positive integer, and call $n$ a "good number" if the number of prime numbers not exceeding $n$ equals the number of composite numbers not exceeding $n$. Then the sum of all good numbers is ( ).
(A) 33
(B) 34
(C) 2013
(D) 2014
6. B.

Since 1 is neither a prime number nor a composite number, a good number must be an odd number.

Let the number of prime numbers not exceeding $n$ be $a_{n}$, and the number of composite numbers be $b_{n}$. When $n \leqslant 15$, only consider the case where $n$ is odd (as shown in Table 1).
Table 1
\begin{tabular}{|l|l|l|l|l|l|l|l|l|}
\hline$n$ & 1 & 3 & 5 & 7 & 9 & 11 & 13 & 15 \\
\hline$a_{n}$ & 0 & 2 & 3 & 4 & 4 & 5 & 6 & 6 \\
\hline$b_{n}$ & 0 & 0 & 1 & 2 & 4 & 5 & 6 & 8 \\
\hline
\end{tabular}

Obviously, 1, 9, 11, and 13 are good numbers.
Since $b_{15}-a_{15}=2$, when $n \geqslant 16$, based on $n=15$, every two numbers added must include one even number, which is a composite number. This means that the number of composite numbers added will not be less than the number of prime numbers added, so there must be $b_{n}-a_{n} \geqslant 2$.
Therefore, when $n \geqslant 16$, $n$ cannot be a good number.
Thus, the sum of all good numbers is
$$
1+9+11+13=34 \text {. }
$$