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
• 18,570 points
1,427 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
• 52,360 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 6, 2018 in Other DevOps Questions by DareDev
• 6,890 points
648 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
381 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, 2019 in Other DevOps Questions by Yesha
585 views
0 votes
1 answer

Is CCNA a big plus while applying for a DevOps job because networking knowledge comes in handy?

Hii amit, Actually now a days Cloud Computing is a ...READ MORE

answered Apr 20, 2020 in Other DevOps Questions by Niroj
• 82,880 points
2,366 views
+1 vote
1 answer
+15 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,526 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
1,452 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
• 52,360 points
727 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP