Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

PhantomJS can appear to “hang” for different reasons: the process was never told to exit, page.open is waiting on a page or resource, or an exception and network failure is being hidden. Diagnose the layer first. Confirm the binary you are running, add explicit termination on every intended outcome, log page and resource callbacks, then investigate HTTPS, proxy, SELinux, and page-script errors. PhantomJS is archived and unmaintained, so treat these steps as legacy-job triage and plan a migration when browser compatibility matters.

Identify what “hanging” means

Watch the terminal and define the symptom before changing code:

  • The page finishes or a file is written, but the command never returns: the JavaScript process likely lacks phantom.exit(), or another asynchronous operation remains active.
  • page.open never calls your expected completion logic: a page or individual request may still be loading, or the callback path is not logged.
  • The process exits only after a very long delay: a resource, proxy, TLS negotiation, or host policy may be delaying a request.
  • The terminal is quiet while the site is visibly broken: PhantomJS does not print page console messages by default, and page JavaScript errors may be undisclosed.

Capture the URL, operating system, PhantomJS version, exact command, and a run with diagnostics enabled. Without those details there is no reliable one-cause fix.

1. Confirm the executable and invocation

Check which binary your shell resolves and whether multiple installations are present:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
phantomjs --version
which phantomjs    # macOS/Linux
where phantomjs    # Windows

The CLI syntax is phantomjs [options] somescript.js [arg1 ...]; PhantomJS runs headlessly. The legacy command-line reference applies to PhantomJS 2.1.1 unless noted: official CLI reference. If a machine has an old package and a manually installed binary, your web application and terminal may be invoking different versions. Run the intended executable by absolute path while troubleshooting.

For extra diagnostics, add the documented debug option:

phantomjs --debug=true capture.js

2. Make process termination explicit

The quick-start documentation warns that PhantomJS will not terminate unless the script calls phantom.exit: Quick Start. Put termination in every deliberate terminal path, including load failure and exception handling. Do not call it immediately after page.open, because that can stop rendering or inspection before asynchronous work completes.

A minimal render pattern is:

var page = require('webpage').create();
var address = system.args[1] || 'https://example.com';

page.open(address, function (status) {
  console.log('Page status: ' + status);
  if (status === 'success') {
    page.render('page.png');
    phantom.exit(0);
  } else {
    phantom.exit(1);
  }
});

The documented render method is described at WebPage.render. If your script starts timers, opens additional pages, or waits for a selector, make sure those operations are completed or cancelled before the final exit.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Instrument page loading and every resource

Use the page.open callback (and its onLoadFinished equivalent) to record whether loading ended with success or fail. The API references are WebPage.open and onLoadFinished.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

For a useful first diagnostic, install callbacks before the initial open:

var system = require('system');
var page = require('webpage').create();
var address = system.args[1] || 'https://example.com';

page.settings.resourceTimeout = 10000; // milliseconds

page.onResourceRequested = function (request) {
  console.log('Request: ' + request.url);
};

page.onResourceTimeout = function (request) {
  console.log('Resource timeout: ' + request.url +
              ' (' + request.errorString + ')');
};

page.onResourceError = function (error) {
  console.log('Resource error: ' + error.url +
              ' (' + error.errorString + ')');
};

page.onError = function (message, trace) {
  console.log('Page JavaScript error: ' + message);
  if (trace && trace.length) {
    trace.forEach(function (item) {
      console.log('  ' + item.file + ':' + item.line +
                  ' ' + item.function);
    });
  }
};

page.onConsoleMessage = function (message) {
  console.log('Page console: ' + message);
};

page.open(address, function (status) {
  console.log('Page status: ' + status);
  phantom.exit(status === 'success' ? 0 : 1);
});

The callback names and payloads are documented in onResourceRequested, onResourceTimeout, and onResourceError. This tells you whether the apparent freeze is one slow URL, repeated failures, or a page-level exception.

Understand the timeout’s boundary

page.settings.resourceTimeout is measured in milliseconds and limits an individual requested resource. Set it before the initial page.open; changing it afterward does not change that initial open. It is not a universal deadline for the whole script, JavaScript loops, later navigation, or total process lifetime. See WebPage settings.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the value for the workload: a very low number can discard legitimate slow assets, while a very high number can leave a failed job waiting longer. Keep the logged URL and error string so you can decide whether to block, remove, or fix that dependency.

4. Catch errors outside the page

page.onError reports exceptions raised by the loaded document. Errors in your PhantomJS script itself can bypass that handler. Add a global handler while diagnosing:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
phantom.onError = function (message, trace) {
  console.log('PhantomJS error: ' + message);
  if (trace) {
    trace.forEach(function (item) {
      console.log('  ' + item.file + ':' + item.line +
                  ' ' + item.function);
    });
  }
  phantom.exit(1);
};

Use this with care in production: an expected, recoverable page error should not necessarily kill a batch. The point during triage is to turn a silent failure into a nonzero exit and a stack trace. If you need the site’s own logs, retain page.onConsoleMessage; console output is otherwise silent by default.

5. Check HTTPS, proxies, and host policy

HTTPS fails while HTTP works

The official troubleshooting guide says to check the SSL libraries, usually OpenSSL, when HTTP succeeds but HTTPS does not: PhantomJS troubleshooting. Verify that the libraries required by your PhantomJS build are installed and discoverable by the process. Also test the same URL from the same account and environment; a browser on your workstation does not prove that the headless binary has equivalent TLS support.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Windows takes an extremely long time

The troubleshooting page notes that Windows’ default proxy can cause massive latency. If your logs show requests waiting rather than failing, test a run with:

phantomjs --proxy-type=none capture.js

Use this only when a direct connection is permitted by your network policy. If the direct run works, configure the correct explicit proxy instead of permanently bypassing an organization’s required gateway.

SELinux or other host controls

The same guide lists SELinux as a possible obstacle and references a custom-policy workaround. Inspect the host’s denial logs first and involve the system administrator; do not disable security controls blindly. A policy change must be tested against the account, binary path, temporary directories, and network permissions used by the real job.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

6. Use the remote debugger for a stubborn case

For a page that still will not complete, start PhantomJS with the documented remote debugger:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
phantomjs --remote-debugger-port=9000 capture.js

Connect with a WebKit-based browser such as Safari, Chrome, or Chromium and inspect script execution, network activity, and the point at which callbacks stop. Port 9000 is the troubleshooting example; choose another permitted local port if it is occupied, and do not expose a debugger port to an untrusted network.

7. Separate a page that never settles from a process that never exits

Modern sites can keep polling, open analytics connections, or continuously create resources. A successful onLoadFinished event does not mean every later activity has stopped, and a missing event may indicate a navigation that never reached a terminal state. Record timestamps for requests, timeouts, errors, and the final callback. Then decide whether your job needs the whole page or only a stable element.

  • If the required content is present after a known delay, perform the capture in that completion path and exit.
  • If one third-party asset repeatedly times out but is irrelevant, determine whether the page can be captured without it; do not hide a dependency that is required for correctness.
  • If a redirect loop or script-driven navigation continues indefinitely, inspect it in the debugger and fix the target URL or page logic.
  • If your own code waits on a selector or timer, add a bounded failure path that logs the condition and calls phantom.exit(1).

8. A repeatable command-line triage checklist

  1. Run phantomjs --version and locate every installed binary.
  2. Re-run with --debug=true and save the terminal output.
  3. Confirm that every success and failure path calls phantom.exit.
  4. Set resourceTimeout before page.open and log resource requests, timeouts, and errors.
  5. Log page.open‘s status and page JavaScript exceptions.
  6. Compare HTTP and HTTPS, then check OpenSSL-related dependencies if only HTTPS fails.
  7. On Windows, test --proxy-type=none when proxy latency is suspected.
  8. Inspect SELinux denial logs where applicable.
  9. Use --remote-debugger-port=9000 for execution that remains unexplained.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is a dependable screenshot rather than maintaining a PhantomJS runtime, ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns PNG, JPEG, WebP, or PDF. It accepts cookie and consent banners before capture, removes more than 60 known consent platforms plus newsletter popups and chat widgets, and lets you turn those steps off. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and whether it was billed.

cURL (see the ScreenshotNeo documentation):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients. Features include full-page lazy-image loading, CSS-selector element capture, device presets and custom viewports, dark mode, retina scale, custom CSS/JavaScript, click and wait actions, request blocking, headers/cookies/user agents, timezone and geolocation, resizing, transparent backgrounds, chosen cache TTLs, signed image links, asynchronous webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. Existing parameter names used by other screenshot APIs also work.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to try it.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

9. Plan for migration

The upstream PhantomJS repository was archived and made read-only on May 30, 2023. Its README says development is suspended, and the PhantomJS Wiki describes the 2.x branch as deprecated and unmaintained. That does not prove every installed binary is unusable or identify the best replacement for your application, but it does mean new TLS behavior, browser APIs, and site changes will not receive upstream fixes.

Keep a pinned, isolated PhantomJS job only when its output is stable and migration is not yet possible. Document the binary version, operating-system dependencies, proxy and certificate requirements, timeout settings, and known target URLs. For a maintained replacement, evaluate the browser automation framework, language, rendering requirements, authentication model, and operating environment rather than assuming one universal successor.

Common errors and fixes

Symptom Likely layer Action
Image is written but command stays alive Process lifecycle Add phantom.exit() after all intended asynchronous work.
No completion message Page lifecycle Log page.open/onLoadFinished status and install resource callbacks.
One URL waits repeatedly Individual resource Set a per-resource timeout before open and inspect its URL and error string.
HTTP works; HTTPS fails TLS Check OpenSSL and the PhantomJS build’s SSL dependencies.
Windows run is extremely slow Proxy Test --proxy-type=none, then configure the required proxy correctly.
Blank terminal, broken page Page JavaScript/logging Attach page.onError and page.onConsoleMessage.
Sandbox or permission denials Host policy Review SELinux/system logs and apply only an administrator-approved policy fix.

Frequently Asked Questions

Does increasing resourceTimeout guarantee PhantomJS will finish?

No. It limits each requested resource during the initial page.open; it is not a whole-process or JavaScript execution deadline.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why does page.onError not show every PhantomJS failure?

page.onError covers errors from the loaded page. Use phantom.onError as well for exceptions in your PhantomJS script.

Is PhantomJS still maintained?

No. The upstream repository is archived and the 2.x branch is described as deprecated and unmaintained.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.