This error usually happens on Windows either when ethernet cable is removed and reinserted or when you do reset, disable, enable ethernet on Network and Internet Settings.
Error
My error from yarn looks something like this when I run Nuxt.js, but not limited to Nuxt.js, I get similar errors when running any project on port 3000.
[get-port] Unable to find an available port (tried -). Using random port: 3457
[get-port] Unable to find an available port (tried 3000). Using alternative port: 3457
Your error might be from npm where it says
Error: EACCES, Permission denied
There are many other forms or text printed for same error.
You could get the same error for project unrelated to yarn or npm too. Like I did for running Django/Flask.
If at all you have searched online a lot and nothing has worked, there is one last thing you have yet to try, i.e. restart Windows NAT.
Solution
- Open Terminal/CMD with admin rights. Easiest way to do it is go to start and search for
cmdand under Command Prompt click onRun as administration.
2. Run these commands on CMD
net stop winnat
net start winnat
3. That’s it, now go back to your project and run it.
Conclusion
With this usually the problem should be fixed, but if it’s not I’m very sorry for that.
You could try running npx kill-port <port> in hopes that it will kill whatever is running at your target port. Remember to install the package first.
npm install --global kill-port
# OR
yarn global add kill-port
If even that doesn’t work, your error probably has nothing to do with NAT service or a running process and have to search online for a different solution.
If this post helped, please give a clap. If you want more articles like this please follow me. If you had a different solution that worked out for you or any queries you could always comment.
