Difficulty connecting from Amazon EC2 Ubuntu instance

I have opened ports 27017-27019. Still cannot connect to MongoDB Atlas from my Amazon EC2 Ubuntu instance. I get the following error after it times out:

MongoServerSelectionError: Server selection timed out after 30000 ms
    at Topology.selectServer (/var/www/html/mongo/node_modules/mongodb/lib/sdam/topology.js:303:38)
    at async Topology._connect (/var/www/html/mongo/node_modules/mongodb/lib/sdam/topology.js:196:28)
    at async Topology.connect (/var/www/html/mongo/node_modules/mongodb/lib/sdam/topology.js:158:13)
    at async topologyConnect (/var/www/html/mongo/node_modules/mongodb/lib/mongo_client.js:204:17)
    at async MongoClient._connect (/var/www/html/mongo/node_modules/mongodb/lib/mongo_client.js:217:13)
    at async MongoClient.connect (/var/www/html/mongo/node_modules/mongodb/lib/mongo_client.js:142:13)
    at async MongoClient.connect (/var/www/html/mongo/node_modules/mongodb/lib/mongo_client.js:295:16) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    servers: Map(3) {
      'cluster0-shard-00-02.k1jw3.mongodb.net:27017' => [ServerDescription],
      'cluster0-shard-00-00.k1jw3.mongodb.net:27017' => [ServerDescription],
      'cluster0-shard-00-01.k1jw3.mongodb.net:27017' => [ServerDescription]
    },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: 'atlas-l1r2ml-shard-0',
    maxElectionId: null,
    maxSetVersion: null,
    commonWireVersion: 0,
    logicalSessionTimeoutMinutes: null
  },
  code: undefined,
  [Symbol(errorLabels)]: Set(0) {}

}