How can I tell who would be interested in my research? I'm a math postdoc. On MathJobs they sometimes ask if there are any "faculty contacts," which are people I've met or who otherwise have interest in my work. But sometimes I don't know who the faculty are, I've never met them at a conference, etc.  My feeling is that if I work on something that none of the faculty are particularly interested in, that will sink my application. In other words, I think I need to get someone on the faculty to be enthusiastic about my application. But to do that I have to say something like, "What I'm doing is related to the work of [insert name of faculty member]..."

Actually some of the job descriptions explicitly say that they prefer candidates that match the interests of the department. Why would a department hire candidate X, who works in some out of left field area, when they can hire candidate Y, who works on something that interests faculty there?

It seems that it is not enough to just do good research to stand out. I have to persuade the faculty that I should be hired over everyone else.
First of all:

In other words, I think I need to get someone on the faculty to be enthusiastic about my application.
It seems that it is not enough to just do good research to stand out. I have to persuade the faculty that I should be hired over everyone else.

Yes. That is literally the definition of a job interview. If you get the job, then nobody else will. So you do have to convince the deciding people that you should be hired before over anyone else. You do not earn magic job-points when you do good research that you can cash in at your local university to get a free job. You have to convince the hiring people that you should be hired. I do not understand why you would state this as if this were some terrible hidden secret about academia. It works like this everywhere. I'm sorry to be so blunt, but you are going to have real problems getting a job if you keep this attitude.

But sometimes I don't know who the faculty are, I've never met them at a conference, etc. My feeling is that if I work on something that none of the faculty are particularly interested in, that will sink my application.

The onus is on you to get yourself informed about who the professors at that institution are. Why are you applying there at all? There must be a reason. If this is a personal reason rather than an academic one (e.g. &quot;it's my hometown&quot;, &quot;my fiancée works in this city&quot;, &quot;I like the beach&quot;...) then this will definitely be a hindrance unless you can find a way to turn this into a positive.
Not knowing anybody at the institution will not necessarily &quot;sink&quot; your application. But it will handicap you, for sure. They don't want to a complete stranger that will do research that doesn't interest them. They would much rather hire someone to whom they can at the very least talk to about research.

Actually some of the job descriptions explicitly say that they prefer candidates that match the interests of the department. Why would a department hire candidate X, who works in some out of left field area, when they can hire candidate Y, who works on something that interests faculty there?

Why indeed? If even you cannot answer this question, there is a real problem.