  (Abridged) Main sequence massive stars embedded in an HII region should have
the same chemical abundances as the surrounding nebular gas+dust. The Cocoon
nebula, a close-by Galactic HII region ionized by a narrow line B0.5 V single
star (BD+46 3474), is an ideal target to perform a detailed comparison of
nebular and stellar abundances in the same Galactic HII region. We investigate
the chemical content of O, N and S in the Cocoon nebula from two different
points of view: an empirical analysis of the nebular spectrum and a detailed
spectroscopic analysis of its ionizing B-type star using state-of-the-art
stellar atmosphere modeling. By comparing the stellar and nebular abundances,
we aim to indirectly address the long-standing problem of the discrepancy found
between abundances obtained from collisionally excited lines (CELs) and optical
recombination lines in photoionized nebulae. We collect spatially resolved
spectroscopy of the Cocoon nebula and a high resolution optical spectrum of its
ionizing star. Standard nebular techniques are used to compute the physical
conditions and gaseous abundances of O, N and S. We perform a self-consistent
spectroscopic abundance analysis of BD+46 3474 based on the atmosphere code
FASTWIND to determine the stellar parameters and Si, O, and N abundances. The
Cocoon nebula and its ionizing star, located at a distance of 800+-80 pc, have
a very similar chemical composition as the Orion nebula and other B-type stars
in the solar vicinity. This result agrees with the high degree of homogeneity
of the present-day composition of the solar neighbourhood as derived from the
study of the local cold-gas ISM. The comparison of stellar and nebular CELs
abundances in the Cocoon nebula indicates that O and N gas+dust nebular values
are in better agreement with stellar ones assuming small temperature
fluctuations, of the order of those found in the Orion nebula.
