A recessed lighting fixture consists of a metal housing suspended between ceiling joists by an extension bar, or mounting frame. If the light housing is sliding from the ceiling, there are two possible causes. First, the extension bar might have come loose. For example, if a screw pulls out of the wood joist, the extension bar will no longer be rigid, and the light housing will dip. In this case, you must remove the ceiling to reattach the extension bar. This scenario is rare, however. Most likely, the screws attaching the housing to the extension bar are loose, which is much easier to fix.
Things You'll Need
Socket wrench with appropriate socket
Turn off power to the light to prevent electrocution.
Unscrew the bulb and pull the plastic or metal trim away from the housing to reveal the spring clips, which are hooked metal springs. The trim is the cylindrical piece that nestles within the metal housing of the fixture.
Unhook the spring clips that hold the trim within the housing. You might be able to do this with your hands, but needle-nose pliers make grasping the ends of the spring clips easier. Remove the trim once it is detached.
Tighten with the appropriate tool the screws that attach the housing to the extension bar. Hex head screws are typical. Space is tight within the cavity, so use a socket wrench if possible.
Replace the trim once the metal housing is secure. Reattach the spring clips and push the trim back into the housing. Replace the bulb and turn the power on to test the light.