SocketException: Address already in use MONGODB

前端 未结 11 1137
隐瞒了意图╮
隐瞒了意图╮ 2020-12-07 08:42

i found this error when trying to run mongodb. I install it via homebrew. Please assist

Agungs-MacBook-Pro:~ agungmahaputra$ mongod
2017-12-26T15:31:15.911+0         


        
相关标签:
11条回答
  • 2020-12-07 09:14

    if you're using mongodb version 4.*

    in default settings, there should be a "db" folder "/data/db" having the necessary permission.

    to check it the MongoDB service started

    brew services list
    

    if not then run

    brew services start mongodb
    

    run mongo instead of mongod

    0 讨论(0)
  • 2020-12-07 09:15

    First, shutdown the running server using:

    mongod --shutdown
    

    Then run:

    sudo mongod
    
    0 讨论(0)
  • 2020-12-07 09:16

    I solved it pasting the command below into the command line in order to close mongo's server.

    sudo pkill -f mongod
    

    "sudo" (Super User Do) runs the command admin permissions, so it will ask you for your user password

    0 讨论(0)
  • 2020-12-07 09:21

    If your mongod process is already down, just remove the .sock file in /tmp:

    My mongod is already down, so does not appears in:

    lsof -iTCP -sTCP:LISTEN -n -P
    

    The error was:

    [root@ol7db19c1 ~]# mongod -f /etc/csrs_2.conf
    about to fork child process, waiting until server is ready for connections.
    forked process: 6721
    ERROR: child process failed, exited with error number 48
    To see additional information in this output, start without the "--fork" option.
    

    In the log file (/var/mongodb/db/csrs2.log):

    2020-07-05T16:03:59.354-0300 E  STORAGE  [initandlisten] Failed to set up listener: SocketException: Address already in use
    

    So, find for the socket locking:

    ls -ltra /tmp|grep .sock
    

    And just remove it (do it with caution in production environment):

    rm -f mongodb-26002.sock
    

    G-luck!

    0 讨论(0)
  • 2020-12-07 09:22

    After running this commands below:

    sudo lsof -iTCP -sTCP:LISTEN -n -P
    

    Search for mongod COMMAND and its PID and type,

    sudo kill <mongo_command_pid>
    

    And restarting mongod, it still fails with the same error "SocketException: Address already in use MONGODB".

    Server was restarted yesterday and then this happened.

    0 讨论(0)
提交回复
热议问题