At the start of the Russo-Japanese War, Viren was commanding the "Bayan" as part of the Russian Pacific Squadron based at Port Arthur. During the Battle of Port Arthur he developed a reputation as a daring and capable commander. Following the death of Admiral Wilgelm Vitgeft at the Battle of the Yellow Sea, Prince Pavel Ukhtomsky briefly took command of the Port Arthur Squadron, but could not command the support or respect of his peers. As no one officer could reach the besieged port, Viren, although a relatively junior officer with low seniority was promoted to rear admiral and on 4 September 1904 took command of the squadron during the last four months of the siege. During this time, with the besieged fleet unable to sortie and under continuous bombardment from land, Viren ordered that his warships be stripped of their guns, which were used to bolster the port's landward defenses, and his sailors were ordered to fight as naval infantry. He was wounded in combat in November 1904. After the surrender of Port Arthur, he was taken as a prisoner of war by the Japanese. After the war, he was awarded the Gold Sword for Bravery and the Order of St George, 4th degree, as well as the Order of St. Stanislaus, 1st class with swords.