It depends on the colors used in the rest of your website, the mood you're trying to achieve, the content you're presenting, etc.
In general you should aim to have a lot of contrast between the navbar and the rest of the page, so that users can find it easier.
This is what Stack Exchange does, the blue navbar contrasts heavily with the mostly-white page, and the black network-wide navigation bar at the top contrasts with both the other navigation bar AND the content.
In some cases, however, less contrast is cleaner and less distracting.
This is what Twitter does, their white navbar blends in with the rest of the page. This is because navigating between pages on Twitter is not nearly as important as it is on Stack Exchange sites. On Twitter, the primary focus for the user is the content on a single page, so the navbar should not distract from that.
Additionally, different colors cause users to feel differently while using your application. This is a very broad and interesting topic, and the effects of different colors depend heavily on culture and heritage. Here are some sources to learn about how different colors effect user perception.
Users sometimes also associate colors with certain brands, and keeping this association can be important for users to easily identify the brand of your website. As an example of this, let's play a little game.
Out of these 4 squares, which ones do you recognize? (Answers at the bottom of answer) Color can be a powerful thing, and sticking with a certain color can build brand recognition.
Going back to your original question, a white navigation bar can give focus to the content of your page (provided that your content also has a light background) and can help your logo stand out. It can also make your application look more clean and open.
Answers to Logo Game
(The answers are backwards so you don't see them by accident)
A. koobecaf B. rettiwt C. elppa D. tfosorcim
You might not have gotten C right because Apple depends more on the shape of their logo than color of their products. But you almost certainly should've gotten the first two right as social media sites depend on their brand being recognized everywhere.