The Red Badge of Courage takes place during an unnamed battle during the Civil War. Crane deliberately never mentions the place, the date, or even the fact that the war is the one between the states. However, from "The Veteran," the sequel to Red Badge, we know that the Battle in question is actually the aforementioned Battle of Chancellorsville in Virginia in 1863. (You can read the sequel here.)
Now here’s something interesting for you to think about: some critics believe that the whole novel actually takes place in Henry’s mind. So he imagines fleeing the battle and then imagines himself becoming a hero at its conclusion. We talk quite a bit in this module about the fact that Henry’s biggest battle is in fact a psychological one – he’s dealing with various, conflicting standards (self-preservation, moral obligations, duty, the pursuit of glory) while trying to choose a single course of action. Because of this, it’s largely irrelevant whether the events described take place in the middle of the Civil War or in Henry’s mind, because both are essentially battlefields.