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

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
<script>var hashRoute = '/app/kibana';
var defaultRoute = '/app/kibana';
var hash = window.location.hash;
if (hash.length) {
window.location = hashRoute + hash;
} else {
window.location = defaultRoute;
}</script>
[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!"}

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)
1 Like

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

Thanks @_Alex

done

thanks lot

hi @_Alex

now am getting

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

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
1 Like

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