# (AWS Linux) Failed to connect to localhost port 9200: Connection refused

**URL:** https://discuss.elastic.co/t/aws-linux-failed-to-connect-to-localhost-port-9200-connection-refused/140271
**Category:** Elasticsearch
**Created:** [July 17, 2018, 7:55am UTC](https://discuss.elastic.co/t/aws-linux-failed-to-connect-to-localhost-port-9200-connection-refused/140271 "2018-07-17T07:55:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![justintranjt](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@justintranjt](https://discuss.elastic.co/u/justintranjt)
#### Post date: [July 17, 2018, 7:55am UTC](https://discuss.elastic.co/t/aws-linux-failed-to-connect-to-localhost-port-9200-connection-refused/140271/1 "2018-07-17T07:55:35Z")

</div>

I am unable to start my elasticsearch service successfully despite a correctly configured elasticsearch.yml file. I have only uncommented one line and edited it.

`network.host: "localhost"`

I start my service with _sudo service elasticsearch start_ and I attempt to curl to [http://localhost:9200](http://localhost:9200). I then received a message saying _curl: (7) Failed to connect to localhost port 9200: Connection refused_. This is what I see in _systemctl status elasticsearch_

` ● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2018-07-17 07:41:22 UTC; 2s ago
Docs: http://www.elastic.co
Process: 2988 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet (code=exited, status=1/FAILURE)
Main PID: 2988 (code=exited, status=1/FAILURE)`

Jul 17 07:41:22 ip-172-31-32-121 elasticsearch[2988]: at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)  
Jul 17 07:41:22 ip-172-31-32-121 elasticsearch[2988]: at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)  
Jul 17 07:41:22 ip-172-31-32-121 elasticsearch[2988]: at java.nio.file.Files.newByteChannel(Files.java:361)  
Jul 17 07:41:22 ip-172-31-32-121 elasticsearch[2988]: at java.nio.file.Files.newByteChannel(Files.java:407)  
Jul 17 07:41:22 ip-172-31-32-121 elasticsearch[2988]: at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)  
Jul 17 07:41:22 ip-172-31-32-121 elasticsearch[2988]: at java.nio.file.Files.newInputStream(Files.java:152)  
Jul 17 07:41:22 ip-172-31-32-121 elasticsearch[2988]: at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:58)  
Jul 17 07:41:22 ip-172-31-32-121 systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE  
Jul 17 07:41:22 ip-172-31-32-121 systemd[1]: elasticsearch.service: Unit entered failed state.  
Jul 17 07:41:22 ip-172-31-32-121 systemd[1]: elasticsearch.service: Failed with result 'exit-code'.

---

<div class="post-metadata">

### Author: ![tdasch](https://avatars.discourse-cdn.com/v4/letter/t/58f4c7/32.png) [@tdasch](https://discuss.elastic.co/u/tdasch)
#### Post date: [July 17, 2018, 5:20pm UTC](https://discuss.elastic.co/t/aws-linux-failed-to-connect-to-localhost-port-9200-connection-refused/140271/2 "2018-07-17T17:20:24Z")

</div>

Was your node every running successfully or was this a first attempt? Could you share your logs for Elasticsearch please? Should be located in /var/log/elasticsearch

---

<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: [August 14, 2018, 5:20pm UTC](https://discuss.elastic.co/t/aws-linux-failed-to-connect-to-localhost-port-9200-connection-refused/140271/3 "2018-08-14T17:20:35Z")

</div>

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