I have listed a few free public and private MQTT brokers that you can use for testing or prototyping.

 

Private MQTT Broker: In a private broker, only devices that you set can publish and subscribe to the topics on the broker. You should use this for production & prototyping.

Public MQTT Broker: In a public broker, any device can publish and subscribe to topics on the broker. There is no privacy. Public brokers should never be used in production. If you simply want to learn or play around with MQTT then use this.

If you want to install your own broker on your computer or virtual machine see this:
Installing Mosquitto Broker ob Ubuntu/Windows/Debian

The information in the tables were last updated on April 7th 2020.

Public MQTT Brokers

Name Broker Address TCP Port TLS Port WebSocket Port Message Retention Persistent Session Sign Up Requred Link
Eclipse mqtt.eclipse.org 1883 N/A 80, 443 YES YES NOLink
Mosquitto test.mosquitto.org 1883 8883, 8884 80 YES YES NOLink
HiveMQ broker.hivemq.com 1883 N/A 8000 YES YES NOLink
Flespi mqtt.flespi.io 1883 8883 80, 443 YES YES YESLink
Dioty mqtt.dioty.co 1883 8883 8080, 8880 YES YES YESLink
Fluux mqtt.fluux.io 1883 8883 N/A N/A N/A NOLink
EMQX broker.emqx.io 1883 8883 8083 YES YES NOLink

Private MQTT Brokers

Name TCP Port TLS Port WebSocket Port Message Retention Persistent Session QoS Levels Free Limits Link
Azure NO 8883 443 NO Limited 0, 1 8000 messages/dayLink
AWS NO 8883 443 NO Limited 0, 1 250,000/monthLink
CloudMQTT Custom Port Custom Port Custom Port NOT SURE YES 0, 1, 2 5 Connections & 10 Kbit/sLink

Also, see:
5 Best MQTT Clients For Testing