Reputation: 873
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?
Upvotes: 71
Views: 250527
Reputation: 290
I also encountered an issue that I was able to resolve by specifying the --host
parameter along with npm run dev
. For some reason, all the host interfaces, including Docker's host interface, were attempting to open simultaneously when running npm run dev
, which resulted in an error. To fix this, I ran:
npm install
npm run dev --host localhost
Upvotes: 0
Reputation: 201
I was facing issues with running npm install on several projects on my localhost. Here’s what worked for me:
Deleted package-lock.json in the project directory. Ran npm install again. Restarted my Mac. After following these steps, the installation worked without any issues. It seems the package-lock.json file was causing conflicts, and restarting the machine helped to clear any lingering issues.
Hope this helps anyone facing similar problems!
Upvotes: 0
Reputation: 1190
I had the same issue I ran killall node
then npm start
after that my local server at port 5000 worked again.
Upvotes: 68
Reputation: 81
just kill the running server by tapping the delete button in visual studio and then run again the server.
npm start
Upvotes: 2
Reputation: 164
Delete the node_modules folder and then run npm install. This solved the error for me.
Upvotes: 1
Reputation: 155
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
Upvotes: 5
Reputation: 369
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
Upvotes: 1
Reputation: 957
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
Upvotes: 1
Reputation: 11
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
Upvotes: 0
Reputation: 281
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!
Upvotes: 1
Reputation: 529
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
Upvotes: 1
Reputation: 2574
In my case, it worked after I followed the steps below:
Upvotes: 5
Reputation: 1269
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 [email protected]
npm start
Upvotes: 1
Reputation: 1569
Perhaps you started the echo server elsewhere with same port.
Upvotes: 1
Reputation: 2550
Try npm start
as superuser: sudo npm start
This worked for me.
Upvotes: 26
Reputation: 1330
For windows users, run command
Taskkill /IM node.exe /F
It works for me.
Reference:
https://stackoverflow.com/a/51408717/9033834
Upvotes: 10
Reputation: 121
restart the WebStorm was worked for me.
instead of removed 'node_modules' folder and reinstall modules by npm install
.
Upvotes: 3
Reputation: 147
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
Upvotes: 3
Reputation: 348
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/
Upvotes: 5
Reputation: 566
Just run this command in your terminal
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Upvotes: -1
Reputation: 1073
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.
Upvotes: 1
Reputation: 667
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.
Upvotes: 3
Reputation: 558
Removing the node_modules
directory and reinstalling again using npm install
should solve the problem.
Upvotes: 54