Using a dark matter simulation we show how halo bias is determined by local density and not by halo mass. This is not totally surprising as, according to the peak-background split model, local matter density (bar δ) is the property that constrains bias at large scales. Massive haloes have a high clustering because they reside in high density regions. Small haloes can be found in a wide range of environments which differentially determine their clustering amplitudes. This contradicts the assumption made by standard halo occupation distribution (HOD) models that bias and occupation of haloes is determined solely by their mass. We show that the bias of central galaxies from semi-analytic models of galaxy formation as a function of luminosity and colour is therefore not correctly predicted by the standard HOD model. Using bar δ (of matter or galaxies) instead of halo mass, the HOD model correctly predicts galaxy bias. These results indicate the need to include information about local density and not only mass in order to correctly apply HOD analysis in these galaxy samples. This new model can be readily applied to observations and has the advantage that, in contrast with the dark matter halo mass, the galaxy density can be directly observed.