During World War I, the typical role for a gunboat (Kanonenboot) was its service in colonial territories or coastal areas where larger warships could not operate. Since Germany did not have any colonial territories in the 1930s anymore, there was no real need for gunboats in the German navy anymore.
But with the increased fleet construction in the late 1930s, several design plans for gunboats, either for the use as coastal protection or use on foreign stations were made. While most of these plans never reached a stage near realization, the four Kanonenboote 1938, K1-K4, were ordered in 1938.
With lightly less then 2000 ts and four 10,5 cm guns, those boats were quite similarly in size and armament to gunboats of other nations, but their engine system was different. Using a quite old fashioned triple expansion engine instead of turbines or a diesel engine and having a short operational radius, those boats clearly were never designed to be used overseas, those were boats that should be operated in European waters.
All four boats were ordered on 11.11.1938 at Hamburg's Stülcken shipyard with proposed completion dates between May 1941 and February 1942. None of the ships was laid down and on after the outbreak of the war, all four of them canceled on 19.09.1939.