Deductions & credits

The rules are spelled out exactly in the publication previously mentioned.  Did you read the entire discussion before you posted?

https://www.irs.gov/pub/irs-pdf/p523.pdf

 

You can qualify for a partial exclusion if you moved due to a "hardship".  The IRS provides several specific definitions of qualifying hardships, so-called safe harbors.  If you meet the exact rules in one of the safe harbors, you qualify.  If you don't meet a safe harbor, you are not necessarily prevented from using the partial exclusion, but you will not receive the benefit of the doubt if audited and you will have to strongly prove your case.

 

The "moved for a job rule" says specifically this:

 

  • You took or were transferred to a new job in a work location at least 50 miles farther from the home than your old work location. For example, your old work location was 15 miles from the home and your new work location is 65 miles from the home.

So not merely 50 miles away, but 50 miles farther than the old job (making your commute 50 miles longer than it was before.)