This is another one of them there varies by state/county/city things. Where I live you must be connected to the grid. This causes problems for people who don’t want to be connected to the grid, i.e. they have more than enough solar or windmill and battery capacity to not require it from a functional standpoint. But the county forbids you from not paying the local electricity monopoly their monthly bribe.
This is relatively recent – as of the last 4 or 5 years or so. The power company now helpfully charges a “connection fee” if you use 0 kWh, which started happening exactly at the same time the law was passed to make it illegal not to be connected to them. I can’t help but conclude that these two facts are not coincidental.