It is shown that if $G$ is an almost connected nilpotent group then the stable rank of $C^*(G)$ is equal to the rank of the abelian group $G/[G,G]$. For a general nilpotent locally compact group $G$, it is shown that finiteness of the rank of $G/[G,G]$ is necessary and sufficient for the finiteness of the stable rank of $C^*(G)$ and also for the finiteness of the real rank of $C^*(G)$.