# Hosting Elastic Maps Service Locally with 7.12

**URL:** <https://discuss.elastic.co/t/hosting-elastic-maps-service-locally-with-7-12/270401>\
**Category:** Kibana\
**Tags:** maps\
**Created:** [April 16, 2021, 3:56pm UTC](https://discuss.elastic.co/t/hosting-elastic-maps-service-locally-with-7-12/270401 "2021-04-16T15:56:55Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris6](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@Chris6](https://discuss.elastic.co/u/Chris6)\
**Post date:** [April 16, 2021, 3:56pm UTC](https://discuss.elastic.co/t/hosting-elastic-maps-service-locally-with-7-12/270401/1 "2021-04-16T15:56:55Z")

</div>

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 [8.11] | Elastic](https://www.elastic.co/guide/en/kibana/current/maps-connect-to-ems.html#elastic-maps-server) 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" [docker.elastic.co/elastic-maps-service/elastic-maps-server-ubi8:7.12.0](http://docker.elastic.co/elastic-maps-service/elastic-maps-server-ubi8:7.12.0)`

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 [0.0.0.0:8080](http://0.0.0.0:8080/) 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:

> events.js:291  
> 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" docker.elastic.co/elastic-maps-service/elastic-maps-server-ubi8:7.12.0`

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":"172.17.0.2","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 Elasticsearch with it as well as the web address. I know it is in beta, but it should still work.

---

<div class="post-metadata">

**Author:** ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)\
**Post date:** [April 17, 2021, 11:14am UTC](https://discuss.elastic.co/t/hosting-elastic-maps-service-locally-with-7-12/270401/2 "2021-04-17T11:14:27Z")

</div>

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`](https://docs.docker.com/network/host/) option.

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

```bash
$ docker run --rm \
  docker.elastic.co/elastic-maps-service/elastic-maps-server-ubi8:7.12.0 \
  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)

```bash
docker run --rm --network host \
  docker.elastic.co/elastic-maps-service/elastic-maps-server-ubi8:7.12.0 \
  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"
}

```

---

<div class="post-metadata">

**Author:** ![Chris6](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@Chris6](https://discuss.elastic.co/u/Chris6)\
**Post date:** [April 20, 2021, 2:12pm UTC](https://discuss.elastic.co/t/hosting-elastic-maps-service-locally-with-7-12/270401/3 "2021-04-20T14:12:51Z")

</div>

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.
elasticsearch.host: '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" docker.elastic.co/elastic-maps-service/elastic-maps-server-ubi8:7.12.0

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":"192.168.170.29","ecs":{"version":"1.5.0"},"message":"server started"}
```

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [April 20, 2021, 11:57pm UTC](https://discuss.elastic.co/t/hosting-elastic-maps-service-locally-with-7-12/270401/4 "2021-04-20T23:57:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Chris6](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@Chris6](https://discuss.elastic.co/u/Chris6)\
**Post date:** [April 21, 2021, 12:33am UTC](https://discuss.elastic.co/t/hosting-elastic-maps-service-locally-with-7-12/270401/5 "2021-04-21T00:33:08Z")

</div>

I am running it with Ubuntu.

---

<div class="post-metadata">

**Author:** ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)\
**Post date:** [April 21, 2021, 11:22am UTC](https://discuss.elastic.co/t/hosting-elastic-maps-service-locally-with-7-12/270401/6 "2021-04-21T11:22:06Z")

</div>

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:

2. Add the hostname to the yaml configuration file:

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

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/7/77fdbe5a9c9374f974b8a7cf268e519136639291.png)

---

<div class="post-metadata">

**Author:** ![Chris6](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@Chris6](https://discuss.elastic.co/u/Chris6)\
**Post date:** [April 29, 2021, 12:43pm UTC](https://discuss.elastic.co/t/hosting-elastic-maps-service-locally-with-7-12/270401/7 "2021-04-29T12:43:15Z")

</div>

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](https://www.youtube.com/watch?v=_bsXgJWLpjU) so I don't think that is the case.

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [April 29, 2021, 8:30pm UTC](https://discuss.elastic.co/t/hosting-elastic-maps-service-locally-with-7-12/270401/8 "2021-04-29T20:30:07Z")

</div>

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

```auto
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" \
docker.elastic.co/elastic-maps-service/elastic-maps-server-ubi8:7.12.1 /bin/bash -c "ls -lh /usr/src/app/data"

```

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

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

```

---

<div class="post-metadata">

**Author:** ![Chris6](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@Chris6](https://discuss.elastic.co/u/Chris6)\
**Post date:** [May 3, 2021, 2:19pm UTC](https://discuss.elastic.co/t/hosting-elastic-maps-service-locally-with-7-12/270401/9 "2021-05-03T14:19:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [May 3, 2021, 6:31pm UTC](https://discuss.elastic.co/t/hosting-elastic-maps-service-locally-with-7-12/270401/10 "2021-05-03T18:31:00Z")

</div>

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

In my example [here](https://discuss.elastic.co/t/hosting-elastic-maps-service-locally-with-7-12/270401/8) 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

```auto
/home/nick/ems
|-> elastic-maps-server.yml
|-> data
    |-> planet.mbtiles

```

Does that help?

---

<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:** [May 31, 2021, 6:31pm UTC](https://discuss.elastic.co/t/hosting-elastic-maps-service-locally-with-7-12/270401/11 "2021-05-31T18:31:26Z")

</div>

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