Galaxy clusters are the most massive gravitationally bound structures in the Universe. They grow by accreting smaller structures in a merging process that produces shocks and turbulence in the intracluster gas. We observed a ridge of radio emission connecting the merging galaxy clusters Abell 0399 and Abell 0401 with the Low-Frequency Array (LOFAR) telescope network at 140 megahertz. This emission requires a population of relativistic electrons and a magnetic field located in a filament between the two galaxy clusters. We performed simulations to show that a volume-filling distribution of weak shocks may reaccelerate a preexisting population of relativistic particles, producing emission at radio wavelengths that illuminates the magnetic ridge.