Added localhost detection for database connection.