President Obama said Wednesday that voters should punish congressional Republicans after they voted Wednesday to block a Senate student loan bill that would've helped millions refinance their debt. 

"Don't boo, remember to vote," Obama told students while delivering the commencement address at a Massachusetts high school.

"There are too many politicians in Washington who don't have the right priorities. We need to straighten them out," he continued. "And, maybe, they forgot where they came from and who invested in them along the way."

The bill, authored by Sen. Elizabeth WarrenElizabeth Ann WarrenCordray's legacy of consumer protection worth defending Booker tries to find the right lane  Jones raised 0K a day after first Moore accusers came forward: report MORE (D-Mass.), would have allowed some 25 million individuals to refinance their federal student loans to today’s lower interest rates of less than 4 percent. The Congressional Budget Office estimated the program could cost $51 billion.

Members of the GOP said they opposed how the legislation would be paid for — the so-called "Buffett Rule" — which would limit tax deductions available to millionaires.

The president described the vote, which fell three short of the 60 votes needed to advance, as "frustrating." He accused Republicans of doing a "disservice not only to your generation but our history as a nation that strives to put quality education within the reach of every American."

The president had looked to build momentum for the program in a series of education-focused events throughout the week.

On Monday, Obama signed an executive action expanding the number of student borrowers eligible for a federal program that caps monthly payments based on income. 

Later in the week, the president sat for an education town-hall meeting with Tumblr, a blogging platform used primarily by teenagers and young adults.

In Massachusetts, Obama vowed to "keep on putting pressure on Congress."

"You're going to have to be a part of helping to shape the law," Obama told the students. "You're going to have to shape public opinion. You're going to have to remember everybody who invested in you."