Console: Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'
A DOM method received something that is not a DOM node — null, undefined, a string, or a jQuery/React object instead of an element.
Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'Failed to execute 'insertBefore' on 'Node'Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this nodeparameter 1 is not of type 'Element'Failed to execute 'replaceChild' on 'Node' Meaning
appendChild, insertBefore, replaceChild and similar need real Node objects. The usual cause is a failed lookup (getElementById returned null because the element did not exist yet) or passing a string where an element is needed (use append() or insertAdjacentHTML).
Common causes
document.getElementById/querySelectorreturnednull(wrong id, script runs before the DOM is ready)- Passing a string, number or array instead of an element
- Passing a jQuery object (
$('#x')) instead of the DOM element ($('#x')[0]) - Element created in another document/iframe
- Typo in a variable name
⚡ Quick fix
- Check that the element exists before using it (
if (el) …) - Run code after DOMContentLoaded or put the script at the end of
<body> - Use
el.append('text')for strings
Detailed fix by platform
JavaScript
const el = document.getElementById('list'); if (!el) throw new Error('#list not found'); el.appendChild(li);- For text:
el.append('Hello')
Code examples
Run after the DOM exists
document.addEventListener('DOMContentLoaded', () => {
const list = document.querySelector('#list');
if (!list) return; // avoid the TypeError
const li = document.createElement('li');
li.textContent = 'New item';
list.appendChild(li); // both arguments are real Nodes
});How to diagnose
- Value — Is the argument null or the wrong type?
- Timing — Is the DOM ready?
- Selector — Does the id/class exist?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- addEventListener on null TypeError: Cannot read properties of null (reading 'addEventListener')
- Aw, Snap! Chrome: Aw, Snap! Something went wrong while displaying this webpage. Error code: STATUS_ACCESS_VIOLATION / SIGILL / Out of Memory
- captive portal Browser: This network requires you to sign in — captive portal (hotel, airport, café Wi-Fi) blocking HTTPS sites
Most viewed in Browser
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 15 Oct 2026