# Connection to localhost refused

**URL:** <https://community.icinga.com/t/connection-to-localhost-refused/3493>\
**Category:** Service Monitoring\
**Tags:** ssh\
**Created:** [February 13, 2020, 2:46pm UTC](https://community.icinga.com/t/connection-to-localhost-refused/3493 "2020-02-13T14:46:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwmentor](https://community.icinga.com/user_avatar/community.icinga.com/mwmentor/32/2036_2.png) [@mwmentor](https://community.icinga.com/u/mwmentor)\
**Post date:** [February 13, 2020, 2:46pm UTC](https://community.icinga.com/t/connection-to-localhost-refused/3493/1 "2020-02-13T14:46:12Z")

</div>

Hi there:

I am in the process of completing my first Icinga2 server which has gone well barring one small wrinkle. I am getting an error stating the following:

> connect to address 127.0.0.1 and port 22: Connection refused

So I understand that I have set a custom SSH port on the server platform (Ubuntu 18.04) that I have installed in on which is pretty standard. So I understand the error and have been trying to find out where to change the default port. I am not 100% sure so I thought that I would ask if someone could help.

That would be great 🙂

Thanks so much and I apologies if this is posted to the wrong topic.  
-Michael

---

<div class="post-metadata">

**Author:** ![Pooh](https://community.icinga.com/letter_avatar_proxy/v4/letter/p/f05b48/32.png) [@Pooh](https://community.icinga.com/u/Pooh)\
**Post date:** [February 13, 2020, 3:02pm UTC](https://community.icinga.com/t/connection-to-localhost-refused/3493/2 "2020-02-13T15:02:29Z")

</div>

> Hi there:
> 
> I am in the process of completing my first Icinga2 server which has gone well  
> barring one small wrinkle. I am getting an error stating the following:
> 
> > connect to address 127.0.0.1 and port 22: Connection refused
> 
> So I understand that I have set a custom SSH port on the server platform  
> (Ubuntu 18.04) that I have installed in on which is pretty standard. So I  
> understand the error and have been trying to find out where to change the  
> default port.

Define ssh\_port in your service check.

[https://icinga.com/docs/icinga2/latest/doc/10-icinga-template-library/#ssh](https://icinga.com/docs/icinga2/latest/doc/10-icinga-template-library/#ssh)

Antony.

---

<div class="post-metadata">

**Author:** ![mwmentor](https://community.icinga.com/user_avatar/community.icinga.com/mwmentor/32/2036_2.png) [@mwmentor](https://community.icinga.com/u/mwmentor)\
**Post date:** [February 13, 2020, 9:23pm UTC](https://community.icinga.com/t/connection-to-localhost-refused/3493/3 "2020-02-13T21:23:15Z")

</div>

Hi Antony:

Thanks so much… I adjusted the services.conf file as follows:

> check\_command = “ssh”  
> vars.ssh\_port = xxxx

I decided that would be okay because the port I use is fairly universal… 😃

Thanks for pushing me in the right direction… I appreciate it.  
-Michael

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [February 14, 2020, 9:23am UTC](https://community.icinga.com/t/connection-to-localhost-refused/3493/4 "2020-02-14T09:23:31Z")

</div>

Hi,

keep in mind that a local SSH check doesn’t prove much though 😉 It is just an example to show you some basic checks and how they can be done. For more services and their monitoring, you’ll truly learn more after the basics in the “service monitoring” chapter 🙂

Cheers,  
Michael
