# Action failed: Starting mongodb

**URL:** <https://discuss.circleci.com/t/action-failed-starting-mongodb/6377>\
**Category:** Databases\
**Tags:** mongo\
**Created:** [September 20, 2016, 3:06pm UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377 "2016-09-20T15:06:42Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![afoninsky](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@afoninsky](https://discuss.circleci.com/u/afoninsky)\
**Post date:** [September 20, 2016, 3:06pm UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377/1 "2016-09-20T15:06:42Z")

</div>

With this config:

> machine:  
> services:  
> - mongodb

i’m getting error:

> service mongodb status || service mongodb start  
> mongodb: unrecognized service  
> service mongodb status || service mongodb start returned exit code 1  
> Action failed: Starting mongodb

i believe command should looks like this:

> service mongod status || service mongod start

---

<div class="post-metadata">

**Author:** ![levlaz](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/levlaz/32/36978_2.png) [@levlaz](https://discuss.circleci.com/u/levlaz)\
**Post date:** [September 21, 2016, 12:08am UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377/2 "2016-09-21T00:08:17Z")

</div>

Which build image are you using (Precise or Trusty)?

---

<div class="post-metadata">

**Author:** ![cadupont](https://avatars.discourse-cdn.com/v4/letter/c/f14d63/32.png) [@cadupont](https://discuss.circleci.com/u/cadupont)\
**Post date:** [October 11, 2016, 8:54pm UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377/3 "2016-10-11T20:54:26Z")

</div>

I’m using Trusty and I have the same issue.  
I also tried adding pecl install mongo to dependencies (pre) without success.

---

<div class="post-metadata">

**Author:** ![jim](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/jim/32/14195_2.png) [@jim](https://discuss.circleci.com/u/jim)\
**Post date:** [October 24, 2016, 9:53pm UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377/4 "2016-10-24T21:53:31Z")

</div>

We’re seeing the same issue with Trusty.

We get the following error:

```
service mongodb status || service mongodb start
mongodb: unrecognized service
mongodb: unrecognized service

service mongodb status || service mongodb start returned exit code 1

Action failed: Starting mongodb`

```

Our circle.yml file looks like:

```
machine:
  node:
    version: 6
  services:
    - mongodb
    - redis

```

It doesn’t seem to make a difference if I remove `mongodb` from the services list

---

<div class="post-metadata">

**Author:** ![kronos](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/kronos/32/14825_2.png) [@kronos](https://discuss.circleci.com/u/kronos)\
**Post date:** [December 14, 2016, 9:09am UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377/5 "2016-12-14T09:09:29Z")

</div>

Same here. Could fix it please?

---

<div class="post-metadata">

**Author:** ![kevinohara80](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/kevinohara80/32/14969_2.png) [@kevinohara80](https://discuss.circleci.com/u/kevinohara80)\
**Post date:** [December 21, 2016, 7:31pm UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377/6 "2016-12-21T19:31:01Z")

</div>

Can someone from Circle give an update here?

---

<div class="post-metadata">

**Author:** ![adamjcsmith](https://avatars.discourse-cdn.com/v4/letter/a/54ee81/32.png) [@adamjcsmith](https://discuss.circleci.com/u/adamjcsmith)\
**Post date:** [December 21, 2016, 7:58pm UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377/7 "2016-12-21T19:58:00Z")

</div>

Same here, please could you give an update?

---

<div class="post-metadata">

**Author:** ![levlaz](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/levlaz/32/36978_2.png) [@levlaz](https://discuss.circleci.com/u/levlaz)\
**Post date:** [December 23, 2016, 2:32am UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377/8 "2016-12-23T02:32:35Z")

</div>

Hi all,

Sorry for the delay!

The service name changed in Trusty from `mongodb` to `mongod` you should be able to get it to work by running the same commands with `mongod`.

Best,  
Lev

---

<div class="post-metadata">

**Author:** ![kevinohara80](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/kevinohara80/32/14969_2.png) [@kevinohara80](https://discuss.circleci.com/u/kevinohara80)\
**Post date:** [December 23, 2016, 2:40am UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377/9 "2016-12-23T02:40:56Z")

</div>

That doesn’t work.

 ![](https://global.discourse-cdn.com/circleci/original/3X/9/6/96286f9933f806722fa974170a8f373ab4ca3160.png)

---

<div class="post-metadata">

**Author:** ![levlaz](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/levlaz/32/36978_2.png) [@levlaz](https://discuss.circleci.com/u/levlaz)\
**Post date:** [December 23, 2016, 2:48am UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377/10 "2016-12-23T02:48:49Z")

</div>

Not the services, that should still be `mongodb`

But if you want to see the status, or restart it you should run

```auto
sudo service mongod restart

```

---

<div class="post-metadata">

**Author:** ![kevinohara80](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/kevinohara80/32/14969_2.png) [@kevinohara80](https://discuss.circleci.com/u/kevinohara80)\
**Post date:** [December 23, 2016, 2:54am UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377/11 "2016-12-23T02:54:02Z")

</div>

> Not the services, that should still be mongodb

Are you saying we should continue to list `mongodb` in the services? Because that is what is breaking.

---

<div class="post-metadata">

**Author:** ![levlaz](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/levlaz/32/36978_2.png) [@levlaz](https://discuss.circleci.com/u/levlaz)\
**Post date:** [December 23, 2016, 2:56am UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377/12 "2016-12-23T02:56:18Z")

</div>

Can you share a build URL?

---

<div class="post-metadata">

**Author:** ![levlaz](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/levlaz/32/36978_2.png) [@levlaz](https://discuss.circleci.com/u/levlaz)\
**Post date:** [December 23, 2016, 3:00am UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377/13 "2016-12-23T03:00:49Z")

</div>

Bah, sorry for the confusion ☹

Can you do the following:

1. Remove mongodb from your services completely
2. Add the following to `test: pre`

```auto
service mongod status || service mongod start

```

We need to fix this in our container, which we will do, but the above workaround should work in the meantime.

Best,  
Lev

---

<div class="post-metadata">

**Author:** ![kevinohara80](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/kevinohara80/32/14969_2.png) [@kevinohara80](https://discuss.circleci.com/u/kevinohara80)\
**Post date:** [December 23, 2016, 3:01am UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377/14 "2016-12-23T03:01:54Z")

</div>

Ok that will work for now. Thanks.

---

<div class="post-metadata">

**Author:** ![levlaz](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/levlaz/32/36978_2.png) [@levlaz](https://discuss.circleci.com/u/levlaz)\
**Post date:** [December 23, 2016, 3:02am UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377/15 "2016-12-23T03:02:34Z")

</div>

Thank **you**! I will update this thread when this workaround is no longer necessary.

---

<div class="post-metadata">

**Author:** ![levlaz](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/levlaz/32/36978_2.png) [@levlaz](https://discuss.circleci.com/u/levlaz)\
**Post date:** [December 23, 2016, 3:14am UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377/16 "2016-12-23T03:14:38Z")

</div>

Ok I got some further clarification from our engineering team .

1. Mongodb is [started by default on the 14.04 image](https://circleci.com/docs/1.0/build-image-trusty/#mongodb). So this means that it is not necessary to list it under services.
2. If you need to stop or restart Mongo during your build you should use `sudo service mongod $COMMAND`

Best,  
Lev

---

<div class="post-metadata">

**Author:** ![szdavid92](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/szdavid92/32/13815_2.png) [@szdavid92](https://discuss.circleci.com/u/szdavid92)\
**Post date:** [March 23, 2017, 2:39pm UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377/17 "2017-03-23T14:39:18Z")

</div>

The build shouldn’t break just because you specify you need a service that happens to be started by default. After all what you want to say that is just that “I require this service running”. To make things worse an error message like this “mongodb: unrecognized service” just leads to further confusion. I initially thought I mistyped the name, or it’s called ‘mongo’.

What’s even more frustrating is that the behaviour is different between environments. On Ubuntu 12.04 it works, on 14.04 it doesn’t.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:41am UTC](https://discuss.circleci.com/t/action-failed-starting-mongodb/6377/18 "2018-06-18T11:41:46Z")

</div>

Closed on June 18, 2018, 11:41am UTC


