We have a ceiling fan that includes a light fixture. One day the light went off several minutes after turning it on. I checked the panel, and found that the breakers were ok. Room receptacles from the same breaker are ok too. After shaking the fan wire in the attic, it started working again, but after a couple of hours the same thing happened. I took the fan out and searched for a loose connection, but didn't find one. I traced the wire to a box, where there are four wires coming in. I checked all the wires but no power. Funny thing is the breaker is not tripping.
After 30 years as an electrician, most 95% of all electrical problems I've seen are caused by poor connections.
The best connection for outlets (receptacles) is to pigtail the wires by first twisting the white (neutrals) together and the blacks (hot) with a separate wire for each going to the terminal screws on the receptacle. Torque the connection sufficiently to avoid a high resistance connection, which will generate heat under load.
Many less skilled workmen insert wires into the back of a receptacle, and over time they work their way back out or open up because of high resistance.
Make sure the power is off or consult an electrician.