Proper error handling when database is not running

Fix #152