Learn how ports work in Replit’s cloud environment, including port forwarding, configuration, and troubleshooting for your web applications.
0.0.0.0
part is the address, or host. If a process is listening on 0.0.0.0
, that means it should listen on every network interface — which means that if another computer (on the internet) sends a request to your computer’s IP address, it will see it. So, listening on 0.0.0.0 means those processes are accessible to the public internet (if your computer is connected.)
Most programming frameworks will not listen on 0.0.0.0
when you’re developing, because you don’t necessarily want your work exposed to the public while you’re working on it, for privacy & security. Instead, they’ll listen on a different address — 127.0.0.1
, otherwise known as localhost
. This means only that computer can make requests to that port.
:80
is bound to the internal port :3000
. That means any traffic that Replit App gets on port 80 will go to the internal port 3000.
This configuration is captured in the [[ports]] section of the .replit config file.
By default, we will bind the first port you open to the default external port 80, which will allow that process to be available at the domain without a port address (e.g. customdomain.com/ instead of customdomain.com:3000/). Additional internal ports that are opened will be bound to other available external ports (see a full list below.)
80
will show up in the domain path (e.g. customdomain.com:4200/). (We provide TLS by default, so it will technically be over port 443, which is the default port for https. For all intents and purposes, you can treat them as interchangeable.)
localhost
. If you expose more ports, or expose a single port on localhost, your deployment will fail. An easy way to make sure your Autoscale deployments work as expected is to remove all the externalPort
entries for the ports in your config except the port for the service you want to interact with from the internet.
exposeLocalhost
config option to true
for the port you want to expose.
If you want to always expose localhost ports by default, you can set your “automatic port forwarding” setting in the User Settings tool to “All ports”.
If you want to never create config for ports that are opened, and manually control the port config for all your Replit App, you can set that to “never”.
[[ports]]
.replit config{localPort, externalPort, exposeLocalhost}
The [[ports]]
config Allows you to configure which HTTP port to expose for your web output. By default, any exposed HTTP port with host 0.0.0.0 will be exposed as your Replit App’s web output.
Extra ports can be served without overriding the default port by adding a new [[ports]] entry to your .replit file. You are required to specify both a localPort and externalPort entry. You can add multiple extra ports by adding multiple [[ports]] entries to your .replit file as defined below.
localPort
config but just not add an externalPort
:
localhost
can be bound to an external port. Can be true
, false
, or null.