[SERVER-35838] couldn't connect to server localhost:27017, connection attempt failed Created: 27/Jun/18 Updated: 23/Jul/18 Resolved: 27/Jun/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Networking |
| Affects Version/s: | 3.4.15 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Prashant Pokhriyal | Assignee: | Nick Brewer |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Operating System: | ALL | ||||
| Participants: | |||||
| Description |
|
I'm not able to copy a database. It returns me following error:
I don't know why it says localhost, I'm connecting to mongodb server having ip address 172.31.21.200. Output of mongo --version
|
| Comments |
| Comment by Nick Brewer [ 29/Jun/18 ] | ||
|
In general, it is not an advisable practice to change the value of localhost in /etc/hosts - nor is it a good idea to have multiple lines for the same IP address. Assuming that you have properly configured the 172.31.21.200 IP address on your machine, you should be able to resolve this issue by re-mapping localhost to 127.0.0.1, and then using the --host option when connecting to it with the mongo shell. I mention the proper configuration of the IP address - you can confirm that it's configured properly via:
These are Linux configuration issues, and do not demonstrate an underlying bug in MongoDB. As such, I'd ask that you please post on the mongodb-user group or Stack Overflow with the mongodb tag. A question like this involving more discussion would be best posted on the mongodb-user group. Regards, | ||
| Comment by Prashant Pokhriyal [ 29/Jun/18 ] | ||
|
@Nick Brewer, Thanks for the response, I'm able to reproduce this issue. In my /etc/hosts if I mapped same ip address twice then it's behaving same as mentioned above. /etc/hosts file 172.31.21.200 localhost /etc/mongod.conf file net: lsof shows that it is litening on localhost instead of testing.dev
| ||
| Comment by Nick Brewer [ 27/Jun/18 ] | ||
|
I'd ensure that you're specifying the host you wish to connect to - by default the mongo shell uses localhost. For example:
If you're using a non-standard port (something other than 27017), you will also need to specify the port number:
See the Mongo shell reference documentation for more information. Please note that SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag. Cheers, |