We study the relationship between galaxy colour, stellar mass and local galaxy density in a deep near-infrared imaging survey up to a redshift of z∼ 3 using the GOODS (Great Observatories Origins Deep Survey) NICMOS (Near Infrared Camera and Multi-Object Spectrometer) Survey (GNS). The GNS is a deep near-infrared Hubble Space Telescope survey imaging a total of 45 arcmin2 of the GOODS fields, reaching a stellar mass completeness limit of M*= 109.5 M⊙ at z= 3. Using these data, we measure galaxy local densities based on galaxy counts within a fixed aperture, as well as the distance to the third, fifth and seventh nearest neighbour. We compare the average rest-frame (U−B) colour and fraction of blue galaxies in different local densities and at different stellar masses. We find a strong correlation between colour and stellar mass at all redshifts up to z∼ 3. Massive red galaxies are already in place at z∼ 3 at the expected location of the red sequence in the colour–magnitude diagram, although they are star forming. We do not find a strong correlation between colour and local density; however, there may be evidence that the highest overdensities are populated by a higher fraction of blue galaxies than average or underdense areas. This could be indicating that the colour–density relation at high redshift is reversed with respect to lower redshifts (z < 1), where higher densities are found to have lower blue fractions. Our data suggest that the possible higher blue fraction at extreme overdensities might be due to a lack of massive red galaxies at the highest local densities.