Hi,
in order to help you we need to know a little more about your problem.
try this and report back.
with all 6 strings tuned to pitch, fret the D string at the 1st fret (closest to the nut) and pick the string, listen for the rattling sound. Repeat it at each consecutive fret all the way down the D string. Take note of where the rattle is i.e. 1st fret, 7th, 12th etc.
you can do this for all 6 strings.