The bandgap is one of the most fundamental properties of condensed matter. However, an accurate calculation of its value, which could potentially allow experimentalists to identify materials suitable for device applications, is very computationally expensive. Here, active machine learning algorithms are used to leverage a limited number of accurate density functional theory calculations to robustly predict the bandgap of a very large number of novel 2D heterostructures. Using this approach, a database of ≈2.2 million bandgap values for various novel 2D van der Waals heterostructures is produced.