MongoDB通过端口转发问题在Vagrant上的问题

MongoDB通过端口转发问题在Vagrant上的问题

本文介绍了MongoDB通过端口转发问题在Vagrant上的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在Vagrant上运行的CentOS 6 VM上安装了mongodb.

I've recently installed mongodb on my CentOS 6 VM running on Vagrant.

我在Vagrantfile中添加了端口转发功能,以转发mongo端口

I added port forwarding to Vagrantfile to forward the mongo port

config.vm.forward_port 27017, 127017

我将mongod配置为在服务器启动时自动启动,并确认该服务已按预期启动.

I configured mongod to start automatically when the server starts and have confirmed that the service starts as intended.

但是,当我从主机(不是流浪汉)运行mongo localhost:127017时,出现以下错误

however when i run mongo localhost:127017 from my host machine (not vagrant) i get the following error

MongoDB shell version: 1.8.2
connecting to: localhost:127017/test
Fri Jan 20 13:58:28 getaddrinfo("127.0.0.1") failed: nodename nor servname provided, or not known
Fri Jan 20 13:58:28 Error shell/mongo.js:81
exception: connect failed

有什么想法吗?

推荐答案

TCP端口号是16位无符号的,这意味着最大值是65535(2 ^ 16),并且您尝试使用127017.

TCP port numbers are 16-bit unsigned, which mean the max value is 65535 (2^16), and you're trying with 127017.

这篇关于MongoDB通过端口转发问题在Vagrant上的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 21:20