The equations that define the equilibrium of a homogeneous relativistic gas of neutrons, protons and electrons in a constant magnetic field are obtained. We compute the relative densities of the particles at equilibrium as function of the density of neutrons and the magnetic field. It is found that, when only the first Landau level is being filled, the proton density is enhanced as compared to the case without the magnetic field. For an ultrastrong field there exists the possibility that the proton density is greater than the neutron density. However, when higher Landau levels are being filled, the values of the particle density at equilibrium quickly converge to those obtained without the magnetic field.