The fan and light will turn on then off then on, etc. Sometimes it will last a few seconds and other times minutes.
Is it just a loose connection?
Likely so, yes. A loose connection is quite dangerous- you could be getting arcs, which can start fires. I would recommend against using the fan until you can check the connections.
More and more state and local electrical codes are requiring arc fault circuit interrupt breakers. While they're more expensive, they really do work to prevent fires.