can't connect thru web server

194 views
Skip to first unread message

asc4john

unread,
Nov 21, 2009, 8:30:02 PM11/21/09
to mongodb-user
Installed MongoDB. Start mongodb. ps ax shows it running. mongo client
connects and I can add data and query it.
On the command line, php myMongoTest.php works. A web test page with
phpinfo() displays mongo as loaded.
But when I try http://myMongoTest.php I get thus error
[Sat Nov 21 19:18:50 2009] [error] [client 192.168.1.101] PHP Fatal
error: Uncaught exception 'MongoConnectionException' with message
'127.0.0.1:27017: Permission denied' in /var/www/html/__TM__/
myMongoTest.php:56\nStack trace:\n#0 /var/www/html/__TM__/mongoTest.php
(56): Mongo->__construct('127.0.0.1:27017')\n#1 {main}\n thrown in /
var/www/html/__TM__/mongoTest.php on line 56
Whats wrong?

Michael Lugassy

unread,
Nov 23, 2009, 5:08:13 AM11/23/09
to mongod...@googlegroups.com
would be helpful to see your test script and whether it is connecting
through localhost.
> --
>
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=.
>
>
>



--
Sent from my mobile

Kristina Chodorow

unread,
Nov 23, 2009, 10:44:22 AM11/23/09
to mongod...@googlegroups.com
Hmm, it sounds like the user you're starting your web server as a user that doesn't have permission to open a socket.  Not really sure, I've never seen this before. 

Can you tell us more about your setup?  Are you starting the web server as a different user than you're running the PHP script (on the command line) as?  Also helpful might be: which OS, which web server, any special configuration, any special PHP configuration?

Kristina Chodorow

unread,
Feb 18, 2010, 2:22:49 PM2/18/10
to mongod...@googlegroups.com
Just in case anyone else has this problem, here's the solution:

By default in Fedora 12 (and probably other setups), Apache doesn't allow requests to make network connections.  You can change this by running:

$ /usr/sbin/setsebool -P httpd_can_network_connect 1

and restarting everything.
Reply all
Reply to author
Forward
0 new messages