Port 27017 closed for security reasons

You’re probably only running MongoDB on the internal interface.

See in mongod.conf:

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1  # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.