[SERVER-27495] When given an invalid address, client connects to localhost Created: 22/Dec/16 Updated: 27/Oct/23 Resolved: 07/Jan/17 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | 3.5.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Guilherme Marconi | Assignee: | Andrew Morrow (Inactive) |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Operating System: | ALL |
| Sprint: | Platforms 2017-01-23 |
| Participants: |
| Description |
|
When connecting using mongo client (command line, windows), if the address given is invalid, mongo client will connect to localhost instance, without giving any errors. This happens if you provide only a part of the server full URI. Example: mongo myserver -> connects to localhost, no error message. nslookup myserver returns server ip address, not mine. mongo myserver.fulldomain.com -> connects to myserver correctly. Not sure if it's a bug or it's by design (a previously taken decision), and I wasn't able to find anything on the matter. If it's by design I'd vote to change this to improvement and ask for a warning message (someone might really think they are acting on 'myserver' when it's acting on 'localhost' really - and if both localhost and myserver belongs to the same replicaSet, the prompt will be the same 'replicaSetName:SECONDARY'). |
| Comments |
| Comment by Andrew Morrow (Inactive) [ 07/Jan/17 ] | |||||||
|
marconi - I'm resolving this ticket as "Works as Designed" because I believe this represents the documented behavior. Please feel free to re-open this ticket if you have any further thoughts on the issue, or require additional assistance. | |||||||
| Comment by Andrew Morrow (Inactive) [ 03/Jan/17 ] | |||||||
|
While I agree that it may be somewhat confusing, this is the expected behavior. Please note the following output from the shell when run with --help:
In your case, the single argument is being interpreted as the name of a database - not the name of a host. If you wish to specify both the host and the database, use one of the other indicated formats. Also, please note that while the help output does not show it, modern versions of the MongoDB shell support much of the MongoDB URI syntax (i.e. mongo mongodb://...). You might do better to switch to using that format, as it makes it much clearer what is going on, generally. When using this syntax, the host name is always required, so there is no ambiguity. |