Node events.js:167 throw er; // Unhandled 'error' event
Jsonnode.jsReactjsJson Problem Overview
I'm trying to use JSON Server in a React App. However, I keep getting the following error.
events.js:167
throw er; // Unhandled 'error' event
^
Emitted 'error' event at:
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1498:12)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:50:17)
I've upgraded npm and node to the latest versions. I've killed all processes with killall node and sudo killall -9 node
Any ideas what may be causing the issue?
Json Solutions
Solution 1 - Json
I had the same issue I ran killall node
then npm start
after that my local server at port 5000 worked again. Hope that helps you.
Solution 2 - Json
Removing the node_modules
directory and reinstalling again using npm install
should solve the problem.
Solution 3 - Json
Try npm start
as superuser: sudo npm start
This worked for me.
Solution 4 - Json
test another adb device ... real smartphone or android studie or genymotion npm start in your project open new tab and run react-native run-android and press ctrl + c in past terminal tab
i guess why this problem is we cant run http://localhost:8081/debugger-ui/
Solution 5 - Json
For windows users, run command
Taskkill /IM node.exe /F
It works for me.
Reference:
Solution 6 - Json
If you are running on Windows and have IIS running on your machine, ensure the IIS server is stopped if you are trying to run on port 8080. You can also change the port to not bring IIS into it.
npm start -- --port 8000
Solution 7 - Json
restart the WebStorm was worked for me.
instead of removed 'node_modules' folder and reinstall modules by npm install
.
Solution 8 - Json
In my case, it worked after I followed the steps below:
- Delete node_modules folder.
- Run npm install.
- Run npm update.
- Restart the system. (may be this did the trick)
Solution 9 - Json
Had the same problem and none of the solutions above fixed it.
Server started on port 3000
node:events:368
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND listening
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26)
Emitted 'error' event on Server instance at:
at GetAddrInfoReqWrap.doListen [as callback] (node:net:1517:12)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:17) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'listening'
}
I did notice that node was trying to reach a host called 'listening'. So I added it to my hosts file and that "fixed" it.
127.0.0.1 listening
Solution 10 - Json
I have the same issue. Basically, I am using node v10+ but my project was created in v8.11.4. All the modules were used according to the older version(v8), that's why I am facing the issue. So there are two solutions either update your module or downgrade the node.
I have solved by downgrading the node from v10 to v8. Because some of the modules are not possible to update due to project dependency.
Solution 11 - Json
I ran npm install and then npm update and it works again.
Solution 12 - Json
update severless
with npm. This will resolve it.
Solution 13 - Json
Little late, but for any out there struggling, I came across this error by creating the React app without using sudo
. Using sudo
while running npx create-react-app app-name
fixed the issue.
Solution 14 - Json
Perhaps you started the echo server elsewhere with same port.
Solution 15 - Json
I ran into this exact issue as well and found that it is only present with [email protected], downgrading to [email protected] resolved the issue without needing to mess with environment variables.
create-react-app my-app
cd my-app
npm install react-scripts@2.1.8
npm start
Solution 16 - Json
Your site is running at http://localhost:8000
Try changing your port. Like 3000 or 8080.
app.listen(3000)
My 8080 post was taken, so I got this same error
Solution 17 - Json
Make sure you've closed the previous node connection before opening a new one on the same port.
Just try to close the earlier connection first, and then open the new one!
Solution 18 - Json
I have restored my hosts file to original state on Mac OS and it works for me. I edited this file yesterday and it made the problem. On this site you can copy the text of the original file https://pbxbook.com/other/mac-host.html
Solution 19 - Json
sudo npm start
This should work for you
Solution 20 - Json
In my case the error was caused by a very large project with too many files, and then inotify
cant check and needs to be raised the number of watches. This fix my error.
echo 1048576 > /proc/sys/fs/inotify/max_user_watches
Solution 21 - Json
I was trying to install Vue CLI 4 (VueJS 3) app from the start. So, problem was in versions of node and npm
. At current time the actual version of Node is 17. But for stable Vue CLI 4 needed Node >= 10.
I use nvm
. So changin to downgraded Node worked for me:
nvm use 10.24.1
Solution 22 - Json
Just run this command in your terminal
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Solution 23 - Json
This worked for me
npm install react-scripts@2.1.8
npm start