mongosh --eval 'db.runCommand({ping: 1})'

Category: Databases & SQL

mongosh --eval 'db.runCommand({ping: 1})'

Ping MongoDB to test connectivity

The ping command returns { ok: 1 } when the server is reachable, the standard health probe for mongosh and drivers alike. --eval runs the script and exits. Add --quiet to suppress banner noise in scripts.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.