You can do your best to prevent it, but sooner or later when you're traveling by yourself you're going to come across a creepy guy. Don't let that hold you back from your adventure!
It's been a deeply ingrained safety mechanism since childhood: Don't talk to strangers. Yet this concept goes against the very ideals of a solo traveler - adventure, learning and experiencing the new and different. Some of my best and worst travel experiences began with talking to a stranger in a foreign land. After all, the height of solo travel involves beautiful serendipitous moments doing something you never imagined with people you just met.
Let's face it, creepy men are everywhere, in your own country, in your hometown. Unless your life consists of working digitally, ordering your groceries online and interacting with others solely through social media, you are going to encounter flesh and blood creepy men at some point in your life. I'm not saying to get used to creepy behavior, rather, don't let it stop you from leaving the perceived safety of your home country and venturing out to unchartered lands. You can develop a few simple tactics to prevent or manage these uncomfortable situations.
First, be sure to take basic precautionary measures: meet new people in groups and in public places for the first time, have an alternate plan, be aware of your general surroundings, learn important phrases in the local language, and most importantly, trust your gut feeling. Second, be aware that social norms differ by country. What you might interpret as creepy behavior might simply be a cultural disconnect.
When I was in Argentina, I noticed that the guys were very friendly (to put it mildly) and the women seemed to be a bit standoffish, even to other women. If I was smart, I would've taken that into consideration and modified my personality to align more with the local culture. Instead, I was my usual friendly, open, joyful self. Through Couchsurfing I'd found a nice place to stay with my own room in Buenos Aires. My somewhat shy but kind host was a fellow vegetarian, so we enjoyed nice conversation and a delicious meal at his favorite local restaurant. Imagine my surprise when we arrived home and he swooped in to kiss me. I quickly sidestepped him and the poor guy felt so embarrassed that he made an excuse to stay at his parents' place the rest of the time I was there. He obviously wasn't a bad guy, although making a move on your guest could be interpreted as creepy behavior. In the days after, I shared the story with some new Argentinian friends and they all agreed that my natural bubbliness would be construed as romantic interest to Argentinian men who are used to the everyday indifference expressed by Argentinian women.
The best way to minimize the occurrence of these awkward situations is to be clear and upfront about what you want (or don't want) and be aware of what signals you're sending. For example, after my Couchsurfing host in Istanbul creeped me out by making innuendos and asking me to tell him any sexual travel stories (I locked the door to my bedroom that night), I now make it a point to laughingly share that story with male hosts shortly after meeting them. I tell them, "Can you believe that host thought this was a hookup site? I'm just interested in intercultural exchange." This clarifies the parameters in a nice way. Or you could simply be straightforward and put in your profile and in your communications, "I'm only interested in international friendship, not hooking up."
These are the same tactics you already use at home when you meet a guy for the first time, just in a different environment. If you are someone who knows how to communicate clearly and set healthy boundaries with others, you'll be fine. If not, here's your chance to develop these valuable skills. For every creepy guy you meet abroad, there are 20 non-creepy ones. Traveling solo safely is not about controlling all your external circumstances; rather, it's about trusting your ability to handle whatever shows up. The more you travel solo, the greater your confidence grows in your ability to navigate any situation: becoming hopelessly lost, experiencing plane or train delays, getting sick, being pickpocketed, AND dealing with creepy men from another culture.