The San Francisco man who received national attention for living in a wooden box in a friend’s living room violated local housing laws and created a major fire hazard, according to city officials, who have pressured him to take down his pod and move out.

Peter Berkowitz’s story went viral after he explained in an op-ed for the Guardian that his solution to the city’s housing crisis was to pay $400 a month to live in a tiny pod that he built in his friend’s place – a semi-private wooden home with enough room for a fold-down desk, a mini bed and a reading light.

That solution, it turns out, was illegal and, according to city inspectors, very dangerous.

“The housing codes, the fire codes and the building codes are fairly restrictive in terms of what you can do inside, in terms of coming up with another enclosed bedroom,” said William Strawn, director of public affairs for San Francisco’s department of building inspection. “With these types of, what I’ll call creative efforts to try and cope with what everybody recognizes is a tough housing market here, you still have to follow some basic safety … rules.”

Building officials recently told the website Hoodline that the pods are illegal and that the city is trying to discourage others from building these types of makeshift bedrooms – even if it has become increasingly difficult to find affordable housing in the city.

In a short interview on Tuesday, Berkowitz said that as soon as he heard the city had worries about his housing set-up, he decided to leave the box. “I’m 100% concerned with doing this legally,” he said. “It is not set up any more.”

He said he was staying with family while he’s “figuring things out”.

Berkowitz declined to comment on whether he hopes to build a box that meets the city’s code requirements.

Inside the box that Peter Berkowitz rented. City inspectors said it violated numerous safety codes. Photograph: Peter Berkowitz

The median rent for a one-bedroom apartment in San Francisco is $3,590, according to real estate website Zumper, and with rents continuing to climb in surrounding Bay Area cities, finding a reasonably priced home throughout the region has become seemingly impossible for some.

As a result, Bay Area residents have resorted to tents, trucks, cupboards under the stairs, basement crawl spaces and other housing scenarios.

Strawn said that as soon as building officials saw Berkowitz’s photos online, they tried to track him down to let him know that his box was a hazard.

“If there were a fire in the building,” he said, “it could go up in a hurry. Anybody inside it would essentially be toast.”

Strawn said there are state and local codes that govern how much space, air, light and other factors are required in bedrooms. “Based on what we could see from the pictures, that pod would fail all of those tests.”

Strawn said the city was not able to find Berkowitz and would have delivered a violation notice to the owner if officials had located his address.

“He could have a bed with a curtain around it, but it could not be boxed in, so to speak,” he said.