This guide is for the Port — not open or already in use error
Seen this annoying error lately — causing your node to fail?
"listen tcp 127.0.0.1:6060: bind: address already in use" server=node
Then here is how to resolve it
What are Ports
A port is a communication endpoint, they enable communication between different services on a server.
Imagine your VPS as a bustling city with numerous buildings and establishments. Each building represents a specific application or service running on your server, such as a website, email server, or database. Now, think of the ports as the entrances to these buildings. To ensure the smooth functioning and security of the city, you need to have a well-regulated system for managing these entrances. — ( to learn more about ports
https://www.liquidweb.com/blog/mastering-vps-port-management/)
So that error is usually caused by the fact that some other service (maybe some other node) is using the port you specified
The first 1024 ports (port numbers
0
to1023
) are referred to as well-known port numbers and are reserved for the most commonly used services. These include SSH (port22
), HTTP (port80
), HTTPS (port443
).Port numbers above 1024 are referred to as ephemeral ports.
Port numbers
1024
to49151
are called the registered/user ports.Port numbers
49152
to65535
are called the dynamic/private portshttps://www.digitalocean.com/community/tutorials/opening-a-port-on-linux#
The good news is you can simply, change the service to a different port (preferably ephemeral ports) and that solves the error
How to Solve it
Identify the port in the error, in this case 26657
#same procedure for any port number including
Option 1 — Identify the procedure using that port and kill it.
- Check the port
lsof -i :<port_number>
The output will display the process details along with the PID.
2. Using the PID kill the procudure (
kill <PID>
sudo kill <PID> #if you are not root
#in this case
kill 26657
And thats all, now its free for use
ps: take a look at the process before killing it, to ensure its not a system process — if you aren’t sure you should kill it, go to option 2
Option 2
This option is for cases where the port is already in use, and you need an alternative port, especially when running multiple nodes on a single VPS.
- Search for a new port not in use
You can pick a port from 1024–65535, personally, i prefer picking a number close to the port in use
netstat -na | grep :26660
# if there is no output (blank output) then the port is not in use, if there is pick another
No output so we can proceed
2. open the port
sudo ufw allow 26660
3. Update your config.toml or app.toml where the port is listed
Popular Ports and docs to make changes to
For this i picked one of the more popular guides on the discord Thanks to #Nodebrand for putting it together
Step 4 Variable setting — RPC_PORT
can be changed in $HOME/.0gchain/config/config.toml
can be changed in $HOME/.0gchain/config/app.toml
Step 8 Config setting — Any of the ports here
can be changed in $HOME/.0gchain/config/config.toml and
$HOME/.0gchain/config/app.toml
Port 8545 — EVM RPC HTTP and Websocket HTTP address
Can be changed in $HOME/.0gchain/config/app.toml
Thats all for Now
I intend to keep documenting errors i run into
Let me know if you found this helpful