About to fork child process, waiting until server is ready for connections. forked process: 6558 ERROR: child process failed, exited with 48

I have been trying to set up MongoDB on my Mac using homebrew. I used MongoDB’s Documentation to do that, everything is installed correctly on my mac. But when I start the MongoDB services and try to run MongoDB manually as a background process I come across this error.

mongod --config /opt/homebrew/etc/mongod.conf --fork ─╯
about to fork child process, waiting until server is ready for connections.
forked process: 6558
ERROR: child process failed, exited with 48

And I cannot even access Mongo Shell , this is what I get

mongosh ─╯
[1] 7036 killed mongosh

Hi @Shahima_khan ,
Can you display your configuration file please?
I think it Is set internally the fork option so you don’ t need to explicate the --fork option from the Shell.

Regards

1 Like

Hey @Fabio_Ramohitaj
I would like to thank u for your attention to my problem.
Here is my configuration file

Hi @Shahima_khan ,
Can you see if the port 27017 isn’t busy from another process?
For example in Linux you can see that with the netstat command.

Regards

1 Like

@Fabio_Ramohitaj the port is not busy. I checked there was no port 27017

@Shahima_khan , can you try to change the port in the configuration file of mongo to 27018 and the restart the instance?

1 Like

Let me try to explain everything from the start.
I downloaded MongoDB using Homebrew by following this official post ( https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-os-x/)
I used the following commands:-

(P.S. everything was up to date before starting this process)

brew tap mongodb/brew

brew install mongodb-community@6.0

brew services start mongodb-community@6.0

Then I checked if the services are running using this command

brew services list

I get the following output:-

 brew services list                                                                                                                        ─╯
Name              Status  User    File
emacs             none
mongodb-community started shahima ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist
unbound           none

So according to the output, MongoDB is running

when I try to get the version of MongoDB after closing the current terminal window using the command

mongod --version

I get the output

mongod --version                                                                                                                          ─╯
db version v6.0.4
Build Info: {
    "version": "6.0.4",
    "gitVersion": "44ff59461c1353638a71e710f385a566bcd2f547",
    "modules": [],
    "allocator": "system",
    "environment": {
        "distarch": "aarch64",
        "target_arch": "aarch64"
    }
}

everything seems gr8 so far …
but now as I try to get into Mongo Shell using the command

mongosh

mongo

this is the output I get

I have a good enough Mac Configuration to run this process but I don’t know what is causing the problem.

@Fabio_Ramohitaj umm… what port? There is no field named as “port” in the configuration file.

You need to add the parameter port in the configuration file:

“net:
bindIp: 127.0.0.1
port: 27017”
https://www.mongodb.com/docs/manual/reference/configuration-options/#:~:text=net%3A,port%3A%2027017

1 Like

@Shahima_khan Yes, but change the number of port to 27018 as i mentioned before and restart the process

1 Like

@Fabio_Ramohitaj

I did as u asked but I got a bunch of logs in my terminal.
I changed the port to 27018 in the editor and then after saving the file I restarted the mongodb server using the command

brew services restart mongodb-community

(I hope this is what u mean by restarting the process. Pls correct me if I’m wrong)

Then when I used mongod . I got a lot of logs

mongod                                                                                                                             ─╯
{"t":{"$date":"2023-02-11T20:07:22.645+05:30"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"thread2","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2023-02-11T20:07:22.646+05:30"},"s":"I",  "c":"NETWORK",  "id":4915701, "ctx":"thread2","msg":"Initialized wire specification","attr":{"spec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":17},"incomingInternalClient":{"minWireVersion":0,"maxWireVersion":17},"outgoing":{"minWireVersion":6,"maxWireVersion":17},"isInternalClient":true}}}
{"t":{"$date":"2023-02-11T20:07:22.646+05:30"},"s":"I",  "c":"NETWORK",  "id":4648602, "ctx":"thread2","msg":"Implicit TCP FastOpen in use."}

There was a lot more of this.

And the same thing happed when I specifically tried to connect to the 27018 port using the command

mongod --port 27018

@Shahima_khan

Yes. Can you attach the status of the service here?

@Fabio_Ramohitaj sure here it is :-

brew services restart mongodb-community                                   ─╯
Stopping `mongodb-community`... (might take a while)
==> Successfully stopped `mongodb-community` (label: homebrew.mxcl.mongodb-commu
==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-commu

╭─    ~ ───────────────────────────────────────────── ✔    ─╮
╰─ brew services list                                                        ─╯
Name              Status  User    File
emacs             none
mongodb-community started shahima ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist
unbound           none

╭─    ~ ───────────────────────────────────────────────────────────────────── ✔    ─╮
╰─

Hi @Shahima_khan,
Are you able to connect to the instance with mongo --port 27018 or mongosh --port 27018?
Can you execute command like show dbs?

Regards

@Fabio_Ramohitaj Hey !!

No Im unable to connect to the instance using mongo --port 27018 or mongosh --port 27018

here is the result:-

╭─    ~ ──────────────────────────────────────── KILL ✘  01:50:14 AM  ─╮
╰─ mongo --port 27018                                                        ─╯
zsh: command not found: mongo

╭─    ~ ───────────────────────────────────────── 127 ✘    ─╮
╰─ mongosh --port 27018                                                      ─╯
[1]    9058 killed     mongosh --port 27018

╭─    ~ ──────────────────────────────────────── KILL ✘    ─╮
╰─

Regards!

Hello @Shahima_khan,

I just had the same issue and the problem for me was that I did not stop the services before running the ‘mongod --config /opt/hombrew/etc/mongod.conf --fork’ command. From reading the thread I believe your issue is the same.

Try running ‘brew services stop mongodb-community@{version}

Then run 'mongod --config /opt/hombrew/etc/mongod.conf --fork’.

Hope this helps!

1 Like

Except for testing you do not want to start mongod manually with

You should use brew to stop and start since it is the safest way to get clean shutdown.

1 Like

@Tuhrel_Johnson thank you!

Mine was solved after reinstalling MongoDB completely and installing Mongosh separately.

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