Hosting Elastic Maps Service Locally with 7.12

I am trying to host elastic maps service locally with the new way to host the service on your my infrastructure. I have been following this guide Connect to Elastic Maps Service | Kibana Guide [7.12] | Elastic and have had no luck. I have tried setting up a new blank instance of elastic and still have the same errors.

The first error I cam accross was when running:
docker run --rm --name elastic-maps-server -it --hostname elastic-maps-server -p 8080:8080 -v "${PWD}/elastic-maps-server.yml:/usr/src/app/server/config/elastic-maps-server.yml" -v "${PWD}/data:/usr/src/app/data" -v "${PWD}/ems:/etc/ssl/certs" -v "${PWD}/log:/var/log/elastic-maps-server" [](

I would get there error of this:

docker: Error response from daemon: driver failed programming external connectivity on endpoint elastic-maps-server (55fcdaeff0f19bc997850180bc9404ad1b4ca6dd124c9648fc63e31b0a1c258e): Bind for []( failed: port is already allocated.

I can get rid of this error by stopping the mapping server before running that, but then I will get the error:

throw er; // Unhandled 'error' event

Error: EACCES: permission denied, open '/var/log/elastic-maps-server/elastic-maps-server.log'
Emitted 'error' event on WriteStream instance at:
at internal/fs/streams.js:361:12
at FSReqCallback.oncomplete (fs.js:156:23) {
errno: -13,
code: 'EACCES',
syscall: 'open',
path: '/var/log/elastic-maps-server/elastic-maps-server.log'

I can get rid of all those errors by removing lines from the docker starting command that I think are not relevant so that it looks like this:

docker run --rm --name elastic-maps-server -it --hostname elastic-maps-server -p 8080:8080 -v "${PWD}/elastic-maps-server.yml:/usr/src/app/server/config/elastic-maps-server.yml"

Then it will run the elastic map server but elastic is still not connected. This is the output:

{"log":{"level":"info","logger":"pino"},"@timestamp":"2021-04-16T13:39:11.638Z","process":{"pid":1},"host":{"hostname":"elastic-maps-server"},"created":1618580351589,"started":1618580351635,"host":"elastic-maps-server","port":8080,"protocol":"http","id":"elastic-maps-server:1:knkcy89x","uri":"[http://elastic-maps-server:8080](http://elastic-maps-server:8080/)","address":"","ecs":{"version":"1.5.0"},"message":"server started"}
{"log":{"level":"error","logger":"pino"},"@timestamp":"2021-04-16T13:39:17.662Z","process":{"pid":1},"host":{"hostname":"elastic-maps-server"},"message":"Unable to connect to the Elasticsearch cluster: [http://localhost:9200](http://localhost:9200/)","ecs":{"version":"1.5.0"}}

The password in the .yml is correct and everything because I can log into elastic search with it as well as the web address. I know it is in beta, but it should still work.

I'd try to go from the simplest install to the more complete. The last line of your error is saying that inside your docker image http://localhost:9200 is not accessing to your Elasticsearch instance which makes sense since that's not served by the Docker image. You need to provide a proper networking driver to your Docker instance, in your case looks like the --network host option.

You can confirm this running a simple curl command against localhost:9200 with this line to check the connectivity issue:

$ docker run --rm \ \
  curl http://localhost:9200

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (7) Failed to connect to localhost port 9200: Connection refused

If you do the same with the --network host option then you can access your server (including credentials)

docker run --rm --network host \ \
  curl -s --user $ES_USER:$ES_PASSWORD http://localhost:9200
  "name" : "a",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "LMGRFrsRSjaa-UaJwWzhZw",
  "version" : {
    "number" : "8.0.0-SNAPSHOT",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "6a911b57ecc71ea62c7fb017838cac06383f548c",
    "build_date" : "2021-04-16T19:32:09.677110283Z",
    "build_snapshot" : true,
    "lucene_version" : "8.8.2",
    "minimum_wire_compatibility_version" : "7.13.0",
    "minimum_index_compatibility_version" : "7.0.0"
  "tagline" : "You Know, for Search"
1 Like

Isn't that provided by the elastic-map-service.yml. This is what is in my yml:

# Required settings for the URL and basic authentication parameters for your Elasticsearch
# cluster for license verification. 'http://localhost:9200'
elasticsearch.username: 'ems'
elasticsearch.password: 'changeme'

I have it setup the same way as in the docs. When I run your commands it does work as it does for you, but it doesn't do anything to connect the elastic map service to elasticsearch it just seems to verify that it works. I even tried adding the --network host and still do not get any luck. If I do that it just starts, but I can not reach the website. Here is what I ran.

docker run --rm --network host --name elastic-maps-server -it    --hostname elastic-maps-server    -p 8080:8080    -v "${PWD}/elastic-maps-server.yml:/usr/src/app/server/config/elastic-maps-server.yml"

WARNING: Published ports are discarded when using host network mode
{"log":{"level":"info","logger":"pino"},"@timestamp":"2021-04-20T14:10:52.351Z","process":{"pid":1},"host":{"hostname":"elastic-maps-server"},"created":1618927852292,"started":1618927852342,"host":"elastic-maps-server","port":8080,"protocol":"http","id":"elastic-maps-server:1:knq3udj8","uri":"http://elastic-maps-server:8080","address":"","ecs":{"version":"1.5.0"},"message":"server started"}

Hi Chris. Thanks for trying out Elastic Maps Server. Are you running this on a Mac? If so, can you try changing http://host.docker.internal:9200 in your elastic-maps-server.yml file?

I am running it with Ubuntu.

Hi @Chris6, you need to do two things for your command to run:

  1. Add to your /etc/hosts file a line for the hostname you want for your server:       elastic-maps-server
  2. Add the hostname to the yaml configuration file:

    host: elastic-maps-server

With those two changes, you are directing requests to the elastic-maps-server to your own computer and setting the Docker image to accept them.

Otherwise, you can remove the hostname parameter from the docker command and everything should work from localhost.

Sharing a screenshot of a working setup with your requirements

1 Like

Hi so I noticed I have another issue. When I downloaded the 90GB mapping file and put it into the directory it wanted. I get an error sqlite_cantopen: unable to open database file. I Am wondering if this is maybe because the file is corrupt or is it because it has the wrong permissions. The permissions match the permissions in this video: Getting Started with Elastic Maps Server (Beta) - YouTube so I don't think that is the case.

Hi Chris,

Sounds like the database directory is not mounting correctly. Maybe try listing the contents of the /usr/src/app/data directory from the container? At the end of your docker run command add /bin/bash -c "ls -lh /usr/src/app/data".

For example

docker run --rm --name elastic-maps-server -it \
   --hostname elastic-maps-server \
   -p 8080:8080 \
   -v "${PWD}/elastic-maps-server.yml:/usr/src/app/server/config/elastic-maps-server.yml" \
   -v "${PWD}/data:/usr/src/app/data" \
   -v "${PWD}/log:/var/log/elastic-maps-server" \ /bin/bash -c "ls -lh /usr/src/app/data"

It should show the planet.mbtiles file in the listing similar to

total 83G
-rw-r--r-- 1 node node 83G Apr  7 16:59 planet.mbtiles
1 Like

It looks like mine just reports: total 0. Which is strange because it is in there.

Thanks Chris. It sounds like the mount is not getting applied correctly.

In my example here I have this line -v "${PWD}/data:/usr/src/app/data" \ which tells Docker to mount the data directory relative my current working directory (${PWD}). For example, if I launch Elastic Maps Server from my terminal in the /home/nick/ems directory, my directory must be structured like

|-> elastic-maps-server.yml
|-> data
    |-> planet.mbtiles

Does that help?

1 Like

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