Figures released following a freedom of information (FOI) request by the Scottish Greens reveal the unpaid fees have reached at least £1,168,755.
Every child at a council school can get free lunches in the first three years of primary in Scotland.
Children are also able to get free school lunches after primary three if their parents or caregivers receive benefits or tax credits.
The Scottish Greens received a response to the FOI request from all but seven local authorities.
Edinburgh, Midlothian, Falkirk and West Dunbartonshire had not responded to their request at time of publication, while Glasgow, Renfrewshire and Clackmannanshire did not have a central figure for debt.
Figures highlighted by the Greens showed as much as £434,545 is owed to Aberdeen City Council for unpaid school meals, while £168,854 is owed to North Ayrshire Council.
Elsewhere, £98,985 is owed to Aberdeenshire Council, £55,455 to Fife Council and £20,650 to Dundee City Council.
The Scottish Greens said the vast majority of schools report they do not impose restrictions on pupils accessing meals if they are in debt.
Scottish Green MSP Ross Greer called the level of debt “astonishing” and said it should now be written off.
“Children are going hungry in Scotland and we know that means-tested free school meals miss out far too many families who need them,” he said.
“This frankly astonishing mountain of school meal debt should be written off immediately.
“If it is serious about closing the attainment gap, the Scottish Government should follow the example of countries like Finland by providing all pupils with access to a free, nutritious breakfast and lunch, including during school holidays.
“The first step towards that would be writing off this growing debt, which is clearly not going to be paid off in most cases.”
Deputy First Minister John Swinney said healthy and nutritious free school meals are a benefit to the learning and health of pupils.
“The Scottish Government introduced free school meals for all primary one to three pupils four years ago and has extended eligibility for lower-income households,” he said.
“Healthy and nutritious free school meals benefit pupils’ learning and health and can save eligible families around £400 per child per year, part of our £1.4 billion support for low-income households.
“Eligible families with children above primary three can register for free school meals and if families face financial difficulties but do not meet national eligibility criteria, they can speak to their local authority to access appropriate advice and assistance.”