質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

MongoDB

MongoDBはオープンソースのドキュメント指向データベースの1つです。高性能で、多くのリトルエンディアンシステムを利用することができます。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

Q&A

解決済

1回答

386閲覧

mongodbに接続したい

merico

総合スコア12

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

MongoDB

MongoDBはオープンソースのドキュメント指向データベースの1つです。高性能で、多くのリトルエンディアンシステムを利用することができます。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

0グッド

0クリップ

投稿2018/01/27 07:54

編集2018/01/27 08:01

##mongodbに接続したい
環境
-centOS6
ドットインストール「Node.js入門」に従ってい学習中

やりたいこと
-仮想サーバとmongoDBを接続したい。
接続後”connected to db”と出力される

##エラー

//terminal [vagrant@localhost nodejs]$ node mongo.js /home/vagrant/nodejs/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:532 let sslOptions = { ^^^ SyntaxError: Unexpected strict mode reserved word at Module._compile (module.js:439:25) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (/home/vagrant/nodejs/node_modules/mongodb/node_modules/mongodb-core/index.js:19:15) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32)
//mongo.js var MongoClient = require('mongodb').MongoClient, settings = require('./settings'); MongoClient.connect("mongodb://"+settings.host+"/"+settings.db, function(err, db) { if (err) { return console.dir(err); } console.log("connected to db"); });
[vagrant@localhost nodejs]$ mongo 192.168.33.10 MongoDB shell version v3.6.2 connecting to: mongodb://192.168.33.10:27017/test 2018-01-27T16:59:24.142+0900 W NETWORK [thread1] Failed to connect to 192.168.33.10:27017, in(checking socket for error after poll), reason: Connection refused 2018-01-27T16:59:24.142+0900 E QUERY [thread1] Error: couldn't connect to server 192.168.33.10:27017, connection attempt failed : connect@src/mongo/shell/mongo.js:251:13 @(connect):1:6 exception: connect failed

やってみたこと
/etc/mongod.confの中を変更
参照ページ

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

kabao

2018/11/26 10:00

Connection refused ということなので単純に疎通できていない可能性が高いですが、pingやtelnetなどで疎通確認してみてはいかがですか?
guest

回答1

0

ベストアンサー

疎通していない可能性があるのでそこを確認してくださいなー
https://qiita.com/momota10/items/cbe5c7e20b6f8d27e391

同様の質問もあるので参考までに
https://teratail.com/questions/14479

投稿2019/03/26 14:28

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問