FireWorks was not able to connect to MongoDB

Hello,

I am trying to reset the db as follows:

$ lpad reset
Traceback (most recent call last):
  File "/home/mdi0316/anaconda3/bin/lpad", line 8, in <module>
    sys.exit(lpad())
  File "/home/mdi0316/anaconda3/lib/python3.8/site-packages/fireworks/scripts/lpad_run.py", line 1551, in lpad
    args.func(args)
  File "/home/mdi0316/anaconda3/lib/python3.8/site-packages/fireworks/scripts/lpad_run.py", line 197, in reset
    lp = get_lp(args)
  File "/home/mdi0316/anaconda3/lib/python3.8/site-packages/fireworks/scripts/lpad_run.py", line 142, in get_lp
    raise ValueError(err_message) from None
ValueError: FireWorks was not able to connect to MongoDB at 10.100.192.1:27017. Is the server running? The database file specified was /home/mdi0316/.fireworks/my_launchpad.yaml.

Here’s the version of mongo/lpad/Fireworks that I am using:

$ which mongo
~/anaconda3/bin/mongo
$ mongo --version
MongoDB shell version v4.0.3
git version: 7ea530946fa7880364d88c8d8b6026bbc9ffa48c
OpenSSL version: OpenSSL 1.1.1n  15 Mar 2022
allocator: tcmalloc
modules: none
build environment:
    distarch: x86_64
    target_arch: x86_64
$ pip freeze | grep Fire
FireWorks==2.0.3
$ which lpad
~/anaconda3/bin/lpad
$ lpad --version
lpad v2.0.3 located in /home/mdi0316/anaconda3/lib/python3.8/site-packages

A mongod instance is running already:

$ mongod --bind_ip_all --logpath ~/mongodb/log/mongod.log --port 27017 --dbpath ~/mongodb/db --auth --fork
2022-05-13T16:04:52.605+0200 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
about to fork child process, waiting until server is ready for connections.
forked process: 289628
child process started successfully, parent exiting
$ lsof -iTCP -sTCP:LISTEN | grep mongo
mongod  274693 mdi0316   10u  IPv4 2391118783      0t0  TCP *:27017 (LISTEN)

and I have the following user defined:

> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
> use admin
switched to db admin
> show users
{
	"_id" : "admin.mdi0316_admin",
	"user" : "mdi0316_admin",
	"db" : "admin",
	"roles" : [
		{
			"role" : "userAdminAnyDatabase",
			"db" : "admin"
		}
	],
	"mechanisms" : [
		"SCRAM-SHA-1",
		"SCRAM-SHA-256"
	]
}

and my config file looks like this:

$ cat ~/.fireworks/my_launchpad.yaml 
authsource: mdi0316_admin
host: 10.100.192.1
logdir: null
mongoclient_kwargs: {}
name: mdi0316_admin
password: *******
port: 27017
strm_lvl: INFO
uri_mode: false
user_indices: []
username: mdi0316_admin
wf_user_indices: []

I actually also tried the same with mongo 5.1.1 with no difference.
Thank you for your help.

Marco

Hi Marco,

Are you connecting through an ssh tunnel? How are you connecting to the mongo shell (without fireworks)?

Hello Ardunn,

yes I have a ssh connection to the remote server from my workstation.

This is how I start the deamon:

mongod --fork --bind_ip_all --logpath ~/mongodb/log/mongod.log --port 27017 --dbpath ~/mongodb/db --auth 

and how I connect:

mongo --port 27017 -u "mdg0316_admin" -p '****1234' --authenticationDatabase "admin"

There was a mistake in my yaml file.

I had to create an admin and a user user:

  1. open mongo shell
use admin
db.createUser( { user : 'mdi0316_admin', pwd : '****', roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } )
  1. close mongo shell

  2. Starting mongod as a daemon (fork)

mongod --fork --bind_ip_all --logpath mongodb/log/mongod.log --port 27017 --dbpath mongodb/db --auth
  1. Now, admin can connect using:
mongo --port 27017 -u "mdg0316_admin" -p '****' --authenticationDatabase "admin"
  1. In the same mongo shell
# create user and password for the database:
use db_name
db.createUser( { user : 'mdi0316_fw', pwd : other_psw', roles: [ { role: "dbOwner", db: db_name } ] } )

Crucially, in the my_launchpad.yaml, I needed to modify authsource, password and username to the ones of the db_name mongo user:

authsource: db_name
name: db_name
password: other_psw
username: mdi0316_fw

at this point lpad reset works.

1 Like

Thanks for posting the solution @mdigennaro !!