Moses Ochieng' was arrested last Friday and appeared before Kwale senior resident magistrate Betty Koech on Monday.
State counsel Cecilia Wakoli told the court Ochieng' was arrested at Kombani Trading Centre after members of the public alerted police.
The seller admitted overpricing the product and said he had sold four packets before he was apprehended.
Ochieng' asked the court to forgive him saying he would not repeat the offence and that he had a family to take care of.
The magistrate noted the case was the first of its kind but that it was necessary for the trader to serve as an example to sellers exploiting residents.
He had given Ochieng' the alternative of five months in jail.
On Madaraka Day, Kwale county commissioner Kutswa Olaka warned of stern action against anyone charging more than Sh90 for that amount of flour.
A spot check by The Star found 2kg packs of flour cost Sh150 in areas including Tiribe, Ndavaya and Kinango. In Kwale town, residents said they had been paying Sh120 or Sh130. They said they have no choice as there is a shortage.
-The Star