All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
It is more appropriate for a Muslim to avoid going to restaurants and other places where there is music. But it is appears to us –Allah knows best –that going to those places for a permissible purpose, such as eating, while not listening to the music is not forbidden, because it is forbidden to listen to music but not to hear it.
Ibn Hajar al-Makki said: "Among which is that: The prohibition is only listening, and not just hearing; not with the purpose of listening. Our companions asserted that if there are forbidden nightclubs in one’s neighborhood which he could not remove, he is not obliged to move away to another accommodation, and he is not sinful by hearing it unintentionally. They explicitly asserted here that a person is sinful by listening to it and not by hearing it.” [End of quote –excerpted from Kaff ar-Ri’aa’ ‘an Muharramaat al-Lahwi wal istimaa’]
It is also permissible –with dislikeability –to enter markets involving evil, such as music, for a permissible purpose, while avoiding listening to music, and it is not forbidden to go to those markets for those who do not commit evil in it.
Al-Qurtubi said:
“These Ahadeeth prove the dislikeability of entering markets, especially at this time and age where men mix with women. This is what our scholars stated when there is much falsehood and evil in markets: it is disliked for righteous people to enter it as well as for those who are imitated by people in their religion, as a way for them to avoid going to places where Allah is disobeyed.” [Excerpted from al-Jaami’ li ahkaam al-Qur’aan]
Allah knows best.