The database connection is not serializable I'm getting this error. The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection

I'm using Lightning 2.1.6.
I set up a media upload field on my page content type using reference to content/ reference media. It also uses the media browser to upload images. This field allows a single image upload. I get the error when you try to upload an image. And the image doesn't get added. If i allow multiple upload instead of single the error goes away. Also If I disable the "Interface Translation" module the error goes away and the images can be uploaded.
I experienced this issue after manually deleting some translated configuration files. From then on I was not able to successfully config import anymore without being interrupted with the fatal error from your question.

I then tried to run config import after uninstalling locale, which worked but have also deleted lots of translation from the database. Bad.

I could restore the configs in question and then remove them from the UI before exporting them again. Boring.

So I deleted the original configuration objects from an update function (and thereby also deleted the translations), and afterwards run configuration import again, where the original configs then got restored automatically (as their files still existed) WITHOUT translation.

/**
 * Remove unwanted translations.
 */
function MYMODULE_update_8005(&amp;$sandbox) {

  $configs = [
    'image.style.crop_thumbnail',
    'views.view.user_admin_people',
  ];

  foreach ($configs as $config) {
    Drupal::configFactory()-&gt;getEditable($config)-&gt;delete();
  }
}




EDIT: Only shortly after I had the same problem again. Again it was a missing config (I deleted manually, don't do that) and took me hours to find out which one exactly. This time it was menu_item_extras which required menu_item_extras.utility.yml. Actually I uninstalled menu_item_extras but maybe menu_item_extras can't be uninstalled that simply. But that's a different issue.

What's left to conclude now is: Did you manually delete some config files prior to getting this error?