# How to bind port with Logstash service?

**URL:** <https://discuss.elastic.co/t/how-to-bind-port-with-logstash-service/27635>\
**Category:** Logstash\
**Created:** [August 19, 2015, 5:28am UTC](https://discuss.elastic.co/t/how-to-bind-port-with-logstash-service/27635 "2015-08-19T05:28:37Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![thyfere](https://avatars.discourse-cdn.com/v4/letter/t/48db29/32.png) [@thyfere](https://discuss.elastic.co/u/thyfere)\
**Post date:** [August 19, 2015, 5:28am UTC](https://discuss.elastic.co/t/how-to-bind-port-with-logstash-service/27635/1 "2015-08-19T05:28:37Z")

</div>

Hi,

I hope everyone is doing great. I am very new to ELK stack and deploying it on two virtual machines. One is for Logstash and the other is for Kibana and Elastic search.

OS is Windows Server 2012 R2. I am setting up the ELK stack on my Windows boxes by following this guide: [https://www.ulyaoth.net/resources/tutorial-install-logstash-and-kibana-on-a-windows-server.34/](https://www.ulyaoth.net/resources/tutorial-install-logstash-and-kibana-on-a-windows-server.34/)

The only difference is that author has deployed stack on one machine but I am setting up two. Now, when I run the Logstash, it doesn't bind the port that is mention in logstash.conf, i.e. 5544.

I am using nxlog for logs forwarding. The machine where nxlog is installed throwing an error, i.e. "couldn't connect to tcp socket on 192.195.88.223:5544; A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond."

I ran portqry on my logstash server, it's not listening on port 5544.

What could be the problem or how to bind port to logstash?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 19, 2015, 5:32am UTC](https://discuss.elastic.co/t/how-to-bind-port-with-logstash-service/27635/2 "2015-08-19T05:32:36Z")

</div>

What's your configuration? What's in the Logstash logs during startup? If it has problems binding to a port I'd expect there to be a big error message about that. Could there be a firewall blocking the access?

---

<div class="post-metadata">

**Author:** ![thyfere](https://avatars.discourse-cdn.com/v4/letter/t/48db29/32.png) [@thyfere](https://discuss.elastic.co/u/thyfere)\
**Post date:** [August 19, 2015, 7:02am UTC](https://discuss.elastic.co/t/how-to-bind-port-with-logstash-service/27635/3 "2015-08-19T07:02:28Z")

</div>

Thanks Magnus for prompt reply.

Here are the contents of logstash.conf:

input {  
tcp {

```
port => 5544

```

}  
}

output {  
elasticsearch {  
host =\> "192.195.88.229"  
protocol =\> "http"  
}  
}

I have created a service using nssm with these parameters:

logstansh.bat agent -f c:/logstash/bin/logstash.conf

Moreover, How can I enable debug logging for logstash?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 19, 2015, 7:07am UTC](https://discuss.elastic.co/t/how-to-bind-port-with-logstash-service/27635/4 "2015-08-19T07:07:41Z")

</div>

Start it with `--verbose` or `--debug`.

---

<div class="post-metadata">

**Author:** ![thyfere](https://avatars.discourse-cdn.com/v4/letter/t/48db29/32.png) [@thyfere](https://discuss.elastic.co/u/thyfere)\
**Post date:** [August 19, 2015, 7:16am UTC](https://discuss.elastic.co/t/how-to-bind-port-with-logstash-service/27635/5 "2015-08-19T07:16:29Z")

</div>

Is my conf file is okay? Sorry for stupid questions but I am very new to this stack. As a Windows admin, Linux stuff always freaks me out 🙂

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 19, 2015, 7:24am UTC](https://discuss.elastic.co/t/how-to-bind-port-with-logstash-service/27635/6 "2015-08-19T07:24:37Z")

</div>

Yes, the config file looks okay but I suggest you use a systematic approach and temporarily skip the elasticsearch output in favor of a simple stdout output to verify that the input works and that the messages look reasonable. Add complexity gradually.

---

<div class="post-metadata">

**Author:** ![thyfere](https://avatars.discourse-cdn.com/v4/letter/t/48db29/32.png) [@thyfere](https://discuss.elastic.co/u/thyfere)\
**Post date:** [August 19, 2015, 7:29am UTC](https://discuss.elastic.co/t/how-to-bind-port-with-logstash-service/27635/7 "2015-08-19T07:29:47Z")

</div>

Hi Again,

It looks like, it's working. I have omit the full path while mentioning logstash.conf and it started working. Thanks a lot for your help. Now, I have question that how can ship logs to logstash using Windows Events subscription and group policy? Should I create new discussion for it?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 19, 2015, 7:36am UTC](https://discuss.elastic.co/t/how-to-bind-port-with-logstash-service/27635/8 "2015-08-19T07:36:25Z")

</div>

Well, it's a different subject to please start a new topic.

---

<div class="post-metadata">

**Author:** ![thyfere](https://avatars.discourse-cdn.com/v4/letter/t/48db29/32.png) [@thyfere](https://discuss.elastic.co/u/thyfere)\
**Post date:** [August 19, 2015, 7:37am UTC](https://discuss.elastic.co/t/how-to-bind-port-with-logstash-service/27635/9 "2015-08-19T07:37:16Z")

</div>

Sure. Thanks.

---

<div class="post-metadata">

**Author:** ![prbreezy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prbreezy/32/7285_2.png) [@prbreezy](https://discuss.elastic.co/u/prbreezy)\
**Post date:** [January 20, 2016, 3:28pm UTC](https://discuss.elastic.co/t/how-to-bind-port-with-logstash-service/27635/10 "2016-01-20T15:28:14Z")

</div>

Hi

I face an issue on my Logstash :

I receive this error message with nxlog :

> 2016-01-20 15:22:23 INFO connecting to x.x.x.x:5140  
> 2016-01-20 15:22:24 INFO reconnecting in 200 seconds  
> 2016-01-20 15:22:24 ERROR couldn't connect to tcp socket on x.x.x.x:5140; No connection could be made because the target machine actively refused it.

I obviously understand that the nothing is liseting on this port but how I can be sure my logstash is properly setup to lisen on this port 5140 ?

Here my conf :

> input {  
> tcp {  
> port =\> 5140  
> type =\> "nxlog"  
> codec =\> line {  
> charset =\> "CP1252"  
> }  
> }  
> }

> filter {  
> if [type] == "nxlog" {  
> json {  
> source =\> "message"  
> }  
> mutate {  
> rename =\> ["Message", "message"]  
> # remove\_field =\> ["champ1", "champ2"]  
> }  
> }  
> }

> output {  
> stdout { debug =\> true }  
> }

I understand your point use --verbose to see what s going on with logstash but for windows I have no clue how to use it... I try net stat logstash --verbose \* but its not working.\*

My setup:  
Windows server 2012  
nxlog  
ELK (last binary) -\> all running on the same server

Thank you.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [January 20, 2016, 6:35pm UTC](https://discuss.elastic.co/t/how-to-bind-port-with-logstash-service/27635/11 "2016-01-20T18:35:26Z")

</div>

@prbreezy—please start a new topic for your question.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 5:15am UTC](https://discuss.elastic.co/t/how-to-bind-port-with-logstash-service/27635/12 "2017-07-06T05:15:02Z")

</div>


