I have registered a VPS with DirectAdmin, running CentOS and I'm using a domain which I registered from a different site. I've done the necessary configuration to make the domain display the default page of the VPS. I've also installed node.js and mongoDB using CentOS, but I'm stuck on getting to run the appliction. I've set a .conf file for MongoDB where bind_ip is set to the IP of the VPS and when I try to run MongoDB on port 27017, I get the following message:

service mongod start
Starting mongod:                                           [  OK  ]
bash: /var/log/mongodb/mongodb.log: Permission denied

I think this is caused by the fact that I didn't do any authorization for the VPS, but I couldn't find out how to do authorization. What am I doing wrong?

Also, I can't get node.js to run properly. When I run a basic node.js app on CentOS, port 3000, everything seems to be fine, but when I visit my domainname or VPS IP on port 3000, the server doesn't respond. How do I solve this? Do I need to configure ports on my VPS to make the server respond?

When opening the domain without specifying the port on a browser, how can I configure the VPS to connect to the node application, instead of showing the default index.html page?

I don't have any experience on configuring node.js on a VPS, so my final question: are there any tutorials on getting to run node.js with MongoDB on a VPS? Thanks in advance.

Edit: I solved the MongoDB issue by simply reinstalling it. I guess something went wrong during the installation the first time.


Seems like you're starting the mongod as unprivileged user, so it can't open the logfile. You should run the mongod service as a system service and then provide access to users (check db.addUser documentation).

To run Node.js in production it's better suggested to use some facility like https://github.com/nodejitsu/forever and then proxy requests through a proxy. You can do with Apache, so set it to listen your index.html to another port, say 8080 in ports.conf

    Listen 8080

and add a virtual to redirect to your app at 80, something like:

    <VirtualHost you.example.com:80>
        ProxyRequests off

        <Proxy *>
           Order deny,allow
           Allow from all
        <Location />
            ProxyPass http://localhost:3000/
            ProxyPassReverse http://localhost:3000/

Maybe you could lose some pure Node performances as well with this set up, so have a look to https://github.com/nodejitsu/node-http-proxy also.

  • I simply had to turn off httpd and Apache from DirectAdmin and run node.js on port 80 to make it work. If I need to use multiple processes, I will use a proxy using node-http-proxy as Apache is blocking and I see no further reason to use Apache (I'm not using PHP or MySQL). Also, forever is working fine! Thanks a lot for your input. – Guido Passage Jun 7 '13 at 12:18

For this part of the problem:

bash: /var/log/mongodb/mongodb.log: Permission denied

The user you are using to start MongoDB does not have permission to access the log file you have specified using the logpath configuration option. You should first find out what user it is running as (usually mongod if you are using the 10gen RPM).

Then look at the owner of the log file:

ls -al /var/log/mongodb/mongodb.log

You may need to use sudo or log in as root to modify the permissions (or perhaps create the file). Assuming it exists, then you will need to change the ownership, something like this:

chown mongod:mongod /var/log/mongodb/mongodb.log

The other option would to be create a new logging file elsewhere and change the logpath option to point to that.

  • Thank you for your answer. I tried setting permissions but it didn't work, I was running on root and mongod had all permissions on the file but I still got the message "Permission denied". I fixed it by re-installing MongoDB and now it works, I guess something went wrong with the installation. – Guido Passage Jun 6 '13 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.