Skip to content
>_VibeUnstuck

We couldn't find a web server

Last verified:

The fix

We couldn't find a web server. Replit only forwards a process listening on 0.0.0.0 and the localPort in .replit. localhost and 127.0.0.1 stay inside the sandbox, including on a published app.

  1. 1

    Listen on 0.0.0.0 and the port in .replit

    Bind every interface, on the localPort from .replit. If the template sets PORT to that same number, read PORT. A fallback is only for a laptop, and it has to be the same number the file names. The shell line listening on 127.0.0.1 means Preview and publish still cannot see it.

    const port = Number(process.env.PORT) || 3000;
    app.listen(port, "0.0.0.0");
  2. 2

    Point external port 80 at that same localPort

    Open .replit and keep one web port. localPort is what the process binds. externalPort = 80 is the public side, so the URL has no :3000. Publishing with a [[ports]] table does not autodetect. It needs that externalPort = 80, and the server has to be on localPort. Extra externalPort lines break Autoscale, which allows one. Do not set exposeLocalhost instead of changing the bind. Loopback still fails the published app.

    [[ports]]
    localPort = 3000
    externalPort = 80
  3. 3

    Pass the port to Next.js, and drop a localhost hostname

    Next.js 16 reads PORT. With no --hostname flag it listens on every interface, and the log still prints http://localhost:PORT. That printed host is not a loopback bind. Replace a script that passes --hostname localhost or -H localhost with the command below, and point --port at the localPort in .replit. next start takes the same two flags.

    next dev --hostname 0.0.0.0 --port ${PORT:-3000}
  4. 4

    Run the process that stays up

    Replit runs the configured command, not whichever shell you typed in. A build, a test, or a script that prints and exits leaves Preview on We couldn't find a web server. The published app has to keep running too. One process owns the port. A second server on another port is the address-already-in-use page, and it is not automatically the webview.

Why it happens

Preview stays blank, or publish fails the port check, when nothing Replit can route to is listening. The ports guide says a process is reachable from the webview only after an internal port is bound to an external one. A listen on 0.0.0.0 is eligible for that binding. A listen on 127.0.0.1 or localhost is not forwarded by default, because Replit treats loopback as private. exposeLocalhost can force a loopback port into Preview. The publishing guide still says a server that listens only on localhost or 127.0.0.1 does not work for a published app. Autoscale and Reserved VM deployments expose a single external port, and that internal port must not be localhost.

The other miss is the number. .replit maps localPort to externalPort. Traffic that arrives on external port 80 is delivered to that localPort. An app listening on 8080 while the file says 3000 looks like no server at all. Once a [[ports]] table exists, automatic detection is off, and publishing wants one entry with externalPort = 80 whose localPort is the port the process actually bound. Templates often copy that number into PORT. Read it. Do not pick a port because it happened to be free.

The next error you'll probably hit

Once this is fixed, the usual follow-up is listen EADDRINUSE: address already in use. listen EADDRINUSE: address already in use on Replit: two processes took one port. Stop the extra dev server. Listen once on PORT so the webview can see it.

Prompt to paste back into your AI tool

Paste this above the error.

Replit Preview shows: We couldn't find a web server.
If the older line is the one on screen, it says: We couldn't reach this Repl. Make sure this Repl has a port open and is ready to receive HTTP traffic.

The listen line in the log is:
<paste it, including the host and port, or "none">

The [[ports]] block in .replit is:
<paste it, or "none">

Do not tell me to open a random port in the browser. Do not set exposeLocalhost and leave the server on 127.0.0.1. Do not add a second externalPort.

1. Listen on 0.0.0.0 and the localPort from .replit. If PORT is set, it has to be that same number.
2. Set one [[ports]] entry: that localPort, externalPort = 80. Remove extra externalPort lines if this is an Autoscale publish.
3. If this is Next.js, set dev and start to next dev --hostname 0.0.0.0 --port $PORT (and the same hostname for next start).
4. Point the run command at that server. Do not rewrite the app.

Common questions

+The shell says the server is ready and Preview still says We couldn't find a web server. Why?

Ready on 127.0.0.1, or on a port other than the localPort in .replit, never reaches the webview. Bind 0.0.0.0 and that localPort. Publishing rejects a localhost bind even if you set exposeLocalhost for Preview.

+Can I hardcode port 3000 because the template used 3000?

Only when localPort in .replit is 3000. If PORT is set, listen on PORT. A hardcoded port that disagrees with the file is the usual reason the webview stays empty after a template change.

+Preview works and publish says the port is wrong. Why?

Preview can autodetect a 0.0.0.0 listen. Once .replit has a [[ports]] table, publish does not. One entry needs externalPort = 80, the process has to listen on that localPort, and the address has to be 0.0.0.0. Autoscale allows that single external port.

+The log says listen EADDRINUSE. Is that this error?

No. EADDRINUSE means something already holds the port, so this process never became the server Preview is looking for. Free that port and listen once. That is the next page.

Related errors