I faced the same error while i was trying to install puppet server. Here's what i did:
To fix the problem, all you need to do is to remove the lock files. But before you do that, it would be a good idea to stop any process that is using the lock files.
Use the lsof command to get the process ID of the process holding the lock files.
Run these commands one by one.
It’s possible that the commands don’t return anything, or return just one number. If they do return at least one number, use the number(s) and kill the processes like this (replace the PID with the numbers you got from the above commands):
sudo kill -9 PID
You can now safely remove the lock files using the commands below:
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock
After that, reconfigure the packages:
sudo dpkg --configure -a
Now if you run the sudo apt update command, everything should be fine.
This worked for me!