The $W$ boson mass is measured using proton-proton collision data at $sqrt{s}=13$ TeV corresponding to an integrated luminosity of 1.7 fb$^{-1}$ recorded during 2016 by the LHCb experiment. With a simultaneous fit of the muon $q/p_T$ distribution of a sample of $W to mu u$ decays and the $phi^*$ distribution of a sample of $Ztomumu$ decays the $W$ boson mass is determined to be begin{equation*} m_{W} = 80354 pm 23_{rm stat} pm 10_{rm exp} pm 17_{rm theory} pm 9_{rm PDF}~mathrm{MeV}, end{equation*} where uncertainties correspond to contributions from statistical, experimental systematic, theoretical and parton distribution function sources. This is an average of results based on three recent global parton distribution function sets. The measurement agrees well with the prediction of the global electroweak fit and with previous measurements.