Recently I came across a weird error while trying to run firefly itunes server (mt-daapd) on my router (Asus wl-500w). It had something to do with sqlite and gave a vague message “Unable to open database file”. After going bonkers for a short time, I solved it and this is how.

One of my hard disks crashed recently and unfortunately it was the one I had connected to my router to serve media to me all over the house (through PS3/laptop) or when I travel (through laptop/phone). I had all the data backed up but somehow didn’t preserve the firefly server. I rebuilt the server from source using my own guide (Thank God I did it. I wouldn’t have been able to preserve my sanity finding all that out the hard way again.). But after doing all the installation and reconfiguration, it gave me a weird error “unable to open database file” every time and exited. I checked the permissions on the songs3.db file (in /opt/var/cache/mt-daapd for me) and made it writable by all but the issue persisted. I changed its ownership to the user under which firefly was running but the issue was still there. Finally I found that the server (or maybe its an sqlite thing) was trying to create a temp file in the cache directory for the transactions and since the user with which it was started, didn’t own the directory it wasn’t able to create the file in it.

So, the fix: I did a chown <username> /opt/var/cache/mt-daapd on it and voila! the problem was fixed. I am a happy man now since I own a new android phone since last time and now able to stream all my music to my phone through itunes (daap protocol) server over an ssh tunnel :)