Even though this is an old post it became my go to. Here’s my fix. I purchased a 2004 Mazda 3 Hatch a week ago and the Sunroof did’t work. It made the horrible clacking noise that many people complain about and the sunroof didn’t move much. Resetting the position of the roof did not work. I’ve read though that these cars sunroof motors are notorious for working themselves loose. That ended up being my problem but there’s more to it than just tightening the screws. I found it necessary to reposition the roof and the motor. To get to the motor I pulled the headliner down about half way to get access. I stopped at the B Pillar. It’s best to go all the way but call me lazy I got other $@$* to do. So any way once you get access remove the motor by the 3 Phillips screws as I said they should be loose. They like to fall and disappear in to some kind of %#*@ wormhole so be mindful of that. Oh and disconnect you battery completely before you do this. Those curtain airbags are there. Ok so I dropped the motor out and inspected the drive gear. It appeared to be fine. You’ll notice the drive system on the sunroof. It’s operated by a cable system and the roof motor engages the cable. At this point I moved the roof manually in to the closed position and pushed it up as far as it would go. You see the cable move as it does and eventually won’t move anymore. It did not move to the full upward tilt position just to closed. Now that the roof is closed I wanted to establish the position of the motor. I plugged it to the switch and reconnected the battery. When you press open the motor goes runs clockwise I believe automatically and stops. Close is manual and you have to hold the button down. I moved the motor to fully closed. I didn’t like the idea having the motor hit it’s mechanical stop and having the roof position be correct. Cables stretch after time after all and there should be some extra travel available to the system. So I used an Allen wrench and ‘clocked’ the motor a quarter turn forward. FYI I tried to find the official procedure for this but the web had nothing and I don’t have the service shop manual for the vehicle. If someone does have the manual please correct me. Anyway so with the roof sunroof closed manually and the motor ‘clocked’ I reinstalled it without loctite. I also tightened the surrounding bolts and nuts on the sunroof assembly. Nothing crazy just a solid snug. With the sunroof motor back in I reconnected the switch and boom! Like butta it works. Opened and closed perfectly. Tilt up and down too. I then removed each motor screw individually, put Blue Loctite then and tightened them up. Put everything back together and you’re good. Hope this helps y’all.