Setting up local broker

I am a beginner with mqtt and EMQX and would like to send data from an esp32 using micropython to my local host. I have managed to set up the broker and have tested it using mqttx, however I ran into a few errors when trying from the esp32 ([Errno 113] ECONNABORTED).

I would like some guidance on how to solve this, here is my code snippet:

import time
from adxl import ADXL345
from machine import Pin, SoftI2C
import network
from umqtt.simple import MQTTClient
import json
import network

print(“Running”)
ssid = ‘xxx’
password = ‘xxx’

wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
while not wlan.isconnected():
pass

print(“Connected to WiFi”)
print(‘network config:’, wlan.ifconfig())
i2c = SoftI2C(scl = Pin(22), sda = Pin(21),freq = 400000)
accelerometer = ADXL345(i2c)
accelerometer.data_rate(0x0D)

mqtt_broker = “xx.xxx.xx.xxx”
mqtt_port = 1883
mqtt_topic = b"accelerometer_data"
user = “esp”
password = “pass”

mqtt_client = MQTTClient(“esp_adxl”, mqtt_broker, mqtt_port, user, password)
try:
mqtt_client.connect()
print(“Connected to MQTT broker”)
except OSError as e:
print(“Error connecting to MQTT broker:”, e)

while True:
x, y, z = accelerometer.acceleration()
payload = json.dumps({“x”: x, “y”: y, “z”: z})
mqtt_client.publish(mqtt_topic, payload)
print("Published: ", payload)
time.sleep(0.01)

thank you