Depends if you are shooting crop sensor or full frame.
I'm thinking you are on a crop sensor, for which 50 is a nice range. 85mm is a great range for portraits on a full frame, and actually, some like to have a longer focal range for portraits.
I've used a 70-200 for portraits, shooting around 135mm on a 7D. Longer focal ranges tend to squish the image a bit, making it a bit more flattering for portraits. Wide angles make things look bigger, which is not always the best for portraits. And by portraits, I'm assuming you are doing either head shots or full body shots, but filling the frame with your subject.
So the 17-40 wouldn't be a great portrait lens (although don't let that stop you from exploring wide angle portraits, be creative!).
With that said... when purchasing a new lens, you need to know what your current lens lineup isn't doing for you. Shooting a 50 1.8 at say 2.8 will give nice sharpness and dof for portraits. The only I can think of for a wider portrait lens are portraits i tighter places, usually during weddings and events.
A 24-70 L lens (I know, you said no L) is great for portraits on a crop body. Gives you the wider for small groups and longer for tight in closeups with nice dof. An alternative to that can be the Tamron 28-75 f/2.8, should be in your budget. I've had mine for a few years and love it. Took me a few tries to get a sharp copy as quality control with 3rd party lenses isn't as strict as with the manufacturer lenses, but it can be an option.
For portraits:
50 1.4
85 1.8
135 2.0 L
24-70 2.8 L
Tamron 28-75 2.8
70-200 2.8 L