Connection refused - connect(2) for “localhost” port 25 chef devops

+1 vote

I am working on chef where I have a helper library with the following code

require 'net/smtp'
 module HandlerSendEmail
class Helper
def send_email_on_run_failure(node_name)
  message = "From: Chef <chef@chef.io>\n"
  message << "To: Grant <xyz@test.com>\n"
  message << "Subject: Chef run failed\n"
  message << "Date: #{Time.now.rfc2822}\n\n"
  message << "Chef run failed on #{node_name}\n"
  Net::SMTP.start('localhost', 25) do |smtp|
    smtp.send_message message, 'chef@chef.io', 'xyz@test.com'
  end
end

But when I run the recipe I get

Chef Client failed. 0 resources updated in 02 seconds
[2017-10-30T05:19:38+00:00] ERROR: Connection refused - connect(2) for "localhost" port 25
[2017-10-30T05:19:38+00:00] ERROR: Connection refused - connect(2) for "localhost" port 25

what do I do?

Jul 25, 2018 in Other DevOps Questions by Hannah
• 14,080 points
171 views

1 answer to this question.

0 votes
With the information that you’ve provided it looks like you don’t have an actual SMTP server on your localhost. You would need an actual SMTP server connection on the localhost.
answered Jul 25, 2018 by Kalgi
• 37,320 points

Related Questions In Other DevOps Questions

0 votes
1 answer

how to check runtime for chef-client executions?

 Chef doesn't have the mechanism to save ...READ MORE

answered Jul 5, 2018 in Other DevOps Questions by DareDev
• 6,810 points
25 views
0 votes
1 answer

How do I enable Slack for Bluemix DevOps services beta

Here is where you can take help ...READ MORE

answered Jul 11, 2018 in Other DevOps Questions by Atul
• 10,240 points
32 views
0 votes
1 answer

Why is continuous testing so important for devops?

Continuous Testing allows any change made in ...READ MORE

answered Feb 18 in Other DevOps Questions by Yesha
26 views
0 votes
1 answer

Unable to create BlueMix DevOps services account

Jazzhub is shut now. try https://console.bluemix.net/devops/getting-started. It's ...READ MORE

answered May 28, 2018 in Other DevOps Questions by ajs3033
• 7,240 points
28 views
0 votes
1 answer
+13 votes
2 answers
+3 votes
6 answers

Devops and security

By using tools that are shared across the ...READ MORE

answered Oct 23, 2018 in Other DevOps Questions by Anvit
55 views
0 votes
1 answer

SonarQube cannot connect to JIRA 7 with REST API

The JIRA Plugin is not compatible with JIRA 7 ...READ MORE

answered Jul 5, 2018 in Other DevOps Questions by Kalgi
• 37,320 points
46 views