A Foxboro High School teacher who lost his job after being indicted on child pornography charges has failed in his bid to be released from jail while his case is pending.

U.S. District Court Judge David Hennessy last month rejected the request by Thomas Davis, 41, of Mansfield, to live in a sober house in Boston with a GPS bracelet, among other conditions, according to court records.

The judge agreed with the prosecution that the housing plan was inadequate for the safety of children and the community, according to records.

However, the judge rejected the request “without prejudice,” which means he will consider another request for release by Davis in the future.

Davis has been held without bail since his arrest Aug. 26 and is currently being held at the Plymouth House of Correction.

He was subsequently indicted by a federal grand jury Sept. 23 on charges of possessing child pornography and receiving child pornography over the internet.

Prior to his arrest by the FBI, Davis worked as a special education teacher at Foxboro High for three years.

Federal prosecutors say they found 40 images of child pornography on Davis’ laptop, including ones involving prepubescent boys under the age of 12.

In addition, Davis secretly videotaped himself having sex with an 18-year-old male who told authorities the encounter was consensual but taped without his knowledge, according to prosecutors.

David Linton may be reached at 508-236-0338.