# Curl: (7) Failed to connect to 1.x.x.x port 5601: Connection refused

**URL:** <https://discuss.elastic.co/t/curl-7-failed-to-connect-to-1-x-x-x-port-5601-connection-refused/146848>\
**Category:** Kibana\
**Created:** [August 31, 2018, 10:49am UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect-to-1-x-x-x-port-5601-connection-refused/146848 "2018-08-31T10:49:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jawad846](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@jawad846](https://discuss.elastic.co/u/jawad846)\
**Post date:** [August 31, 2018, 10:49am UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect-to-1-x-x-x-port-5601-connection-refused/146848/1 "2018-08-31T10:49:55Z")

</div>

Hi guys,

I had install elasticsearch and kibana on ec2 instance.

If I run locally both elasticsearch and kibana working

```
[ec2-user@ip-10-0-1-168 ~]$ curl http://localhost:9200
{
  "name" : "_MF1kzR",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "Gm_7rlYySiCFPBUWi1QmDw",
  "version" : {
    "number" : "6.4.0",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "595516e",
    "build_date" : "2018-08-17T23:18:47.308994Z",
    "build_snapshot" : false,
    "lucene_version" : "7.4.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

```

Kibana

```
[ec2-user@ip-10-0-1-168 ~]$ curl http://localhost:5601
&lt;script&gt;var hashRoute = '/app/kibana';
var defaultRoute = '/app/kibana';
var hash = window.location.hash;
if (hash.length) {
window.location = hashRoute + hash;
} else {
window.location = defaultRoute;
}&lt;/script&gt;
[ec2-user@ip-10-0-1-168 ~]$

```

I think that it's running loaclly but, When i access in browser its not working

```
[ec2-user@ip-10-0-1-168 ~]$ sudo service kibana status

kibana is not running

[ec2-user@ip-10-0-1-168 ~]$ sudo service kibana restart 

kibana started

[ec2-user@ip-10-0-1-168 ~]$ sudo service kibana status

kibana is not running

```

I accessed by other machine through curl, getting the output:

```
curl: (7) Failed to connect to 1.x.x.x port 5601: Connection refused`

```

Please help me to solve this

for refference

kibana.yml

```
server.port: 5601
server.host: 127.0.0.1
elasticsearch.url: "http://localhost:9200"

```

permission

```
[ec2-user@ip-10-0-1-168 ~]$ ls -al /usr/share/kibana/optimize/
total 10984
drwxrwxr-x 3 kibana root 45 Aug 30 11:06 .
drwxr-xr-x 9 root root 203 Aug 30 11:06 ..
-rw-r--r-- 1 kibana root 11238322 Aug 31 10:45 .babelcache.json
drwxrwxr-x 3 root root 4096 Aug 30 11:06 bundles

```

vim /var/log/kibana/kibana.stderr

```
FATAL Port 5601 is already in use. Another instance of Kibana may be running!
FATAL Port 5601 is already in use. Another instance of Kibana may be running!
FATAL Port 5601 is already in use. Another instance of Kibana may be running!
FATAL Port 5601 is already in use. Another instance of Kibana may be running!
FATAL Port 5601 is already in use. Another instance of Kibana may be running!
FATAL Port 5601 is already in use. Another instance of Kibana may be running!

```

vim /var/log/kibana/kibana.stdout

```
{"type":"error","@timestamp":"2018-08-31T10:45:23Z","tags":["warning","process"],"pid":12038,"level":"error","error":{"message":"Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)","name":"UnhandledPromiseRejectionWarning","stack":"Error: listen EADDRINUSE 127.0.0.1:5601\n at Object._errnoException (util.js:992:11)\n at _exceptionWithHostPort (util.js:1014:20)\n at Server.setupListenHandle [as _listen2] (net.js:1355:14)\n at listenInCluster (net.js:1396:12)\n at doListen (net.js:1505:7)\n at _combinedTickCallback (internal/process/next_tick.js:141:11)\n at process._tickCallback (internal/process/next_tick.js:180:9)"},"message":"Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)"}
{"type":"log","@timestamp":"2018-08-31T10:45:23Z","tags":["fatal"],"pid":12038,"message":"Port 5601 is already in use. Another instance of Kibana may be running!"}
```

---

<div class="post-metadata">

**Author:** ![\_Alex](https://avatars.discourse-cdn.com/v4/letter/_/54ee81/32.png) [@\_Alex](https://discuss.elastic.co/u/_Alex)\
**Post date:** [August 31, 2018, 11:03am UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect-to-1-x-x-x-port-5601-connection-refused/146848/2 "2018-08-31T11:03:54Z")

</div>

> [@jawad846](#):
>
> server.host: 127.0.0.1

This is likely the problem. A process listening on localhost will only be accessible from that PC. If you change this line to:

```
server.host: 10.0.1.168

```

This will listen on the externally facing interface and you should be able to access. You can verify this by running `lsof -Pi :5601`. A process listening only on localhost:

```
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nc 4731 root 3u IPv4 30860 0t0 TCP localhost:5601 (LISTEN)

```

Versus a process listening on both localhost externally (note the `10.0.1.168` instead of `localhost`):

```
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nc 4787 root 4u IPv4 31641 0t0 TCP 10.0.1.168:5601 (LISTEN)

```

---

<div class="post-metadata">

**Author:** ![jawad846](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@jawad846](https://discuss.elastic.co/u/jawad846)\
**Post date:** [August 31, 2018, 11:08am UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect-to-1-x-x-x-port-5601-connection-refused/146848/3 "2018-08-31T11:08:15Z")

</div>

> [@\_Alex](#):
>
> lsof -Pi :5601

thanks for replay

now kibana running fine

```
[ec2-user@ip-10-0-1-168 ~]$ sudo service kibana status

kibana is running

[ec2-user@ip-10-0-1-168 ~]$ sudo service kibana status

kibana is running

[ec2-user@ip-10-0-1-168 ~]$ sudo service kibana status

```

and

```
[ec2-user@ip-10-0-1-168 ~]$ sudo lsof -Pi :5601
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 2813 kibana 10u IPv4 21150 0t0 TCP localhost:5601 (LISTEN)
node 3960 kibana 9u IPv4 22099 0t0 TCP ip-10-0-1-168.ap-south-1.compute.internal:5601 (LISTEN)

```

but cann't access by browser

---

<div class="post-metadata">

**Author:** ![jawad846](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@jawad846](https://discuss.elastic.co/u/jawad846)\
**Post date:** [August 31, 2018, 11:10am UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect-to-1-x-x-x-port-5601-connection-refused/146848/4 "2018-08-31T11:10:19Z")

</div>

Thanks @_Alex

done

thanks lot

---

<div class="post-metadata">

**Author:** ![jawad846](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@jawad846](https://discuss.elastic.co/u/jawad846)\
**Post date:** [August 31, 2018, 11:37am UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect-to-1-x-x-x-port-5601-connection-refused/146848/5 "2018-08-31T11:37:19Z")

</div>

hi @_Alex

now am getting

 ![48%20PM](https://us1.discourse-cdn.com/elastic/original/3X/7/4/742354c33f7c859c639ac05b06a9a2219a52cfb0.png)

vim /var/log/kibana/kibana.stderr

```
Unhandled rejection Error: No Living connections
    at sendReqWithConnection (/usr/share/kibana/node_modules/elasticsearch/src/lib/transport.js:225:15)
    at next (/usr/share/kibana/node_modules/elasticsearch/src/lib/connection_pool.js:213:7)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)
Unhandled rejection Error: No Living connections
    at sendReqWithConnection (/usr/share/kibana/node_modules/elasticsearch/src/lib/transport.js:225:15)
    at next (/usr/share/kibana/node_modules/elasticsearch/src/lib/connection_pool.js:213:7)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)

```

Can u please help out this

this happed when i edited vim /etc/elasticsearch/elasticsearch.yml

from  
network.host: "localhost"  
to  
network.host: "10.0.1.168"

because i want to use lambda

---

<div class="post-metadata">

**Author:** ![\_Alex](https://avatars.discourse-cdn.com/v4/letter/_/54ee81/32.png) [@\_Alex](https://discuss.elastic.co/u/_Alex)\
**Post date:** [August 31, 2018, 1:57pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect-to-1-x-x-x-port-5601-connection-refused/146848/6 "2018-08-31T13:57:48Z")

</div>

This is the same problem now, but the other way round. You have elastic listening on the external interface but you're trying to connect using localhost. Just remember:

- If the process is listening on localhost, you need to connect to localhost
- If the process is listening on 10.x.x.x, you need to connect to 10.x.x.x

---

<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:** [September 28, 2018, 1:57pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect-to-1-x-x-x-port-5601-connection-refused/146848/7 "2018-09-28T13:57:52Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
