Problem scenario
You run puppet agent but you get this error:
Error: Could not request certificate: Failed to open TCP connection to puppetmaster.domain.com:8140 (Connection refused - connect(2) for "puppetmaster.domain.com" port 8140)
What do you do?
Solution
Ensure port 8140 is open. Install nmap on a server, and run this command:
nmap -p 8140 puppetmaster.domain.com
If you see this
PORT STATE SERVICE
8140/tcp closed unknown
Then the Puppet Master service is not running. Start the puppet master service (e.g., sudo puppet master start). If you need help installing Puppet Master, see this link for Ubuntu and this link for RedHat.
If you get a message showing that port 8140 is filtered, change the Security Group (in AWS), the Network Security Group (in Azure) or the firewall between the two servers.