Why Your Local App Is on Port 8080 (and 7 Other Local Port Surprises)
You expected localhost . You got localhost:8080 , or a database on 15433, and the connection string in your notes no longer works. Local ports are quiet sources of confusion. Here are eight surprises. 80 is often taken. Another web server, a VPN client, a dev proxy. Flisk falls back to 8080 for HTTP and 8443 for HTTPS, and prints the URLs. 5432 is the usual Postgres collision. A database you…
When working with localhost, it is common to encounter unexpected port numbers. Eight surprising port assignments are discussed here. Port 80 is frequently used, often by web servers, VPN clients, or dev proxies. If it is taken, Flisk, a tool, defaults to port 8080 for HTTP and 8443 for HTTPS. The URLs are displayed by Flisk after it chooses these ports.
The database port 5432 is another frequently used number, especially for Postgres. Any database installed previously might still be active on this port. The port is included in the URL itself, so copying an old URL without specifying the port will lead to the wrong location. To ensure the correct port is used, one can set the environment variable FLISK_HTTP_PORT=80 before running flisk up.
If port 80 is occupied, Flisk will indicate this. You can specify the desired port directly in the URL. For easier identification, .localhost names can be used, such as api.my-project.localhost:8080. Performing a dry run with flisk up --dry-run will display the ports that would be used before any building takes place. The ports freed by flisk down are made available for new applications.
If an old Tilt instance is still running and using ports, flisk up --force can terminate it. It is advisable not to hard-code ports in configuration files. Instead, retrieve them from the output or the gateway name. To quickly check which process is using a specific port, use the command lsof -i :5432 on macOS and Linux. Depending on the outcome, you can choose to stop that process or switch to the fallback port.
Understanding and documenting port assignments can simplify debugging and ensure seamless operations.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to