LoginSignup
0
0

More than 5 years have passed since last update.

MongoDBの"No hostname or hostnames provided in connection string"エラーにハマったお話

Last updated at Posted at 2018-11-14

問題発生

MongoDBもといMongooseでDBに接続しようとしたところ以下のようなエラーが出てきて接続ができなかった。
※MongoDBでもMongooseでもこの現象は起こります。

MongoParseError: No hostname or hostnames provided in connection string

解決

以下のように接続しようとしたが上記エラーになった。

var mongoose = require('mongoose');
mongoose.connect('mongodb:///localhost:27017/db_name');

これだけ見るとすぐ気づくと思われるが、ドメイン前の「/」が一個多かったのだ。
ものすごい初歩的なミスだがハマったのでメモとして残しておきます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0