Breastfeeding / latching issues?

Rach

Baby boy is coming up for three weeks.

Sometimes he seems to be latching okay and will feed fine, other times it takes him over ten minutes with lots of failed attempts and screaming fits before he eventually latches. It happens more at night for some reason, it’s getting really tiring now, it’s almost like he sometimes completely forgets and can’t latch no matter how hungry he is.

Also, sometimes he latches fine but comes off himself and goes back and forth. It’s not like he does it intentionally as he cries out of frustration until he latches again. What can I do to help?