Many, if not all, writers have probably heard this advice time and again. It's easy advice to give new writers. After all, it's easiest and most honest in your writing to write what you know. But is that what we should stick to?
I don't have an easy answer to that question. On the one hand, what you are familiar with is going to sound most comfortable. But if all writers stuck to what we knew, there would be no such genres as fantasy and science fiction. Some of the most brilliant works would not have been written. Because we have to write from our imaginations, too. After all, how much did H.G. Wells know about giant aliens, or time travel, or genetic mutations? Maybe something, but since time travel is still theoretical at this point, we have to assume he didn't "know" much about it. How much did Tolkien know about wizards and hobbits? How much did Lovecraft, or Shelley, or King know about... You get the point. On a personal note, I am not a vampire, or a teenager, or a man, or gay. I have never been in an arranged marriage, played basketball, dated a Catholic, or shot up heroin. And yet I have written about all of those things and plenty more that I've never experienced. But parts of me sneak into every character in every novel.
On the other hand, you have authors who write semi-autobiographical novels, and they are just as alive and wonderful, whether they are humorous Jack Gantos novels or disturbing abuse novels. And no matter what you're writing, you've probably had to do at least a teensy tiny bit of research. Even when I'm writing something that is purely from my imagination, I don't think I've ever made it through a book without having to do a little research, whether it's vampire lore or the age cutoffs for statutory rape in each state (ah, the things writers google).
So I guess the best advice I can give is, write what interests you, even if it's not what you know. Write what fascinates you, what you're passionate about, especially if no one else is writing about it. Chances are, someone else is interested in that subject too. Think no one wants to read caveman romances? Auel's readership would disagree. There's a readership for just about anything. If your craft is strong and you are honest in what you write, you don't have to know it, at least not initially. You will write it and research it until you do know it. You will find your plotline and follow it, and when you know that, you're on the right track.