Getting Started with 7.9.2 on Debian 10

Hello, All!

I've installed Elasticsearch using the .tar.gz method onto my Debian 10 host. But when I attempt to verify that Elasticsearch is listening and responding to inquiries by sending an HTTP request to port 9200 on localhost I get this error:

eric@foobar:~/Projects/elasticsearch-7.9.2$ telnet 127.0.0.1 9200
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
GET /
HTTP/1.0 400 Bad Request
content-type: application/json; charset=UTF-8
content-length: 203

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"text is empty (possibly HTTP/0.9)"}],"type":"illegal_argument_exception","reason":"text is empty (possibly HTTP/0.9)"},"status":400}Connection closed by foreign host.

What's causing this error?

TIA,
Eric P.
Portland, Oregon

You need to specify the HTTP version in your request.

Use

GET / HTTP/1.0

You can also test using curl

curl 127.0.0.1:9200
1 Like

Thanks, Leandro! But specifying the version of HTTP just creates a different error:

No HTTP version information:
eric@foobar:~/Projects/elasticsearch-7.9.2$ telnet 127.0.0.1 9200
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
GET /
HTTP/1.0 400 Bad Request
content-type: application/json; charset=UTF-8
content-length: 203

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"text is empty (possibly HTTP/0.9)"}],"type":"illegal_argument_exception","reason":"text is empty (possibly HTTP/0.9)"},"status":400}Connection closed by foreign host.

When specifying HTTP version 1.0:
eric@foobar:~/Projects/elasticsearch-7.9.2$ telnet 127.0.0.1 9200
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
GET / HTTP/1.0
.
HTTP/1.0 400 Bad Request
content-type: application/json; charset=UTF-8
content-length: 165

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"No colon found"}],"type":"illegal_argument_exception","reason":"No colon found"},"status":400}Connection closed by foreign host.

When specifying HTTP version 1.1:
eric@flex-5:~/Projects/elasticsearch-7.9.2$ telnet 127.0.0.1 9200
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
GET / HTTP/1.1
.
HTTP/1.1 400 Bad Request
content-type: application/json; charset=UTF-8
content-length: 165

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"No colon found"}],"type":"illegal_argument_exception","reason":"No colon found"},"status":400}

Notice that, in the last session, the foreign host doesn't close the connection!

Ideas? Suggestions?

TIA,
Eric P.
Portland, Oregon

But your other suggestion (i.e., curl) works as-expected! :thinking:

eric@foobar:~/Projects/elasticsearch-7.9.2$ curl 127.0.0.1:9200
{
  "name" : "foobar",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "lMCQ03R1QMqG5uR9aatE-A",
  "version" : {
    "number" : "7.9.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "d34da0ea4a966c4e49417f2da2f244e3e97b4e6e",
    "build_date" : "2020-09-23T00:45:33.626720Z",
    "build_snapshot" : false,
    "lucene_version" : "8.6.2",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

What could be causing this inconsistent behavior?

TIA,
Eric P.
Portland, Oregon

And Mozilla Firefox also works as-expected:

{
  "name" : "flex-5",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "lMCQ03R1QMqG5uR9aatE-A",
  "version" : {
    "number" : "7.9.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "d34da0ea4a966c4e49417f2da2f244e3e97b4e6e",
    "build_date" : "2020-09-23T00:45:33.626720Z",
    "build_snapshot" : false,
    "lucene_version" : "8.6.2",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

HTH,
Eric P.
Portland, Oregon

You are sending a dot . in your request, just press enter instead of using a . and it will work.

When you use HTTP/1.1 the connection is persisted unless you specify it should not be persisted, you should use.

GET / HTTP/1.1
Connection: close

But using curl is simpler, it just one command, no need to use telnet.

1 Like

One last thing, Leandro:

How can I suggest/make improvements and/or corrections to the instructions that I'd referenced?

TIA,
Eric P.
Portland, Oregon

You could try opening an issue on github, but I don't think there is the need for it in this case.

The instructions to check if elasticsearch is running is to Send a HTTP Request, it does not say what you should use to do that, you could use Postman, a Browser, a Python Script, anything.

To make things easier it also has a link to copy the request using curl so you just paste it in your terminal.

The problem is that when making an HTTP Request you should include the HTTP Protocol version, this is speficied in the RFC 2616.

This is what a HTTP request looks like

Method SP Request-URI SP HTTP-Version CRLF

So the correct way to check if elasticsearch is running using telnet is to make the following request.

GET / HTTP/1.0

Since you didn't include the HTTP version in your first request, it was as Bad Request. This is not an elasticsearch error, but a Request error.