Error: couldn't connect to server - Linux -

It is not clear what problem you are trying to fix. From some of the post it looks like you are trying to fix an installation issues. My reply was to fix

To start a localhost server use the documentation found at https://docs.mongodb.com/manual/reference/program/mongod/

To connect to another server with the mongo command consider the manual at https://docs.mongodb.com/manual/reference/program/mongo/