There are plenty of companies make money based on open source software. Mongodb, Redhat, even ecomerce giant Magento. etc.
Usually, it is when a open source project get big enough that big enterprises wants to use it, they'll pay a lot of money for professional support licenses, training, etc.
And smaller companies or individuals might be willing to pay for hosted solutions if they don't want to bother with all the dev ops needs to manage and scale it, even if it is open source.