digitros / nextjs-fastapi

https://nextjs-fastapi-starter.vercel.app
MIT License
407 stars 117 forks source link

Error: connect ECONNREFUSED 127.0.0.1:8000 #10

Closed badrul1 closed 11 months ago

badrul1 commented 11 months ago

I've just followed the steps here: https://vercel.com/templates/next.js/nextjs-fastapi-starter

and am getting this error when I run npm run dev:

[1] Requirement already satisfied: anyio<5,>=3.4.0 in c:\python311\lib\site-packages (from starlette<0.28.0,>=0.27.0->fastapi==0.100.1->-r requirements.txt (line 1)) (4.0.0)
[0] }[0] - error Error: connect ECONNREFUSED 127.0.0.1:8000
[0]     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) {[0]   errno: -4078,
[0]   code: 'ECONNREFUSED',
[0]   syscall: 'connect',
[0]   address: '127.0.0.1',
[0]   port: 8000
[0] }
[0] - wait compiling /favicon.ico/route (client and server)...
[0] - event compiled successfully in 64 ms (96 modules)

I am using Windows, and Node.js v18.15

badrul1 commented 11 months ago

Ok I fixed it. It's a case of Linux/Apple devs not bothering to check if their tutorial works on Windows. In your package.json file change: "fastapi-dev": "pip3 install -r requirements.txt && python3 -m uvicorn api.index:app --reload", to

"fastapi-dev": "pip3 install -r requirements.txt && python -m uvicorn api.index:app --reload",

this should ensure uvicorn runs.