It might seem natural to assume that your hypothesis is wrong, and therefore rethink your hypothesis. In fact, in a popular article for LiveScience (see link below), that's exactly what the author suggests: The scientist either rejects the hypothesis outright, or modifies the hypothesis to account for the failed prediction. Either way, the implication is that the scientist "goes back to the drawing board" to come up with new predictions to test.
But in the real world, scientists don't always assume there is something wrong with the hypothesis. Before you reject your hypothesis, it's important to check your reasoning. You might have made a mistake at the step of generating predictions. Does your prediction necessarily follow from your hypothesis?
Or you might have made a mistake during the testing process. Did you execute a clean experiment? Did you successfully control for other factors that might have influenced the results?
It's not hard to imagine how you could make a mistake during testing. You might fail to control for all the underlying differences between your treatment and control groups. Many phenomena are caused by multiple factors. If you fail to confirm your prediction, it could be because there was something different between groups that you failed to account for.
But what about the validity of your prediction? It's important to check that step too. For example, let's suppose your hypothesis is that gorillas are capable of visually recognizing themselves, and so you make the following prediction: If gorillas possess the ability of self-recognition, then if they look in the mirror, and see a smudge of white paint on their foreheads, they will try to rub it off.
You perform this experiment -- applying paint to gorillas while they sleep, and then allowing them to look in the mirror after they wake up. They look at their reflections, but fail to touch the paint spot or try to rub it off.
Should you abandon your hypothesis that gorillas are capable of visual self-recognition just because your prediction was wrong? On reflection, the prediction has problems. We can imagine cases where human beings -- who have self-awareness -- might not react in the predicted way.
This experiment is a real one. It's been called the "mirror test" and it has been performed on a variety of species. But some researchers have pointed out that the prediction doesn't necessarily follow from the hypothesis. For instance, gorillas might ignore the paint spot because they simply don't care how they look. These researchers haven't rejected the hypothesis merely because the prediction was wrong. Their approach, instead, is to go back to the step where you generate predictions from your hypothesis -- taking better care to come up with predictions that are more tightly entailed by your hypothesis.