‘Write what you know’ is great advice on the whole, and definitely a good starting point. We all have individual experiences, individual knowledge and an individual viewpoint. It would be madness not to make use of those, although it’s surprisingly easy to overlook things that are intrinsically part of us. However, when taken to an extreme, I find it can be unhelpful.
To me, one of the many joys of writing is the sense of discovery. It’s not so much about writing what I already know as it is about stepping, and occasionally leaping, from what I know, to the things I will come to know. Perhaps I start a story on familiar territory, but then I move on to the unknown. I may not know much about the workings of a hospital, for example, but writing might give me a reason to find out. And that’s exciting!
I’m working on a project that deals with familiar subject matter. It’s at risk of becoming safe and sickly, so I’m playing with the idea of setting the story in a city. I have never lived in a city! It’ll push me out of my comfort zone and hopefully give some edge to the story. I’ll have to learn a lot more before I can make it work, but that’s part of the fun.
So, yes, write what you know. And then find out more. Write about that too.