Context : HD 54879 ( O9.7 V ) is one of a dozen O-stars for which an organized atmospheric magnetic field has been detected . Despite their importance , little is known about the winds and evolution of magnetized massive stars . Aims : To gain insights into the interplay between atmospheres , winds , and magnetic fields of massive stars , we acquired UV and X-ray data of HD 54879 using the Hubble Space Telescope and the XMM-Newton satellite . In addition , 35 optical amateur spectra were secured to study the variability of HD 54879 . Methods : A multiwavelength ( X-ray to optical ) spectral analysis is performed using the Potsdam Wolf-Rayet ( PoWR ) model atmosphere code and the xspec software . Results : The photospheric parameters ( T _ { * } = 30.5 kK , \log g = 4.0 [ cm { s } ^ { -2 } ] , \log L = 4.45 [ L _ { \odot } ] ) are typical for an O9.7 V star . The microturbulent , macroturbulent , and projected rotational velocities are lower than previously suggested ( \xi _ { \text } { ph } ,v _ { \text } { mac } ,v \sin i \leq 4 km { s } ^ { -1 } ) . An initial mass of 16 M _ { \odot } and an age of 5 Myr are inferred from evolutionary tracks . We derive a mean X-ray emitting temperature of \log T _ { \text } { X } = 6.7 [ K ] and an X-ray luminosity of L _ { \text } { X } = 1 \cdot 10 ^ { 32 } { erg } { s } ^ { -1 } . Short- and long-scale variability is seen in the H \alpha line , but only a very long period of P \approx 5 yr could be estimated . Assessing the circumstellar density of HD 54879 using UV spectra , we can roughly estimate the mass-loss rate HD 54879 would have in the absence of a magnetic field as \log \dot { M } _ { B = 0 } \approx - 9.0 [ M _ { \odot } { yr } ^ { -1 } ] . The magnetic field traps the stellar wind up to the Alfvén radius r _ { \text } { A } \gtrsim 12 R _ { * } , implying that its true mass-loss rate is \log \dot { M } \lesssim - 10.2 [ M _ { \odot } { yr } ^ { -1 } ] . Hence , density enhancements around magnetic stars can be exploited to estimate mass-loss rates of non-magnetic stars of similar spectral types , essential for resolving the weak wind problem . Conclusions : Our study confirms that strongly magnetized stars lose little or no mass , and supplies important constraints on the weak-wind problem of massive main sequence stars .