This paper develops a search model with heterogeneous workers and social networks. High ability workers are more productive and have a larger number of professional contacts. Firms have a choice between a high cost vacancy in the regular labour market and a low cost job opening in the referral market. In this setting the model predicts that a larger number of social contacts is associated with a larger wage gap between high and low ability workers and a larger difference in the equilibrium unemployment rates. Next we demonstrate that the decentralized equilibrium is inefficient for any value of the bargaining power. There are two reasons for the inefficiency. First, the private gain from creating a job in the referral market is always below the social gain, so the equilibrium unemployment of high ability workers is above its optimal value. Moreover, high ability workers congest the market for low ability workers, so the equilibrium wage inequality is inefficiently large. This is in contrast to the result of Blazquez and Jansen (2008) showing that the distribution of wages is compressed in a search model with heterogeneous workers. Finally, we show that a combination of taxes and subsidies can restore the optimal allocation.