We study the formation of topological defects in nematic liquid crystals confined in open bicontinuous networks produced in glass by femtosecond laser micromachining. We obtain a careful classification of the number and localisation of the defects as a function of the topological properties of the network. Our findings lead to a general formula that predicts the total topological charge in open complex networks, thus complementing the classic Stein–Gauss theorem. Our result provides a justification for the observed multistability of nematics confined in porous networks.