It can be a lot of things. The most usual culprit is that you have an object hidden in the viewport but it comes into effect at render time and it’s right in front of your camera, blacking everything. Another one is that you have compositing nodes turned on and it’s taking effect after the render. Maybe it’s some collection in the outliner that has the renderability off. In any case you can upload your .blend file if you want us to take a look.