Its perfectly possible for them to mutually recognise each other and then sign a peace treaty. In fact thats actually what North Korea has proposed several times saying “hey theres no need for the US to keep all those troops over there, they are the ones causing the problem not us!”… eg see here: http://journal-neo.org/2015/10/22/north-korean-peace-agreement-proposal/
of course their peace proposal involves them keeping nuclear weapons amongst other things.
I think, to be meaningful, the question would need to be limited to nations which had historically recognized each other’s sovereignty and borders over the relevant territory prior to the hostilities, and involving the regular armed forces under the control and command of the central governments of the two states…
And “war” would need to be defined as ongoing hostilities in which every asset of the adversaries is regarded as a tactical target.
That still leaves a gray area, but it would not be a proper “war” if the two sides are just glaring at each other and the incidents are limited to a few skirmishes between undisciplined troops or an occasional inadvertent overflight. Technically, quite a few countries are at war with their neighbors, like Chile/Bolivia, to this day, since old peace treaties have been annulled…
The First Congo War (96-97) was a pretty straightforward “Country A (Zaire) invades Country B (Rwanda) and they fight about it for a while” war. The subsequent longer and bloodier Second Congo War was technically a civil war, but unique in that there were national armies from multiple countries fighting on each side, which has lead to some people calling it “the World War of Africa.”
I don’t think Ukraine counts. The troops in question were not openly wearing the uniforms of Russia or acknowledged to be under the command of the Russian military hierarchy. If we count covert operations then US vs Syria right now is the winner. US special forces are certainly operating against the Assad government at the moment.
They are both separately UN members and widely recognized by other countries, which is a pretty reasonable definition of being nations. A number of nations claim sovereignty over another nation’s territory.
I wouldn’t count this, however, since although a state of war exists and there are occasional hostilities it’s not really an active war.