First lab script shows errors - cannot connect-connection refused

Untitledghfg

What is wrong with this? I do not understand

1 Like

Please check that mongod is running on port 27000 (by default it runs on 27017).

2 Likes

I had a similar issue, the solution for me was to run the mongod in the vagrant ssh shell and bind it to 192.168.103.100 and localhost. Then once mongod is running in the vagrant ssh shell, open another shell and via mongo using the 192.168.103.100 (localhost didnt work for me and i got the connection refused error). As Mahesh_56388 said you also need to specify the port that mongod is listening on (you can see which one it is once mongod is running, it is the last phrase it outputs). Hope this helps

1 Like

One of the most common mistake in the course, at the start until you get into the grove is that you lose track of the ports you are using to start and connect to the database.

Also when you start copying examples from the notes, people forget to change the port.

Have a txt file of connection strings so you just paste in the ones you use most often, just remember to change the port :slight_smile:

1 Like

How do I change ports?

For example from the vagrant shell: -

mongo --port 30000

And within your config file: -

net:
bindIp: 192.168.103.100,localhost
port: 30000

You have watched the course videos? Since I am sure it has been covered in chapter 0 - The MongoD

1 Like

I do not know how to change ports, and how to check ports. :frowning:

Moreover, all those steps are unclear in what I should do.

  • run on port 27000
  • data files are stored in /data/db/
  • listens to connections from the IP address 192.168.103.100 and localhost
  • authentication is enabled

Well if you have a log file, check in the first couple of lines of that, it tells you what you started the mongod with.

Otherwise do a : -

ps -ef | grep mongo

This will give you the pid and then kill the process, and start it up again with the port you wanted.

Mongod tells you what port it is listening on.

1 Like

Thanks.

I will just give up. :neutral_face:, having s syntax error when trying to kill the process, nothing is working. This course is hard.

You are being asked to create a single command line mongod .

  1. Create a data database using the parameters you have listed, so that will be using mongod --port XXXX --dbpath XXXX --bind_ip XXXXXXXXXXX --auth

  2. connect to the data base using mongo command (using the correct port).

  3. Create user as instructed.

It is covered in the previous video, you just have to swap parameters in the previous video for the ones requested. It is important to make notes as you go along, watching a video to find the specific part you need is hard work.

The command for killing the process…

ps -ef | grep mongod

This tells you the PID you want.

kill <pid>

This kills the PID you name. Do NOT put in the < > :slight_smile:

1 Like

For a kill process I have: "syntax error near unexpected token newline

You are running this from vagrant shell?

Screen shot it.

without <> it seems like cmd asks for agrs.

So

  1. Your mongod is running on port 27000
  2. It isn’t kill pid, it is kill 8516

PID Definition. A PID (i.e., process identification number) is an identification number that is automatically assigned to each process when it is created on a Unix -like operating system.

1 Like

Yes, it is running on 27000. When I put kill 8516, it comes through, but when I check port again, the process is still running.

I watched previous videos again, and it seems clear on how it should work. I am unfamiliar with networking in general, so it is hard to follow.

If you kill 8516 successfully, and run ps -ef again, then the you wouldn’t be seeing mongod --port 27000 , since you have killed the process.

Kill 8499

No, it is still there. :persevere:

Not sure why you can’t kill the process.

However connect and shutdown the server. If you haven’t created the admin user, you can shutdown with this.

mongo admin --port 27000 --eval 'db.shutdownServer()'

Connect to the admin database on port 27000 and shut the server down.

Another thing. A couple of times I have tried to do something, I have something like this:

Something is connecting and staying like this forever.