Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

210
Visualizações
Basic Next.js start ending in 404

I've been working for a week on Next.js and decided to try it outside of the dev setup. After some bug fixing I've managed to build it 'make it start' without errors but I ended up on : {"message":"Route GET:/ not found","error":"Not Found","statusCode":404} when opening http://localhost:3000.

So after few tests and some tries within a docker container I tried the simplest of setups which resulted in the same matter:

npx create-next-app test
cd test
npm run dev //works when opening localhost:3000 so ^C to stop
npm run build

which give :

> test@0.1.0 build
> next build

info  - Checking validity of types  
info  - Creating an optimized production build  
info  - Compiled successfully
info  - Collecting page data  
info  - Generating static pages (3/3)
info  - Finalizing page optimization  

Page                                       Size     First Load JS
┌ ○ /                                      6.25 kB        81.2 kB
├   └ css/149b18973e5508c7.css             655 B
├   /_app                                  0 B            74.9 kB
├ ○ /404                                   193 B          75.1 kB
└ λ /api/hello                             0 B            74.9 kB
+ First Load JS shared by all              74.9 kB
  ├ chunks/framework-1f10003e17636e37.js   45 kB
  ├ chunks/main-fc7d2f0e2098927e.js        28.7 kB
  ├ chunks/pages/_app-69da446bea935969.js  493 B
  ├ chunks/webpack-69bfa6990bb9e155.js     769 B
  └ css/27d177a30947857b.css               194 B

λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
○  (Static)  automatically rendered as static HTML (uses no initial props)

and finally:

npm run start

which give an encouraging :

> test@0.1.0 start
> next start

ready - started server on 0.0.0.0:3000, url: http://localhost:3000

But unfortunately opening http://localhost:3000 results in :

{"message":"Route GET:/ not found","error":"Not Found","statusCode":404}

Can someone tell me what am I missing ?

It seams like I cannot make it simpler but it is not even working..

Thanks all

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

(Self answer for those who could have the same issue)

Apparently there is a subtle difference between npx (executable) and scripts runned by npm.

Indeed, playing with different instructions I stumbled across this:

> npm run start

with package.json :

{
  ...
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start -p 8000",
    "lint": "next lint"
  },
  ...
}

is not the same as :

> npx next start -p 8000

Because npm will open a server on port 3000 (that does not work) and npx on port 8000 (that does work).

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda