ESPHome 8266 ERROR Cannot connect to MQTT broker: [Errno 113] No route to host

Hi advise how to connect ESP using mqtt. He still writes this text to me in his log.

ERROR Cannot connect to MQTT broker: [Errno 113] No route to host

YAML:

substitutions:
  device_name: ESP-AirQuality
  friendly_name: ESP-AirQuality
  device_description: "AirQuality"

esphome:
  name: esp-airquality
  platform: ESP8266
  board: d1_mini

# Enable logging
logger:


ota:
  password: "pass"

wifi:
  fast_connect: on
  ssid: "wifissid"
  password: "wifipass"
  manual_ip:
    static_ip: 192.168.31.170
    gateway: 192.168.31.1
    subnet: 255.255.255.0

  ap:
    ssid: "Esp-Vodomer1 Fallback Hotspot"
    password: "EkoOcThOjgHY"

captive_portal:

mqtt:
  broker: 192.168.1.170
  port: 1883
  username: admin
  password: admin
  client_id: "${device_name}"

sensor:
# Wifi signal 
  - platform: wifi_signal
    name: "${friendly_name} - Signal"
    update_interval: 300s
    filters:
      - multiply: 1.0

Mosquitto broker Options:

logins:
  - username: admin
    password: admin
customize:
  active: false
  folder: mosquitto
certfile: fullchain.pem
keyfile: privkey.pem
require_certificate: false

esp is visible in routers
Where am I making a mistake?

Well it depends on the router. The MQTT Broker 192.168.1.170 is on a completely different subnet to the ESP device 192.168.31.170 - so there needs to be routing rules to allow the 2 different subnets to talk to each other. Have you done that?