Usually easiest to yank the headlight to get room to work. While there I commonly cut the black ground wire to also screw it into a drilled hole under the light at the chassis run there. That gives two grounds, the OEM long ground can sometimes not ground to make light not work, the separate dedicated ground stops that.
The plug connectors can make for trouble too when they corrode inside from water splashing. A credit or gift card cut to 1/16" wide with a same width strip of #400 sandpaper folded around it can make an excellent plug contact cleaning tool.