MQTT Discovery Config Error

I’m having problems enabling MQTT discovery. I have MQTT working fine, if i put in the discovery config i get an error saying its unable to setup MQTT and owntracks. Ill post my working and non-working configs below. Any ideas what i’m doing wrong?

Not working config:

mqtt:
  discovery: true
  discovery_prefix: homeassistant
  broker: x.x.x.x
  port: xxxx
  client_id: home-assistant
  username: xxxxx
  password: xxxxx

device_tracker
  - platform: owntracks

Working config:

mqtt:
  broker: x.x.x.x
  port: xxx
  client_id: home-assistant
  username: xxxxx
  password: xxxxx

device_tracker
  - platform: owntracks