Ran into this error message whilst developing tonight: SQLite3::BusyException: database is locked:
I have two models:
my trouble is: I opened a database management program named "DB Browser for SQlite". Closed this database management program, and problem solved.
SQLite has troubles with concurrency. I changed sqlite on Postgresql and the issue is gone
try restarting the server or closing any running rails console, worked for me
This happens when you make any changes manually directly into the SQlite DB Browser (like delete a row or change the value of any column) and forget to save those changes. Any changes made need to be saved (ctrl + s
). If not saved, SQLite locks the Database until u save those changes.
I did the same and my issue got resolved!
SQLite is not really supposed to be used for concurrent access which is the issue you are running into here. You can try increasing the timeout in your database.yml
file which may be a workaround for you in this case. However, I would recommend you switch to another database that supports multiple connections like MySQL or PgSQL.
Probably you have a Rails console open on another bash, if so you have to close it (ctrl+D).