MQTT remains connecting while settings have been changed

when you deploy a change to a node, it is destroyed and re-created.

Then you either dont have the settings correct or it is unreachable.

Are you using latest Node-RED?

You can also try dynamic connection and disconnect actions while testing. Demo here: Dynamic MQTT node's "actions->connect" guidance needed - #2 by Steve-Mcl