UB-4 was ordered in October 1914 and was laid down at the Germaniawerft shipyard in Kiel in November. UB-4 was a little more than in length and displaced between , depending on whether surfaced or submerged. She carried two torpedoes for her two bow torpedo tubes and was also armed with a deck-mounted machine gun. UB-4 was broken into sections and shipped by rail to Antwerp for reassembly. She was launched and commissioned as SM UB-4 in March 1915.