when I was looking the definition of both of these words. It showed that they both meant night. Does both of these words mean night?
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.
Night refers to the period from dark to dawn
The original meaning refers to a period after sunset. (in modern Chinese. it is used to refer the night itself)
晚上我不外出 = I don't go out at night (as soon as the sun is down and until the sun rises)
夜間我不外出 = I don't go out at night (when it is dark)
裡 in 夜裡 means 'in'
夜裡 = in the night time = at night
It's hard to explain. Because there are overlaps between 夜裡 and 晚上。
Below is a simple and ugly graph I drew.
晚上10點 and 夜裡10點 => 10PM
夜裡7點, 7PM => odd, because 7PM is not so late night, use 晚上7點 or 傍晚7點 instead would be more appropriate.
夜裡一兩點 半夜一兩點 凌晨一兩點 all have the same meaning.
夜裡12點 晚上12點 半夜12點 凌晨12點 all means 00:00.