I’m trying to connect to a Greenbone VM via Python using the gvm library (TLSConnection + Gmp) from another VM (VMware). Connection fails with a ConnectionRefusedError.
Environment:
-
Greenbone VM IP:
192.xxx.xxx.xxx -
GMP port:
9390 -
Python 3.14 (Windows 11, running in PyCharm virtual environment)
-
gvmlibrary installed in venv
Python code (main.py):
from gvm.connections import TLSConnection
from gvm.protocols.gmp import Gmp
import yaml
def load_config(path="config/config.yaml"):
with open(path, "r") as f:
return yaml.safe_load(f)
def main():
cfg = load_config()
gmp_cfg = cfg["gmp"]
connection = TLSConnection(hostname=gmp_cfg["host"], port=gmp_cfg["port"])
try:
connection.connect()
with Gmp(connection=connection) as gmp:
gmp.authenticate(username=gmp_cfg["username"], password=gmp_cfg["password"])
print("✅ Connected and authenticated!")
tasks_xml = gmp.get_tasks(filter_string="rows=5")
finally:
connection.disconnect()
if __name__ == "__main__":
main()
Config (config/config.yaml):
gmp:
host: "192.xxx.xxx.xxx"
port: 9390
username: "xxx"
password: "xxx"
Error message:
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
...
ValueError: No SSL wrapper around <ssl.SSLSocket ...>
What I’ve checked:
-
Greenbone VM is reachable via ping
-
GMP port 9390 is open
-
Both VMs are in the same network (VMware)
Question:
Why does TLSConnection.connect() fail with ConnectionRefusedError? Is there something wrong with TLS, firewall, or GMP configuration? Any guidance on connecting via Python would be appreciated.