# Tor can't bind 127.0.0.1 with 9050 port



## aterow (Jun 16, 2018)

Hi, 
When i run tor command i'll see this error:
https://beepaste.io/paste/view/01O54O
And this is my torrc file:
https://beepaste.io/paste/view/q0NVjS
What should i do? Thanks.


----------



## ShelLuser (Jun 16, 2018)

You should read the warnings and follow up on them. Something is already listening on 9050 and 9051, so start by making sure that Tor isn't already started.

sockstat can be a good starting point: `# sockstat -4l | less`, then check what is listening on those ports.


----------



## aterow (Jun 16, 2018)

ShelLuser said:


> You should read the warnings and follow up on them. Something is already listening on 9050 and 9051, so start by making sure that Tor isn't already started.
> 
> sockstat can be a good starting point: `# sockstat -4l | less`, then check what is listening on those ports.


Thanks for your reply, Yes i tried that command and i just saw tor is running at port 9050 and 9051! I killed them and restart tor but i got that error again... Actually tor will listen this port!


----------



## Deleted member 54719 (Jun 17, 2018)

`sudo lsof -i` is a wonderful mechanism to see what processes are already listening on ports.


----------



## Deleted member 54719 (Jun 17, 2018)

aterow said:


> Thanks for your reply, Yes i tried that command and i just saw tor is running at port 9050 and 9051! I killed them and restart tor but i got that error again... Actually tor will listen this port!



I didn't read your error log, but the above would indicate that tor is already running and you are trying to start a second instance of it.  Something else has already started tor: inetd?  rc.d/whatever?


----------



## aterow (Jun 17, 2018)

```
# lsof -i | grep tor
lsof: WARNING: compiled for FreeBSD release 11.1-RELEASE-p10; this is 11.1-RELEASE.
tor       1577   _tor    5u  IPv4 0xfffff80106151820      0t0     TCP localhost:9050 (LISTEN)
obfs4prox 1578   _tor    4u  IPv4 0xfffff80075de2410      0t0     TCP localhost:50256 (LISTEN)
```
If i kill this processes and run this command: service tor restart , and run tor command i will get this:

```
# tor
Jun 17 08:42:56.877 [notice] Tor 0.3.2.10 (git-31cc63deb69db819) running on FreeBSD with Libevent 2.1.8-stable, OpenSSL 1.0.2k-freebsd, Zlib 1.2.11, Liblzma 5.2.3, and Libzstd 1.3.3.
Jun 17 08:42:56.877 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Jun 17 08:42:56.878 [notice] Read configuration file "/usr/local/etc/tor/torrc".
Jun 17 08:42:56.886 [notice] Scheduler type KISTLite has been enabled.
Jun 17 08:42:56.886 [notice] Opening Socks listener on 127.0.0.1:9050
Jun 17 08:42:56.886 [warn] Could not bind to 127.0.0.1:9050: Address already in use. Is Tor already running?
Jun 17 08:42:56.886 [warn] Failed to parse/validate config: Failed to bind one of the listener ports.
Jun 17 08:42:56.886 [err] Reading config failed--see warnings above.
```
I think my torrc file is wrong...


----------



## ShelLuser (Jun 17, 2018)

So how did you kill those processes? And did you check that they were really killed after that? Those processes could be stalled or something, after which a mere kill might not do anything.

As a side comment: although lsof works it's usually better to use sockstat, for the simple reason that sockstat is a native FreeBSD command which is always available. Not a problem on a running server, but it can become a problem if you're using a rescue environment to try and resolve a few issues.


----------



## bds (Jun 18, 2018)

"service tor restart" causes Tor to run in the background. "tor" causes Tor to run the in foreground at same time as the one in the background. They both want to listen on the same port, and you get an error that tells you this. I'm not sure what your expectations are or indeed what you want to do - run Tor in the background (as a daemon) and leave it? Run Tor in the foreground? Or run two Tor nodes on the same machine?


----------



## Deleted member 55181 (Jun 19, 2018)

Did You have installed Vidalia (tors gui)?

whatever:

`rm -R /usr/local/etc/tor/torrc`
`ee /usr/local/etc/tor/torrc`

paste in file:

```
SOCKSPort 127.0.0.1:10001
```

paste in /etc/rc.conf


```
tor_enable="YES"
```

then in #

`service tor start`

If you want to new id type in $service tor reload or #service tor restart or #service tor reload.

Then you have a SOCKS5 on 127.0.0.1:10001 for add it to browser.

PS. For future use forums edition tool.


----------

