In Hive, "select * from table" operates in a different mode than any other more complicated query. That query operates within the hive client, in a single JVM. The logic is that query will eventually have to print everything to the console from a single thread anyway, so just doing everything from that thread isn't any worse. Everything else, including just a simple filter, will run as one or more MapReduce jobs.
When you run the query without the filter, I'm guessing you're doing so on the same machine that MongoDB is running on, so it can connect to localhost:12345. But when you run a MapReduce job, it's a different machine trying to connect: a task node. The mapper tries to connect to "localhost:12345" to get data from Mongo, but can't do so. Maybe Mongo isn't running on that machine, or maybe it's running on a different port. I don't know how your cluster is configured.
Regardless, you should be specifying the location of the MongoDB instance in a way that all of the machines in your cluster can access it. If it has a local IP address that's pretty static, that will work, but better would be to do it by hostname and DNS resolution.