The singer revealed the touching story behind the track for the new Peter Pan film 'Pan' in tweets to her five million followers, admitting it was unlike her to "discuss it so publicly".
She tweeted: "Five years ago today I was admitted to hospital. Four days later I delivered a beautiful baby boy, but sadly he didn't make it.
"Please listen and if you fancy it, you could donate in his memory. Much love, lil x".
The singer included a link to the stillbirth and neonatal death charity (Sands) for donations.
It's unlike me to discuss this sort of thing so publicly but I wrote this song in his memory when writing something for @panmovie— lily (@lilyallen) October 27, 2015
5 years ago today I was admitted to hospital. 4 days later I delivered a beautiful baby boy, but sadly he didn't make it.— lily (@lilyallen) October 27, 2015
"The anniversary of a baby’s death is always a very difficult time for bereaved parents and we hope that Lily Allen is okay and feeling supported at this time," Judith Abela, acting chief executive of Sands told HuffPost UK Parents.
"Creating memories is something that is really important to parents and their families so we’re really pleased that Lily has been able to do this by writing a song in her baby son’s memory.
"Sadly thousands of babies die every year in the UK. In 2013, over 100 babies every week were stillborn or died soon after birth.
"Stillbirth is not rare and it’s a tragedy that doesn’t discriminate."
Abela said the charity would not exist without the generosity of donations and said every penny raised helps to fund and expand their work to help prevent babies from dying.
She added: "That’s why we really appreciate Lily Allen very kindly asking people to donate to Sands in memory of her baby son."
Allen, mum to Ethel, four, and Marnie, two, with husband Sam Cooper has previously spoken out about the devastation of losing her son in November 2010 when she was six months pregnant.
In an interview with The Sun on Sunday, the 30-year-old singer said: "It was horrendous and something I would not wish on my worst enemy.
"It's something that I still haven't dealt with. I never will get over it. I have dealt with it, you know, as being at one with it.
"But it's not something that you get over. I held my child and it was really horrific and painful - one of the hardest things that can happen to a person."
Allen, who married Cooper in 2011, said the family have a stone in their garden with their son's name on.
Allen also suffered a miscarriage in 2008 while with her former partner Ed Simons from Chemical Brother. The couple broke up shortly after.
She told The Mirror at the time: "Maybe if I had stayed pregnant and had the baby then things would have worked out between me and Ed.
"I don't know. You could drive yourself insane thinking about it."