[Answer]-How to remove hard coded IP address from connection.py file. (I'm very very new to this)

1👍

By default, mongoengine will try to connect to localhost. It is not finding a mongo instance there, which is the source of your error.

The ip-10-141-58-44.ec2.internal is just the hostname of the server; it is not hardcoded anywhere.

Have a look at your settings.py file, there should be a line such as:

connect('somenamehere')

Where ‘somenamehere’ is the name of your database; if such a line exists, then it is trying to connect to a mongo on the localhost.

Now you have two choices:

  1. Setup mongo on your localhost.
  2. Update settings.py and point it to the location of your mongo database installation. You can do this by passing in an extra parameter host, connect('somenamehere', host='10.10.10.1'). See the documentation for more information.

Leave a comment