This question already has an answer here:
I have a home server running Ubuntu 16.04 Server Edition. I have a couple ports that my router forwards to my server and
ufw on my server allows so that I can access the services outside the LAN - namely, SSH on a custom port (as the router blocks port 22 for forwarding) and ports 80 and 443 for HTTP and HTTPS for my web server. I want to open a port for development purposes - specifically, port 9991, which is not associated with any particular service/protocol. Most of the time, the development server listening on this port will not be running. However, the router will still forward requests on this port to the server, which will still be allowed by
ufw. If there is no service listening on the port, yet it is open to incoming connections, is there a security threat?