We present constraints derived from a search of four years of IceCube data for a prompt neutrino flux from gamma-ray bursts (GRBs). A single low-significance neutrino, compatible with the atmospheric neutrino background, was found in coincidence with one of the 506 observed bursts. Although GRBs have been proposed as candidate sources for ultra-high-energy cosmic rays, our limits on the neutrino flux disfavor much of the parameter space for the latest models. We also find that no more than ∼1% of the recently observed astrophysical neutrino flux consists of prompt emission from GRBs that are potentially observable by existing satellites.