Mandy Moore was warned she only had a "slim chance" of getting pregnant.

The 39-year-old actress - who has sons Gus, two, and Ozzie, 15 months, with husband Taylor Goldsmith - recalled how much of a "surprise" it was to be told she was expecting her first child because she'd always expected to have fertility problems.

Alongside a photo of herself as a child, she wrote on Instagram: "I’ve always wanted to be a mom. Before bringing my two boys into the world with my love, @taylordawesgoldsmith, I was a mom to many many cats and at times, just as many dogs (and admittedly today, I still am).

"But there was a time when I thought I might not be able to have kids. I remember when the doctor told me there was a slim chance of getting pregnant… and then lo and behold to our surprise, I became pregnant with Gus.[heart emoji])

Before having her children, Mandy was cast as Rebecca Pearson on 'This Is Us' and she admitted playing a mother to triplets has helped her with the struggle of raising two very young kids and knowing nothing has to be "right" all the time.

She continued: "Motherhood is a beautiful, messy, sleepless gift and to have two kiddos under two…whew!!!

"Playing Rebecca on #ThisIsUs actually prepared me for it a bit — like changing a diaper for the first time and running around set with “triplets”.

"Being a mom on This Is Us to triplets at various stages of life and now being a mom to Gus and Ozzie, well, I’ve learned that as hard as you try and as good intentioned as you may be, it is impossible to “get it right” all of the time.

"Rebecca Pearson said it best: “It’s my job to keep standing there with my arms wide open, waiting for you to maybe someday fall inside if you needed it. And if you do, I’ll love you. And if you don’t I’ll love you too — because that’s what it means to be a parent. You’ll see one day.” And to that I say, Rebecca, I see it! #ThisIsUs and #ThatWasUs @thatwasus (sic)"

The 'Dr. Death' actress previously admitted she was "very hesitant" to believe she was going to have a child because she was preparing for surgery on her uterus when she was told she was expecting Gus.

Speaking during her first pregnancy, she told Romper: "Because of this issue with my uterus, I was very hesitant to believe it and put any stock in it.

"I sort of was holding my breath until 12 weeks."