错误 ECONNREFUSED 在将 Next.js 12 升级到 13 后发生。

huangapple go评论74阅读模式
英文:

Error ECONNREFUSED after upgrading nextjs 12 to 13

问题

I upgraded from Next.js 12 to 13 but now every time I run the application, I'm getting ECONNREFUSED to my local but the port keeps changing, and it won't render.

英文:

I upgraded from Nextjs 12 to 13 but now everytime I run the application, I'm getting ECONNREFUSED to my local but the port keeps changing. and it won't render

> dtpms-usrmgmt-ui@0.1.20 dev /run/media/rud31mp/drive2/Codes/typescript/dtpms/dtpms-usrmngr-ui
> next dev -p 3002

- ready started server on 0.0.0.0:3002, url: http://localhost:3002
- info Loaded env from /run/media/rud31mp/drive2/Codes/typescript/dtpms/dtpms-usrmngr-ui/.env.local
- warn Invalid next.config.js options detected: 
- warn     The root value has an unexpected property, externals, which is not in the list of allowed properties (amp, analyticsId, assetPrefix, basePath, cleanDistDir, compiler, compress, configOrigin, crossOrigin, devIndicators, distDir, env, eslint, excludeDefaultMomentLocales, experimental, exportPathMap, generateBuildId, generateEtags, headers, httpAgentOptions, i18n, images, modularizeImports, onDemandEntries, optimizeFonts, output, outputFileTracing, pageExtensions, poweredByHeader, productionBrowserSourceMaps, publicRuntimeConfig, reactStrictMode, redirects, rewrites, sassOptions, serverRuntimeConfig, skipMiddlewareUrlNormalize, skipTrailingSlashRedirect, staticPageGenerationTimeout, swcMinify, target, trailingSlash, transpilePackages, typescript, useFileSystemPublicRoutes, webpack).
- warn See more info here: https://nextjs.org/docs/messages/invalid-next-config
- event compiled client and server successfully in 1216 ms (311 modules)
- wait compiling...
- event compiled client and server successfully in 334 ms (311 modules)
- wait compiling /not-found (client and server)...
- event compiled client and server successfully in 694 ms (555 modules)
- warn Fast Refresh had to perform a full reload due to a runtime error.
- error Error: connect ECONNREFUSED 127.0.0.1:33241
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1487:16)
    at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 33241
}
- wait compiling /_error (client and server)...
- event compiled client and server successfully in 385 ms (556 modules)

错误 ECONNREFUSED 在将 Next.js 12 升级到 13 后发生。

答案1

得分: 1

这可能与 node > v16 有关。尝试将其降级到 v16

我知道这个答案不是理想的,但似乎是webpack开发环境和启动环境本身之间的竞争条件。

我还在调查中。请关注此问题

英文:

This might be related to node > v16. Try downgrading it to v16.

I know this answer isn't ideal, but it seams to be a race condition between the webpack dev environment and the request to launch the environment itself.

I'm still investigating it. Keep an eye on this issue

答案2

得分: 0

Are you using next.js 的新 google 字体功能吗?我的意思是通过从 'next/font/google' 导入字体吗?

我刚刚在一个新的 next.js 项目中遇到了类似的问题,该项目是通过 'npx create-next-app@latest' 初始化的。默认情况下,'layout.tsx' 使用了这个新功能:

import { Inter } from 'next/font/google'.
const inter = Inter({ subsets: ['latin'] })

我将其注释掉后错误消失了。我猜测 next.js 试图访问 google 服务器以检索字体,但失败了。

英文:

Are you using nextjs new google font feature? I mean using font by importing from 'next/font/google'?

I've just had the similar problem with a new nextjs project initialised with npx create-next-app@latest. By default layout.tsx uses this new feature:

import { Inter } from &#39;next/font/google&#39;.<br>
const inter = Inter({ subsets: [&#39;latin&#39;] })

I commented it out and the error disappeared. I guess nextjs tries to access google servers to retrieve the fonts but fails.

huangapple
  • 本文由 发表于 2023年5月11日 13:08:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76224310.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定