Really got to me too. Loneliness one of the greatest sorrows for so many people and for so many reasons.
DH and I always try and make eye contact, smile and say hello to everyone we pass when out. It has made for some very interesting encounters over the years including one with a woman we knew only slightly from smiling at her and saying hello whenever we passed on our walks. One day she said, “my husbands just died” She said she needed to talk to someone and although she didn’t know us, because we always said hello she felt she could speak out. We were with her for over an hour.
Just smile and say hello sometimes that’s enough to help a little,