When you sell ESPP stock, it is possible that you will owe both ordinary income tax as well as capital gains tax. This TurboTax help topic explains:
You shouldn't be taxed twice on the same dollars, though. For example, suppose the share price of ABC Corp is $100, and you acquire a share at a discount price of $80. Later you sell the share for $110. You have $20 of taxable compensation from working, and a $10 capital gain. That's normal. You should not be taxed on $30 of capital gains on top of paying the tax on $20 of compensation. If you think that is what happened, we will need some more details to help you figure out what happened.
Did the sale show up on the W-2 and the again on the 1099-B from the broker in the same tax year ? If so you need to adjust the cost basis on the 1099-B to reflect the taxes paid on the W-2. Your employer should have provided the cost basis for you if the broker doesn't have the correct information. Usually the 1099-B will show a loss in the amount of the broker's fee if it is done correctly.