Finally fixed solution with database connection