title: MongoDB centos7 unable to run with a non standard port as a service
body: <p>I installed mongodb on a fresh centos 7<br>
  I run <code>sudo service mongod</code> start without any problem<br>
  When I change the port in <code>/etc/mongod.conf</code> and I restart the mongod service I get the following error</p>
  
  <p>From <code>/var/log/mongodb/mongod.log</code></p>
  
  <blockquote>
    <p>2014-11-11T07:38:29.495+0000 [initandlisten] MongoDB starting : pid=12401 port=27022 dbpath=/var/lib/mongo 64-bit host=awscm001<br>
    2014-11-11T07:38:29.495+0000 [initandlisten] db version v2.6.5<br>
    2014-11-11T07:38:29.495+0000 [initandlisten] git version: e99d4fcb4279c0279796f237aa92fe3b64560bf6<br>
    2014-11-11T07:38:29.495+0000 [initandlisten] build info: Linux build8.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49<br>
    2014-11-11T07:38:29.495+0000 [initandlisten] allocator: tcmalloc<br>
    2014-11-11T07:38:29.495+0000 [initandlisten] options: { config: "/etc/mongod.conf", net: { port: 27021 }, processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" }, storage: { dbPath: "/var/lib/mongo" }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
    2014-11-11T07:38:29.497+0000 [initandlisten] journal dir=/var/lib/mongo/journal<br>
    2014-11-11T07:38:29.497+0000 [initandlisten] recover : no journal files present, no recovery needed<br>
    2014-11-11T07:38:29.679+0000 [initandlisten] <strong>ERROR: listen(): bind() failed errno:13 Permission denied for socket: 0.0.0.0:27022</strong><br>
    2014-11-11T07:38:29.680+0000 [initandlisten] now exiting<br>
    2014-11-11T07:38:29.680+0000 [initandlisten] dbexit:<br>
    2014-11-11T07:38:29.680+0000 [initandlisten] shutdown: going to close listening sockets...<br>
    2014-11-11T07:38:29.680+0000 [initandlisten] shutdown: going to flush diaglog...  </p>
  </blockquote>
  
  <p>I am able though to run with a different port with the following command</p>
  
  <pre><code>sudo mongod -f /etc/mongod.conf
  </code></pre>
  
  <p>When I run as a service user mongod runs mongodb<br>
  When I run from command line root runs mongodb</p>
  
  <p>How can run the mongodb service with a different port?<br>
  By the way I succeeded on centos 6.5<br>
  Thanks</p>