# Failed to connect to localhost port 9200: Connection refused，----elasticsearch SETUP

**URL:** https://discuss.elastic.co/t/failed-to-connect-to-localhost-port-9200-connection-refused-elasticsearch-setup/225092
**Category:** Elasticsearch
**Created:** [March 26, 2020, 1:16am UTC](https://discuss.elastic.co/t/failed-to-connect-to-localhost-port-9200-connection-refused-elasticsearch-setup/225092 "2020-03-26T01:16:22Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Jennifer](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@Jennifer](https://discuss.elastic.co/u/Jennifer)
#### Post date: [March 26, 2020, 1:16am UTC](https://discuss.elastic.co/t/failed-to-connect-to-localhost-port-9200-connection-refused-elasticsearch-setup/225092/1 "2020-03-26T01:16:23Z")

</div>

oot@ubuntu1804:/usr/local/elasticsearch-7.6.1# /etc/init.d/elasticsearch start  
No passwd entry for user 'elsearch'  
elasticsearch is started  
root@ubuntu1804:/usr/local/elasticsearch-7.6.1# /usr/local/elasticsearch-7.6.1  
bash: /usr/local/elasticsearch-7.6.1: Is a directory  
root@ubuntu1804:/usr/local/elasticsearch-7.6.1# curl -XGET [http://localhost:9200](http://localhost:9200)  
curl: (7) Failed to connect to localhost port 9200: Connection refused  
root@ubuntu1804:/usr/local/elasticsearch-7.6.1# /etc/init.d/elasticsearch start  
No passwd entry for user 'elsearch'  
elasticsearch is started  
root@ubuntu1804:/usr/local/elasticsearch-7.6.1/config# curl -XGET [http://localhost:9200](http://localhost:9200)  
curl: (7) Failed to connect to localhost port 9200: Connection refused

/usr/local/elasticsearch-7.6.1/config/elasticsearch.yml

# ------------------------------------ Node ------------------------------------

# 

# Use a descriptive name for the node:

# 

#node.name: node-1#自己的节点主机名  
node.name: elasticsearch

#node.attr.rack: r1

# ----------------------------------- Paths ------------------------------------

# 

# Path to directory where to store the data (separate multiple locations by comma):

# 

path.data: /var/lib/elasticsearch

# 

# Path to log files:

# 

path.logs: /var/log/elasticsearch

# 

# ----------------------------------- Memory -----------------------------------

# 

# Lock the memory on startup:

# 

#bootstrap.memory\_lock: true

# 

# Make sure that the heap size is set to about half the memory available

# on the system and that the owner of the process is allowed to use this

# limit.

# 

# Elasticsearch performs poorly when the system is swapping the memory.

# 

# ---------------------------------- Network -----------------------------------

# 

# Set the bind address to a specific IP (IPv4 or IPv6):

# 

network.host:127.0.0.1

# 

# Set a custom port for HTTP:

# 

http.port: 9200

# For more information, consult the network module documentation.

#

---

<div class="post-metadata">

### Author: ![Jennifer](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@Jennifer](https://discuss.elastic.co/u/Jennifer)
#### Post date: [March 26, 2020, 1:19am UTC](https://discuss.elastic.co/t/failed-to-connect-to-localhost-port-9200-connection-refused-elasticsearch-setup/225092/2 "2020-03-26T01:19:40Z")

</div>

When I started elasticsearch,these two folder have not generated. I do not known why.  
path.data: /var/lib/elasticsearch  
path.logs: /var/log/elasticsearch

---

<div class="post-metadata">

### Author: ![Yang\_Wang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yang_wang/32/48857_2.png) [@Yang\_Wang](https://discuss.elastic.co/u/Yang_Wang)
#### Post date: [March 26, 2020, 5:22am UTC](https://discuss.elastic.co/t/failed-to-connect-to-localhost-port-9200-connection-refused-elasticsearch-setup/225092/3 "2020-03-26T05:22:53Z")

</div>

> No passwd entry for user 'elsearch'

The above error message looks suspicious. Have you manually edit the `/etc/init.d/elasticsearch` file?

You could also check whether there are any error messages from systemd with  
`journalctl -u elasticsearch -b`

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [March 26, 2020, 7:17am UTC](https://discuss.elastic.co/t/failed-to-connect-to-localhost-port-9200-connection-refused-elasticsearch-setup/225092/4 "2020-03-26T07:17:21Z")

</div>

Welcome!

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

This is the icon to use if you are not using markdown format:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.  
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.  
Please update your post.

---

<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: [April 23, 2020, 7:17am UTC](https://discuss.elastic.co/t/failed-to-connect-to-localhost-port-9200-connection-refused-elasticsearch-setup/225092/5 "2020-04-23T07:17:25Z")

</div>

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