FAQ

[mongodb-user] 'MongoConnectionException' - 'Failed to connect to: localhost:27017'

Sathyamoorthi P
Jan 8, 2013 at 1:07 pm
Hi All,

I used the following php code to connect with MongoDB.

*$m = new MongoClient("mongodb://localhost:27017");*

But i am getting the following error.
*
*
*Fatal error: Uncaught exception 'MongoConnectionException' with message
'Failed to connect to: localhost:27017: Unknown error'**
*
*
*
I tried lot of connection string possibilities that are posted in various
blogs. but nothing helped. Can anyone help on this?

i am seeing following details in my phpinfo

mongo MongoDB Supportenabled Version 1.3.2RC1
DirectiveLocal ValueMaster Value mongo.allow_empty_keys00 mongo.chunk_size
262144262144 mongo.cmd$$ mongo.default_hostlocalhostlocalhost
mongo.default_port2701727017 mongo.is_master_interval*no value**no value*
mongo.long_as_object00 mongo.native_long00 mongo.ping_interval*no value**no
value* mongo.utf811
*
*
Thanks,
Sathyamoorthi.

--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user+unsubscribe@googlegroups.com
See also the IRC channel -- freenode.net#mongodb
reply

Search Discussions

3 responses

  • Sathyamoorthi P at Jan 8, 2013 at 1:18 pm
    Hi,

    I used the following PHP code to connect with MongoDB.

    *$m = new MongoClient("mongodb://localhost:27017");*

    But i am getting below error.

    *Fatal error: Uncaught exception 'MongoConnectionException' with message
    'Failed to connect to: localhost:27017: Unknown error'*

    I tried lot of connection string possibilities that are posted in various
    blogs. nothing helps. Can anyone help on this?

    this is my mongoDB phpinfo.

    mongo MongoDB Supportenabled Version 1.3.2RC1
    DirectiveLocal ValueMaster Value mongo.allow_empty_keys00 mongo.chunk_size
    262144262144 mongo.cmd$$ mongo.default_hostlocalhostlocalhost
    mongo.default_port2701727017 mongo.is_master_interval*no value**no value*
    mongo.long_as_object00 mongo.native_long00 mongo.ping_interval*no value**no
    value* mongo.utf811

    Thanks,
    Sathyamoorthi.

    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com
    See also the IRC channel -- freenode.net#mongodb
  • Wiwwo.com at Jan 8, 2013 at 1:36 pm
    Hi there!
    Try changing localhost to 127.0.0.1

    On Tuesday, January 8, 2013 2:05:14 PM UTC+1, Sathyamoorthi P wrote:

    Hi All,

    I used the following php code to connect with MongoDB.

    *$m = new MongoClient("mongodb://localhost:27017");*
    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com
    See also the IRC channel -- freenode.net#mongodb
  • Hannes Magnusson at Jan 31, 2013 at 2:00 am
    Did cosimo.simeone's suggestion work?

    Are you sure mongod is running properly on your localhost?
    You can try connecting with the shell to verify everything is working fine.

    Some systems map "localhost" to IPv6, which the PHP driver doesn't
    support at this time, so using "127.0.0.1" should work for that case.

    -Hannes

    On Tue, Jan 8, 2013 at 8:05 AM, Sathyamoorthi P
    wrote:
    Hi All,

    I used the following php code to connect with MongoDB.

    $m = new MongoClient("mongodb://localhost:27017");

    But i am getting the following error.

    Fatal error: Uncaught exception 'MongoConnectionException' with message
    'Failed to connect to: localhost:27017: Unknown error'

    I tried lot of connection string possibilities that are posted in various
    blogs. but nothing helped. Can anyone help on this?

    i am seeing following details in my phpinfo

    mongo

    MongoDB Supportenabled
    Version 1.3.2RC1

    DirectiveLocal ValueMaster Value
    mongo.allow_empty_keys00
    mongo.chunk_size262144262144
    mongo.cmd$$
    mongo.default_hostlocalhostlocalhost
    mongo.default_port2701727017
    mongo.is_master_intervalno valueno value
    mongo.long_as_object00
    mongo.native_long00
    mongo.ping_intervalno valueno value
    mongo.utf811

    Thanks,
    Sathyamoorthi.

    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com
    See also the IRC channel -- freenode.net#mongodb
    --
    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com
    See also the IRC channel -- freenode.net#mongodb

    ---
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post