gatsbyjs / gatsby-source-wordpress-experimental

The upcoming v4 of gatsby-source-wordpress, currently in beta
MIT License
385 stars 100 forks source link

Error: listen EADDRINUSE: address already in use 127.0.0.1:52338 #404

Closed martin-braun closed 3 years ago

martin-braun commented 3 years ago

Since 6.1.0 I'm unable to run gatsby develop:

...
info  gatsby-source-wordpress  Watching for WordPress changes
⠹ Building development bundle
/....../node_modules/yoga-layout-prebuilt/yoga-layout/build/Release/nbind.js:53
        throw ex;
        ^

Error: listen EADDRINUSE: address already in use 127.0.0.1:52338
    at Server.setupListenHandle [as _listen2] (net.js:1316:16)
    at listenInCluster (net.js:1364:12)
    at GetAddrInfoReqWrap.doListen (net.js:1501:7)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:68:8)
Emitted 'error' event on Server instance at:
    at emitErrorNT (net.js:1343:8)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  code: 'EADDRINUSE',
  errno: 'EADDRINUSE',
  syscall: 'listen',
  address: '127.0.0.1',
  port: 52338
}
npm ERR! code ELIFECYCLE
npm ERR! errno 7
npm ERR! ........@1.0.0 start: `gatsby develop`
npm ERR! Exit status 7

Yes, there is another server running on 127.0.0.1 (Local by Flywheel), but it's using a different port.

sudo lsof -i :52338

returns nothing.

acao commented 3 years ago

you've probably already tried this but, did you try a gatsby clean in between upgrades?

also, have you tried restarting all running instances of the gatsby server on your machine? you said there is another server running on a different port, what kind of server? a gatsby server? try shutting down all gatsby servers first, then try the upgrade after running gatsby clean

babgyy commented 3 years ago

Speaking for myself : lsof is not retuning anything for the port supposedly in use. Using v6 of this plugin.

It happens when doing gatsby develop, and it happens more frequently when content writers are updating the Wordpress server.

I can't reproduce systematically the issue, but the port in use is not always the same. Quitting the terminal, or restarting my computer sometimes helps, but sometimes not. gatsby clean sometimes helps, but sometimes not. But it also takes 10-20 minutes for a fresh build so it is my last resort.

acao commented 3 years ago

@babgyy what version of gatsby core are you running? is it the latest?

TylerBarnes commented 3 years ago

I think this issue is related https://github.com/gatsbyjs/gatsby/issues/25859

I ran into this myself once and couldn't figure out what was causing it. Changing my node version made it stop 😬

martin-braun commented 3 years ago

@acao I can say it happens every time. Yes I tried gatsby clean. I also tried to restart my machine.

Here are more details of my setup:

you said there is another server running on a different port, what kind of server? a gatsby server? try shutting down all gatsby servers first, then try the upgrade after running gatsby clean

It's the Apache of Local by Flywheel, the program I host the Wordpress with. I cannot disable it, because then the GraphQL API is not accessible by gratsby develop. I can ensure that it worked with 6.0.0. I reverted my version and the build works, so it's something that was added in 6.1.0 or its dependencies.

Here is my downgrade patch of the package.json:

Screen Shot 2021-01-09 at 01 51 58

Red entries caused this issue, green entries fixed this problem (downgraded versions).

@TylerBarnes Your linked issue looks suspicious, the major version of node matches with mine. I will try to switch to node v10 later, but whatsoever, it would not explain why the issue appeared on minor version steps, now, when it was reported back in July 2020.

TylerBarnes commented 3 years ago

Yeah, it's hard to say what's causing it. We will be investigating it further but in the meantime switching your node version should fix it 👍

martin-braun commented 3 years ago

I just want to report that I finally downgraded to node v10, updated all my packages so I'm at the latest version right now. Everything works fine, eventually. Maybe it should be part of the documentation to better use node v10, or is it, already? @TylerBarnes

Anyway, I'm closing this now, it seems to be related to https://github.com/gatsbyjs/gatsby/issues/25859 as you said. If the base of Gatsby supports v12, we could re-investigate and make a new issue if problems come back.

Thanks for your support!