The importance of referral hiring, which is workers finding employment via social contacts, is nowadays an empirically well documented fact. It also has been shown that social networks for finding jobs can create stratification. These analyses are, by and large, based on exogenous network structures. We go beyond the existing work by building an agent-based model of the labor market in which the social network of potential referees is endogenous. Workers invest some of their endowments into building up and fostering their social networks as an insurance device against future job losses. We look into the manner in which social networks and inequality respond to increased uncertainty in the labor market. We find that larger variability in firms' labor demand reduces workers' efforts put into social networks, leading to lower inequality.