How to change default mongo port on a bitnami instance
I am running a bitnami instance of mongodb for our pre-production. The
  default port for mongo is 27017. But for security reasons i want to
  change it but it is not possible.


As you mention error code below


  Error: couldn't connect to server
  /opt/bitnami/mongodb/tmp/mongodb-27017.sock:27017, connection attempt
  failed : connect@src/mongo/shell/mongo.js:237:13 @(connect):1:6
  exception: connect failed


As per your error code location (/opt/bitnami/mongodb/tmp/mongodb-27017.sock) mongod tring to connect with port 27017. May be your mongod.conf data files and log files has not configure properly or may be you don't have a authentication permission of that folder where is mongod.conf .

As Bitnami MongoDB documentation here On Unix, the MongoDB clients can connect to the server using a Unix socket file at 

installdir/mongodb/tmp/mongodb.sock


The default port in which MongoDB listens is 27017

The main MongoDB log file is at installdir/mongodb/log/mongodb.log

The MongoDB configuration file is located at installdir/mongodb/mongodb.conf

The official MongoDB documentation has more details about how configure the MongoDB database.

For your further ref here , here and here