1

At first I had a problem where the mongod service stopped working altogether. Thereupon I completely uninstalled mongodb and reinstalled it and followed instructions per this thread: https://askubuntu.com/questions/921753/failed-to-start-mongod-service-unit-mongod-service-not-found

This caused the mongod service to finally start.

In order for it to work, I also had to follow instructions from this thread: mongo - couldn't connect to server 127.0.0.1:27017

So far this configuration has worked only 1 time and that was after I followed the instructions to remove the .lock file in the mongod directory and then repair mongod.

I also tried to remove the sock file like stated here: MongoDB Failing to Start - ***aborting after fassert() failure

Full project reset

Then I tried just disconnecting the project entirely; close nodemon for backend, exit ng serve on frontend, stop and remove mongo docker container... And tried again. Here is my step-by-step process after everything should have been fixed:

Restart mongod service

sudo service mongod restart

Restart frontend (executed from frontend directory)

ng serve frontend

Restart backend (executed from backend directory)

npx nodemon backend 

Restart mongo container (executed from deploy directory, mongo is the docker container name, I'm building it from existing provided deploy script)

sudo docker-compose up -d mongo
sudo docker ps -a # check container was created and is running

Debugging information:

sudo service mongod status

    Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: 
    Active: active (running) since Thu 2020-01-09 11:21:43 CET; 3min 40s ago
      Docs: https://docs.mongodb.org/manual
  Main PID: 17242 (mongod)
    CGroup: /system.slice/mongod.service
            └─17242 /usr/bin/mongod --config /etc/mongod.conf

 janv. 09 11:21:43 junior-LIFEBOOK-E752 systemd[1]: Started MongoDB Database Server



 sudo mongod2020-01-09T11:25:45.983+0100 I  CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
 2020-01-09T11:25:45.987+0100 I  CONTROL  [initandlisten] MongoDB starting : pid=17727 port=27017 dbpath=/data/db 64-bit host=junior-LIFEBOOK-E752
 2020-01-09T11:25:45.987+0100 I  CONTROL  [initandlisten] db version v4.2.2
 2020-01-09T11:25:45.987+0100 I  CONTROL  [initandlisten] git version: a0bbbff6ada159e19298d37946ac8dc4b497eadf
 2020-01-09T11:25:45.987+0100 I  CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.1d  10 Sep 2019
 2020-01-09T11:25:45.987+0100 I  CONTROL  [initandlisten] allocator: tcmalloc
 2020-01-09T11:25:45.987+0100 I  CONTROL  [initandlisten] modules: none
 2020-01-09T11:25:45.987+0100 I  CONTROL  [initandlisten] build environment:
 2020-01-09T11:25:45.987+0100 I  CONTROL  [initandlisten]     distmod: ubuntu1804
 2020-01-09T11:25:45.987+0100 I  CONTROL  [initandlisten]     distarch: x86_64
 2020-01-09T11:25:45.987+0100 I  CONTROL  [initandlisten]     target_arch: x86_64
 2020-01-09T11:25:45.987+0100 I  CONTROL  [initandlisten] options: {}
 2020-01-09T11:25:45.987+0100 E  STORAGE  [initandlisten] Failed to set up listener: SocketException: Address already in use
 2020-01-09T11:25:45.987+0100 I  CONTROL  [initandlisten] now exiting
 2020-01-09T11:25:45.987+0100 I  CONTROL  [initandlisten] shutting down with code:48

sudo mongo

  connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
  Implicit session: session { "id" : UUID("8e813fc2-049c-440d-83ce-0b1d8516c4d0") }
  MongoDB server version: 4.2.2
  Server has startup warnings: 
  2020-01-09T11:21:43.352+0100 I  STORAGE  [initandlisten] 
  2020-01-09T11:21:43.352+0100 I  STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
  2020-01-09T11:21:43.352+0100 I  STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
  2020-01-09T11:21:44.848+0100 I  CONTROL  [initandlisten] 
  2020-01-09T11:21:44.848+0100 I  CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
  2020-01-09T11:21:44.848+0100 I  CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
  2020-01-09T11:21:44.848+0100 I  CONTROL  [initandlisten] 

  Enable MongoDB's free cloud-based monitoring service, which will then receive and display
  metrics about your deployment (disk utilization, CPU, operation statistics, etc).

  The monitoring data will be available on a MongoDB website with a unique URL accessible to you
  and anyone you share the URL with. MongoDB may use this information to make product
  improvements and to suggest MongoDB products and deployment options to you.

  To enable free monitoring, run the following command: db.enableFreeMonitoring()
  To permanently disable this reminder, run the following command: db.disableFreeMonitoring()

So something weird is happening here, it doesn't find the database from the project and I have no clue why. As far as I can see, it creates a new database including my system details. How can I fix this please and connect to the project database? I can't move further until I do.

2
  • Seems you already have something listening on the mongo port, blocking the startup procedure?
    – JohannesB
    Jan 9, 2020 at 13:59
  • @JohannesB Hi, someone told me now I don't need to have the mongod service running if mongo is already included in the docker container, so I diabled the service locally and am just trying to get it to work using the docker container but it's still not getting output
    – Lisonallie
    Jan 9, 2020 at 14:18

1 Answer 1

0

it's been resolved. First I found out I didn't need to have the mongod service running locally because mongo was already included in the docker container. But actually this wasn't a database issue at all. There were a few things going wrong like there was a proxy but the command had been changed to execute the connection, endpoints were on localhost but weren't supposed to be, and the content I was expecting to see had been hidden by a careless push from another developer. Fun times! But we can move on now. Thanks to the people who tried to help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.