What is the difference between 晚上 and 夜里?
As a native speaker, these two word actually mean very different things to me:
晚上 refers to in the evening, the period of time between sunset and going to bed.
夜里 refers to in the night, anytime after people have gone to bed.
There should be very few cases where these are interchangeable, just like you can’t always swap “evening” for “night”

晚上一起吃饭吧？
Wanna eat out tonight(aka this evening)?


夜里一起吃饭吧？【误】
Wanna eat out tonight(aka at night)? [wrong]

Note how in English we are actually accustomed to use tonight for both meanings and I think that’s where the confusion kicked in.