dongtan7201 2017-06-07 06:51
浏览 1300

无法连接到数据库:无法连接到:localhost:27017:连接被拒绝

Why while I run the command mongod on server everything is ok and when I close ssh session on putty I see such error.

Unable to connect to Database: Failed to connect to: localhost:27017: Connection refused

  • 写回答

1条回答 默认 最新

  • doujiu4643 2017-06-07 10:36
    关注

    The issue here is that the mongo server is being run in the ssh session you are opening when you connect. You'll have to detach the mongo server from your session by using disown or by using a utility such as tmux or screen. This will allow your mongo server process to keep running after you have disconnected your ssh session.

    Alternatively, as was mentioned in a comment above, if you run your mongo server as a service, you'll be able to disconnect from the ssh session and still have your server process running.

    Starting mongo as a service would look something like this -

    sudo service mongod start
    

    So to explain it simply, when you connect via ssh, you are provided a shell on the server to execute commands. The moment you disconnect from your ssh session, your mongo server exits because it has no shell to run on. The shell that it did have was closed when you exited your ssh session.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度