MongoDB has no single "print" button, so "getting print back" depends on where output disappeared. The mongosh shell echoes expression results automatically, while drivers (Node.js, Python, Java) only print what your code explicitly outputs, and the server writes operational messages to logs. Most vanished output traces to one of three causes: a query that legitimately returns nothing, a client-side serialization problem, or a logging setting that redirected or silenced messages. Identify which layer you're troubleshooting first, because the fix differs completely between an empty shell cursor and a driver returning an empty array.
The guidance below targets MongoDB 6.0 and later with mongosh, the shell that replaced the legacy mongo shell, and notes version differences where behavior changed.
Sort out which "print" went missing before changing anything
"Print" in MongoDB means at least five different things, and the remedy depends on which one broke. Separating them takes a minute and prevents pointless configuration churn.
Shell expression output: mongosh evaluates an expression typed at the prompt and displays the result automatically. db.users.find() returns a cursor and mongosh prints a formatted document preview (the first 20 documents by default). Explicit shell printing: print(), printjson(), and console.log() in mongosh write to standard output. Driver-side output: application code in Node.js, Python, or another language prints only through that language's own output calls; a query result sitting in a variable prints nothing by itself. Server logging: mongod and mongos write connection, query, and error events to a log file or the system journal, controlled by systemLog settings in the configuration file or command-line options. Server-side JavaScript printing: print() calls inside $where, mapReduce functions, and similar evaluated JavaScript historically wrote to the server log or the shell depending on context; recent versions discourage $where entirely.
A useful triage rule: if a command returns nothing in the shell, the question is about query results or cursor iteration. If the shell returns results but nothing appears in logs, the question is server logging. If the application shows empty arrays where the shell shows documents, the question is driver usage or a connection pointed at a different database.
Restore automatic result display in mongosh
mongosh prints results by default, so unexpected silence usually means the query actually matched nothing, the cursor was consumed, or the expression's value was undefined.
Prerequisites: a running mongod or mongos you can reach, a mongosh session connected to the right database, and a known collection name. Check the connection first with db.getName().
1: Run a bare expression to confirm echo works: type 1 + 1 and press Enter. A working shell prints 2. 2: Confirm the database and collection: db.getName() and db.getCollectionNames(). 3: Count before querying: db.users.countDocuments({}). A zero count explains empty output with no further debugging. 4: Run the query as a bare expression rather than assigning it: db.users.find({ status: "active" }) prints a preview; const c = db.users.find(...) stores the cursor silently, and you must then call c.toArray() or iterate it. 5: If a stored cursor prints nothing, check it hasn't already been drained. Iterating a cursor exhausts it; a second for loop over the same exhausted cursor yields nothing. Re-run the query to get a fresh cursor. 6: To force full output rather than the default 20-document preview, append .toArray() or iterate explicitly:
7: If multi-line pasted scripts hide output, switch to line-by-line evaluation or load the script with load("script.js"); mongosh shows the value of the final expression and anything you explicitly print.
Success check: a fresh query on a non-empty collection displays at least one document, and countDocuments agrees with what you expect. If counts are correct but documents still never display, inspect the documents themselves: a projection that excludes every field ({ _id: 0, missingField: 1 }) returns documents with no visible content, which looks like missing print but is a projection error.
When the shell shows a cursor but no documents
mongosh prints a cursor's documents up to the preview limit, so a cursor that matches zero documents prints nothing after the initial { ok: 1 }-style acknowledgment of the command. Two failure modes mimic lost output. First, a filter with a type mismatch returns nothing without error: querying { userId: "42" } against a numeric field silently matches zero documents unless you use $expr with conversion or store consistent types. Second, a case-sensitive regex misses capitalized values. The diagnostic is always the same—run countDocuments with an empty filter, then add filter clauses one at a time until the count drops to zero, which pinpoints the clause responsible.
Get prints back in Node.js, Python, and other drivers
Driver code never prints query results on its own. If your application "stopped printing" results, the cause is in your code, not the server.
Prerequisites: a working connection string, the driver installed, and a reproduction script you can run from the terminal.
1: Verify the connection points at the database you inspected in the shell. Hard-code the database name in the URI path or the client call instead of relying on defaults; a driver defaulting to test while you examined app produces empty arrays with a healthy connection. 2: Check that the query result is actually consumed. In Node.js, find() returns a cursor; call .toArray() or use for await before printing. In Python (PyMongo), find() returns a cursor that prints only when iterated. 3: Print explicitly with the language's output call. In Node.js use console.log(JSON.stringify(docs, null, 2)), because logging raw documents may collapse nested structure or, for large ObjectIds and dates, display differently than the shell. In Python use pprint(docs) or print(docs) after list(cursor). 4: Handle the empty-set case: print the result length alongside the data (console.log(docs.length, docs)), so an empty array is visible rather than looking like silence. 5: Check for swallowed errors. An awaited call inside a try block whose catch does nothing produces no output and no trace; add a logging statement inside the catch. 6: In languages with buffered output (Python especially), a process that exits or crashes before the buffer flushes can lose prints. Flush explicitly (print(..., flush=True)) or run unbuffered to test.
Success check: the script prints a length and the expected documents, and running the same filter in mongosh returns matching content. That agreement confirms server and client see the same data.
Bring back server logs and diagnostic messages
If the problem is that nothing appears in mongod's log—no startup messages, no query entries—the logging configuration is the place to look. These settings live in the configuration file (/etc/mongod.conf on typical Linux packages) or on the command line; changes require a restart or, for verbosity, a runtime command.
1: Find the current destination: check systemLog.destination in the config. file writes to systemLog.path; omitting it sends output to standard output (captured by systemd's journal on most Linux installs) rather than a file. If you were tailing an old file path, the logs may simply be going elsewhere now. 2: Confirm quiet mode is off. quiet: true in the config suppresses most informational messages, which is the most common reason logs "stop" after a config review. 3: Check the log path exists and is writable by the mongod user. A permissions error at startup can leave you with a running-looking service and a stale or empty log file. 4: Use the runtime verbosity control for targeted debugging:
This increases verbosity for the query component until reset to 0. It changes logging behavior for the running process without a restart; the setting doesn't persist across restarts unless you set systemLog.component.query.verbosity in the config.
5: On systemd-managed Linux hosts, read the journal (journalctl -u mongod) when the config has no file destination. 6: Remember that server-side print() inside evaluated JavaScript writes to the server log, not to your shell; if you expected output in the shell, that is a wrong expectation rather than a failure.
Success check: performing an action you know generates a log entry (starting the service, or a slow query above the profiler threshold) produces a new line at the current destination. If the destination file hasn't changed size after such an action, re-verify the path and permissions before anything else.
Turning logging back on after it was disabled
Two settings account for most "logging disappeared" reports. Setting systemLog.destination: syslog moves output to the system logger, so the mongod log file goes quiet while the journal fills. Setting the log path to a directory the service user cannot write means mongod may continue running with output going nowhere useful. Both are visible in the config file and both reverse cleanly with a restart. Verbosity left at a high component level is the opposite problem—too much output—and resets with db.setLogLevel(0).
Understand why output vanished in the first place
The common thread in nearly every case is that MongoDB's layers have different defaults, and mistaking one for another produces false alarms.
The shell is designed to be interactive, so it echoes results generously. Drivers are designed to be embedded in programs, so they print nothing unless instructed. The server is designed for durability, so it logs operational events rather than query results—query results are never written to logs by default, and enabling the database profiler (db.setProfilingLevel) records query performance data in a capped system.profile collection, not row contents. Expecting query rows in the log is a category error, not a misconfiguration.
A second cause is cursor semantics. Every driver's find() returns a lazy cursor; results materialize only when iterated, converted to an array, or previewed by the shell. Code that builds a cursor, checks it for truthiness, and prints the object prints driver internals rather than documents—which many developers describe as "not printing the data."
Third, type mismatches fail silently. MongoDB compares values with type sensitivity in filters, so an integer field queried with a string yields zero matches without an error. The count-first diagnostic described earlier resolves this in seconds.
Fourth, buffering hides prints at process exit. A script that prints and then exits abnormally, or a containerized process writing to a closed stdout, loses output that was generated correctly. Testing with forced flushes distinguishes a real logic problem from a buffering artifact.
A worked estimate shows why the count-first habit saves time: a filter that matches one document in a million returns quickly with an empty-looking preview for the wrong clause, then returns a preview full of documents for the right one. Running countDocuments({}) and then countDocuments(filter) costs two fast queries and isolates the problem clause far faster than reading driver documentation.
Fix output in aggregation pipelines and $where
Aggregations and evaluated JavaScript each have their own output behavior that differs from plain finds.
For aggregations, the shell prints the result cursor the same way it prints find() results, but two stages commonly produce "empty" output that isn't empty at all. A $group stage without a _id produces one document of grouped values; if you expected per-document lines, the output looks wrong but is correct. A $match placed after $limit filters away most rows, which is often a pipeline-ordering mistake rather than a data problem. Preview the pipeline stage by stage by running each prefix separately in the shell, which shows which stage drops everything.
For $where and similar evaluated JavaScript, print() inside the function writes to the server log, not the shell, and MongoDB discourages $where for performance and safety reasons in current versions. If you're debugging logic that was written with $where, reproducing it in mongosh as a loop that prints matching _ids gives you visible output without touching server-side JavaScript at all:
For mapReduce, which is deprecated in favor of the aggregation pipeline, emitted values surface in a result document; converting the emit logic to a $group stage produces clearer, faster output and current tooling supports it.
Keep prints visible with reusable habits
A few durable practices keep this troubleshooting from recurring. Print counts alongside documents in application code so empty results are visible. Keep connection database names explicit in URIs and client constructors. In mongosh, prefer printjson over bare console.log for documents, because it formats dates, ObjectIds, and nested objects in a readable, driver-neutral way. Read documents into an array with .toArray() when you need to print the whole result set, since the shell's default preview intentionally caps output.
It also helps to know what "print back" used to mean. The legacy mongo shell printed expression results on one line and included helpers like printjson and the --eval flag whose behavior mongosh carried forward but with formatting changes. Scripts migrated from mongo that relied on exact one-line output may look different in mongosh without anything being broken; adjusting the print call resolves the cosmetic difference.
Finally, when troubleshooting, isolate one layer at a time: confirm the count in the shell, print the length in the driver, check the log destination with a known event, then re-introduce complexity. Each layer has a single, inspectable success condition, which makes the whole search finite.
Quick answers to recurring causes
Why does db.collection.find() show nothing in mongosh? Usually zero matches, a stale connection to a different database, or an exhausted cursor from earlier iteration. Run countDocuments({}) to split these causes.
Why does my driver return an empty array while the shell shows documents? The driver is likely connected to a different database, or the filter contains a type mismatch the shell run didn't have. Print the database name in both places.
Where did the mongod log go? Check systemLog.destination and systemLog.path in the config, verify quiet isn't true, confirm file permissions for the service user, and check systemd's journal if no file is configured.
Can I make the server log query results? No. The profiler records performance metadata in system.profile, not result documents; to see data, print it in the shell or the driver.