Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netlify dev could not connect to target server after long time out #3735

Closed
robations opened this issue Nov 30, 2021 · 8 comments
Closed

netlify dev could not connect to target server after long time out #3735

robations opened this issue Nov 30, 2021 · 8 comments
Labels
type: bug code to address defects in shipped code

Comments

@robations
Copy link

Describe the bug

The netlify dev command correctly starts the gatsby server on port 8000, which is then running correctly.

The most common scenario is there is a long pause (>10 minutes) then dev server says it can't connect to port 8000 and exits with an error code of 1. On one occasion it connected correctly (after the same long wait).

At some point a few months ago this was working fine, unsure which dependency/environment/cli change has broken it.

To Reproduce

Steps to reproduce the behavior:

  1. Run git clone private git repo
  2. Navigate to the cloned repository
  3. Run netlify dev
  4. See that the CLI exits with an error

Bear with me while I work on this. A discussion about this issue might help me or other people. Not at all easy to reproduce bugs with such complicated systems, e.g. do I need to set up another copy of WordPress for this reproduction? Please, tell me no...

Configuration

  • If possible, please copy/paste below your netlify.toml.
  • Please enter the following command in a terminal and copy/paste its output:
$npx envinfo --system --binaries --npmPackages netlify-cli --npmGlobalPackages netlify-cli

  System:
    OS: macOS 11.6
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 16.10.0 - ~/.asdf/installs/nodejs/16.10.0/bin/node
    Yarn: 1.22.15 - /usr/local/bin/yarn
    npm: 7.24.0 - ~/.asdf/installs/nodejs/16.10.0/bin/npm

Expected behavior

Expecting dev server to connect to localhost:8000 shortly after gatsby has finished processing and has opened a port.

CLI Output

You can now view my-project-name in the browser.
⠀
  http://localhost:8000/
⠀
View GraphiQL, an in-browser IDE, to explore your site's data and schema
⠀
  http://localhost:8000/___graphql
⠀
Note that the development build is not optimized.
To create a production build, use gatsby build
⠀
success Building development bundle - 97.505s
⠀
info  gatsby-source-wordpress  Watching for WordPress changes
success Writing page-data.json files to public directory - 1.692s - 147/147 86.87/s
success write out requires - 0.141s
[ LONG WAIT AT THIS POINT ]
◈ Netlify Dev could not connect to localhost:8000.
◈ Please make sure your framework server is running on port 8000
Waiting for the debugger to disconnect...
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Waiting for the debugger to disconnect...

Process finished with exit code 1

Additional context

Is netlify dev waiting for some kind of signal/event from the child process to connect, or is it polling on a regular basis?

NB the output log above is running with the debugger but it fails in the same way without the debugger.

@robations robations added the type: bug code to address defects in shipped code label Nov 30, 2021
@robations
Copy link
Author

I assumed netlify-cli was installed locally (and thus up-to-date) but turns out it was a global installation through homebrew.

After upgrading (6.9.30 -> 7.1.0) it looks like it's working as expected.

@robations
Copy link
Author

I have this issue again with all Netlify cli versions I've tried:

# homebrew global install
netlify-cli/8.13.0 darwin-x64 node-v16.10.0

# devDep (before upgrade)
netlify-cli/8.17.3 darwin-x64 node-v16.10.0

# devDep (after upgrade)
netlify-cli/9.4.0 darwin-x64 node-v16.10.0

Each time gatsby (v3) finishes with:

info  gatsby-source-wordpress  Watching for WordPress changes
success Writing page-data.json files to public directory - 3.865s - 149/149 38.55/s
success write out requires - 0.025s

Then I get after a long pause:

◈ Netlify Dev could not connect to localhost:8000.
◈ Please make sure your framework server is running on port 8000
error Command failed with exit code 1.

It's possible that gatsby is at fault. Open to ideas on how to debug this dialogue between the two platforms.

@robations robations reopened this Feb 14, 2022
@novelnet
Copy link

having the exact same problem on node v17.5.0, gatsby 4.11.2 and netlify-cli ^9.13.2

@reesericci
Copy link

Nope, same issue here on SvelteKit.

@novelnet
Copy link

Solved the issue for me, having an index.js placeholder in src/pages/ (as i usually only used src/pages/de/ with locale redirect: domain.com/de/)

const IndexPage = () => {
  return ""
}

export default IndexPage

@bomzj
Copy link

bomzj commented May 4, 2022

Having the same time out issue with stopping Netlify dev server when 10 or so minutes passed.
I'm using Netlify dev server for functions and Vite as web server. netlify-cli/10.1.0 win32-x64 node-v17.3.0
Error message from Netlify dev server:

Netlify Dev could not connect to localhost:3000.
Please make sure your framework server is running on port 3000

whereas my website is accessible on localhost:3000.

@jorislive
Copy link

For some reason my problem has been resolved by enabling my VPN service on my computer / switching from on network to the other. It seems unrelated since you're running a localhost server but I thought to mention it here anyway.

@danez
Copy link
Contributor

danez commented Sep 30, 2022

Some of these issues should be fixed now as of version 12.0.2. If it still appears please reopen with an example.

@danez danez closed this as completed Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

6 participants