Intermittent issue with migration task

i have exected the below command multiple times and it was executed fine with some 20k document update status, but suddently it fails again with the same configurations.

Error during migration, Error: querySrv ETIMEOUT

the test task was not able to complete because of this issue, i have enhanced the script correctly without any issues but its failing because some db issues,
i have given my sample code which was update for my tutorial, please let me know how to go forward.

const host = 'mongodb+srv://'
	const client = await MongoClient.connect(host,	{ useNewUrlParser: true, useUnifiedTopology: true}
	const mflix = client.db("sample_mflix")
const predicate = { lastupdated: { $exists: true, $type:'string' } }
    const projection = { lastupdated: 1 }
    const cursor = await mflix
      .find(predicate, projection)
    const moviesToMigrate ={ _id, lastupdated }) => ({
      updateOne: {
        filter: { _id: ObjectId(_id) },
        update: {
          $set: { lastupdated: new Date(Date.parse(lastupdated)) },

const  modifiedCount  = await mflix.collection('movies').bulkWrite(moviesToMigrate)

below is the image shows the connection issues, may be the server is not responding to the connection request, with the same configuration which usually worked for me through out the course.

Hi @Rama_krishna1,
Can you please verify your credentials in the connection string, the course says to use: m220student, m220password as the user-id and password?
In case you have any doubts, please feel free to reach out to us.

Sourabh Bagrecha,
Curriculum Services Engineer

Thanks a lot Sourabh, for the replay

Actually i have used my own credentials, like m2student and pwd. and it worked for me till the migration task.
not sure suddenly some thing happend and the connection is not working

Could you please guide me with this connections issues.

Hi @Rama_krishna1,
The intermittent nature of the failure could mean there could be many causes. If it has succeeded in the past and given the error message, a first hypothesis would be to investigate if this wasn’t network-related due to the timeout message. A way to investigate this hypothesis would be to enable the keepalive setting on your TCP socket for broader details on the options you can set for your MongoDB connections, you can see this and the entire list of options on this docs page.In order to test the hypothesis, you should configure keepalive to enable and then re-attempt the operation.
Were there any network changes in your local setup from when this operation succeed for you as compared to when it failed? This isn’t the only possible hypothesis given the information and it may require rejecting more hypotheses with experiments before the cause(s) are identified. Looking forward to hear your results from testing this hypothesis.

In case you have any doubts, please feel free to reach out to us.

Thanks. Regards.
Sourabh Bagrecha,
Curriculum Services Engineer