Updated server to check the environment for a port