First please check that chain1@172.31.31.111:4287 is the correct node address for the other node. You can see this by looking at the address it outputs when it starts up, or using the getinfo command.
Second, you may indeed need to check the firewall settings on that computer, that it allows incoming connections on the port 4287. By default many Linux systems don't allow incoming traffic on any port and you need to explicitly open them.