That’s one of the first explanations that was considered. It can’t be dust or gas, because those would be backlit by the stars behind them and thus be visible. Larger objects are called MACHO [0] and have been ruled out by observational studies as well. As explained in [1], baryonic dark matter is also contradicted by CMB anisotropy analysis and nucleosynthesis theory.
[0] https://en.wikipedia.org/wiki/Massive_compact_halo_object
[1] https://en.wikipedia.org/wiki/Dark_matter#Baryonic_matter