I've recently found a recipe that I really enjoy, but it calls for a sunny side up egg. Every time I try to fry an egg in this way it ends up sticking to the pan, the yolk breaks, and it ends up as an eggy mess.   I've tried multiple pans including my cast-iron pan, a teflon, pan, and others but they seem to always stick. What am I doing wrong? 
I like to use low heat and a lid on a teflon pan. The lid helps the top side of the egg set faster, and prevents the underside from over cooking. Of course, this is easier if you have a glass lid. (also, as others have noted, it is important to add fat and to preheat the pan) 