MavProxy not connecting after installing Gazebo plugin

I was following the SITL instructions on the main docs site (Setting up SITL on Linux — Dev documentation); i am on Ubuntu 20.04. I got the SITL with MavProxy working just like in the instructions; the command --console --map launching everything as the last step.

I then moved on to get it to work with Gazebo following Using Gazebo Simulator with SITL — Dev documentation, I installed Gazebo9, the dev dependencies, the khancyr gazebo plugin.

Launching Gazebo with gazebo --verbose worlds/ and then the SITL with

cd ~/ardupilot/ArduPlane
…/Tools/autotest/ -f gazebo-zephyr --console --map

I get an error

SIM_VEHICLE: “” “–map” “–console” “–out” “” “–out” “” “–master” “tcp:” “–sitl” “”
RiTW: Starting ArduPlane : /home/hermamr1/ardupilot/build/sitl/bin/arduplane -S --model gazebo-zephyr --speedup 1 --slave 0 --defaults /home/hermamr1/ardupilot/Tools/autotest/default_params/gazebo-zephyr.parm -I0
Connect tcp: source_system=255
[Errno 111] Connection refused sleeping
[Errno 111] Connection refused sleeping
[Errno 111] Connection refused sleeping
[Errno 111] Connection refused sleeping
Failed to connect to tcp: : [Errno 111] Connection refused
SIM_VEHICLE: Killing tasks

It seems that MavProxy isn’t connecting with the SITL anymore? But I am not sure why that would be. And now when I try to run without Gazebo using the steps at the top of my post I get the same error; so it seems not related to Gazebo, but happened after trying to use Gazebo for the first time?

Why would I get this error, I am really new to ArduPilot and ArduPlane so maybe it’s something real obvious I am missing but stepping through everything I did I can’t figure it out.

After some debugging, I determined the problem. The startup script /Tools/autotest/ starts mavproxy and then mavproxy will attempt to connect for a short time before failing, closing and then causing to end. The issue is if Arduplane hasn’t completely started to the point of waiting for connections then mavproxy has nothing to connect to causing the above failure and premature shutdown. In most cases I doubt this happens to most people, Arduplane starts up quick; however, I was observing that on an SSH connection with a higher latency than one sees on a local network that Arduplane does take an extra amount of time to fully start and causes failure. I sleep() in sim_vehicle before starting mavproxy solved my issue; however, that is not ideal. An issue was created, could start mavproxy before ArduPlane has started and is waiting for connection causing premature exit · Issue #19314 · ArduPilot/ardupilot · GitHub.