Nearly 10,000 commuters faced a rude welcome to December on Monday morning, when the MetroCards sent to them by the Metropolitan Transportation Authority proved worthless.

Commuters rushing to get to work after the extended holiday weekend could not get through the turnstiles or past the fareboxes when they tried to swipe their new MetroCards. The cards, which should have been good for 30 days’ use of New York City’s subway and bus systems, turned out to be good for none because of a coding error, said Aaron Donovan, a spokesman for the authority.

Mr. Donovan said the “technical glitch” affected only those MetroCards attached to December monthly passes for riders on the Long Island Rail Road and the Metro-North Railroad. He said that 7,100 Long Island customers and 2,800 Metro-North riders who buy MetroCards with their passes through the authority’s Mail & Ride program were affected.

Many of those customers transfer from commuter trains to the subway at Pennsylvania Station or Grand Central Terminal. The failure caused confusion and long lines of unhappy commuters at the authority’s booths at those stations. Unable to reach the authority through its overwhelmed website or by phone, many of them resorted to buying MetroCards to get to work, hoping to sort out the problem later.