{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/1711","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/1711/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/1711/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/1711/events","html_url":"https://github.com/Automattic/mongoose/issues/1711","id":20068570,"number":1711,"title":"Cannot write to a secondary","user":{"login":"habicm","id":2984156,"avatar_url":"https://avatars.githubusercontent.com/u/2984156?v=3","gravatar_id":"","url":"https://api.github.com/users/habicm","html_url":"https://github.com/habicm","followers_url":"https://api.github.com/users/habicm/followers","following_url":"https://api.github.com/users/habicm/following{/other_user}","gists_url":"https://api.github.com/users/habicm/gists{/gist_id}","starred_url":"https://api.github.com/users/habicm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/habicm/subscriptions","organizations_url":"https://api.github.com/users/habicm/orgs","repos_url":"https://api.github.com/users/habicm/repos","events_url":"https://api.github.com/users/habicm/events{/privacy}","received_events_url":"https://api.github.com/users/habicm/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Automattic/mongoose/labels/won't%20fix","name":"won't fix","color":"006b75"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2013-09-25T20:42:19Z","updated_at":"2015-10-15T12:07:03Z","closed_at":"2013-09-26T15:03:47Z","body":"I have a web server connecting to mongolab, I have been developing without any issue, however my server is going to QA and after one day I am getting following error know that I am using just single server.\r\n\r\nError: Cannot write to a secondary\r\nat canCheckoutWriter (/var/node/ci/fieldevent-website/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:756:12)\r\nat Server.checkoutWriter (/var/node/ci/fieldevent-website/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:771:16)\r\nat __executeInsertCommand (/var/node/ci/fieldevent-website/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1651:38)\r\nat Db._executeInsertCommand (/var/node/ci/fieldevent-website/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1772:5)\r\nat insertAll (/var/node/ci/fieldevent-website/node_modules/mongoose/node_modules/mongodb/lib/mongodb/collection.js:330:13)\r\nat Collection.insert (/var/node/ci/fieldevent-website/node_modules/mongoose/node_modules/mongodb/lib/mongodb/collection.js:92:3)\r\nat NativeCollection.(anonymous function) [as insert] (/var/node/ci/fieldevent-website/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:129:21)\r\nat model.save (/var/node/ci/fieldevent-website/node_modules/mongoose/lib/model.js:173:21)\r\nat model._done (/var/node/ci/fieldevent-website/node_modules/mongoose/node_modules/hooks/hooks.js:59:24)\r\nat _next (/var/node/ci/fieldevent-website/node_modules/mongoose/node_modules/hooks/hooks.js:52:28)\r\nat fnWrapper (/var/node/ci/fieldevent-website/node_modules/mongoose/node_modules/hooks/hooks.js:159:8)\r\n\r\nI am connecting to mongoDB using this:\r\n\r\nvar options =  {\r\n                        server:  { poolSize:  5,\r\n                                   socketOptions: { keepAlive: 1 }\r\n                        }\r\n                    }\r\n\r\nvar connection = mongoose.createConnection(db.url, options, function(err) {\r\n   if (err) {\r\n       Logger.error(\"Could not connect to database with error: \" + err);\r\n   }\r\n})\r\n\r\nThanks in advance for your help"},"comment":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/comments/148367367","html_url":"https://github.com/Automattic/mongoose/issues/1711#issuecomment-148367367","issue_url":"https://api.github.com/repos/Automattic/mongoose/issues/1711","id":148367367,"user":{"login":"lpuccini","id":10496067,"avatar_url":"https://avatars.githubusercontent.com/u/10496067?v=3","gravatar_id":"","url":"https://api.github.com/users/lpuccini","html_url":"https://github.com/lpuccini","followers_url":"https://api.github.com/users/lpuccini/followers","following_url":"https://api.github.com/users/lpuccini/following{/other_user}","gists_url":"https://api.github.com/users/lpuccini/gists{/gist_id}","starred_url":"https://api.github.com/users/lpuccini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lpuccini/subscriptions","organizations_url":"https://api.github.com/users/lpuccini/orgs","repos_url":"https://api.github.com/users/lpuccini/repos","events_url":"https://api.github.com/users/lpuccini/events{/privacy}","received_events_url":"https://api.github.com/users/lpuccini/received_events","type":"User","site_admin":false},"created_at":"2015-10-15T12:07:03Z","updated_at":"2015-10-15T12:07:03Z","body":"Why do I get this error without a replica set then? It sounds a bit strange to me\r\n"}}