Crewe goalkeeper Steve Phillips denied Andy Bond before Crewe took the lead midway through the first half.
Skipper Luke Murphy slotted in from the spot after referee Keith Hill had ruled that U's substitute Josh Thompson had handled Gregor Robertson's cross in the penalty area.
Max Clayton then fired straight at Colchester goalkeeper Sam Walker, before the introduction of substitute Michael Smith got the U's back in the game.
Gavin Massey and Billy Clifford went close, before Murphy nodded Magnus Okuonghae's powerful header off the goalline.
Colchester equalised three minutes before the break through George Porter, who controlled well before slotting into the net, following good play by Smith.
Phillips saved Thompson's header in the opening stages of the second half and Smith scooped a first-time effort from Porter's ball in over the crossbar.
But Crewe grabbed their winner with 18 minutes to go through Mathias Pogba, who drove in from close range after Murphy had picked him out in the area.