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,090 points
181 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
• 39,270 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
29 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
36 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
31 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,280 points
31 views
0 votes
1 answer
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
112 views
+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
66 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
• 39,270 points
57 views