pythondjangopostgresqltortorsocks

How to set up torsocks with postgresql


Hi When I try to run my Python program

The program runs well with torsocks

But when the program needs to connect to the database (postgresql) Gives an error and can not

How to configure the tor so that our program can find the database?

I use the postgresql

Photo of Error: 1

It does not matter if my program is a Django or I use a sqlalchemy Cannot find database at all

oem@khoramfar$: proxychains curl https://api.ipify.org/
    [proxychains] config file found: /etc/proxychains.conf
    [proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4
    [proxychains] DLL init: proxychains-ng 4.14
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  178.128.235.170:3128 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  51.68.198.158:80 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  68.183.192.29:8080 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  93.91.86.102:8080 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  41.237.65.105:80 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  115.124.115.26:80 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  41.59.254.172:80 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  1.20.103.196:42792 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  115.85.75.34:80 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  118.179.223.130:80 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  139.255.31.146:8080 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  51.222.73.117:80 <--denied
    [proxychains] Dynamic chain  ...  109.194.114.100:8081  ...  timeout
    [proxychains] Dynamic chain  ...  178.128.125.16:35577  ...  111.90.179.74:8080 <--denied
    [proxychains] Dynamic chain  ...  178.128.125.16:35577  ...  96.47.231.58:8020 <--denied
    [proxychains] Dynamic chain  ...  178.128.125.16:35577  ...  167.172.184.166:40607  ...  185.18.214.13:8080  ...  178.128.125.16:34534  ...  106.51.252.227:80 <--socket error or timeout!
    [proxychains] Dynamic chain  ...  178.128.125.16:35577  ...  167.172.184.166:40607  ...  185.18.214.13:8080  ...  178.128.125.16:34534  ...  59.14.228.31:80 <--socket error or timeout!
    [proxychains] Dynamic chain  ...  178.128.125.16:35577  ...  167.172.184.166:40607 <--denied
    [proxychains] Dynamic chain  ...  178.128.125.16:35577  ...  185.18.214.13:8080 <--socket error or timeout!
    [proxychains] Dynamic chain  ...  178.128.125.16:35577  ...  178.128.125.16:34534  ...  23.21.48.44:443 <--socket error or timeout!
    [proxychains] Dynamic chain  ...  178.128.125.16:35577  ...  178.128.125.16:34534  ...  23.21.140.41:443  ...  OK

185.220.100.251

when i use proxychains my ip changes but when i run the program stil get that error


Solution

  • You won't be able to connect to a local database from within the program if you run it through torsocks because this intercepts all socket calls to route them over Tor. Routing all connections through Tor like that means there is no more localhost (can't access 127.0.0.1) and the database connection will go over Tor.

    If you have some HTTP requests that need to be routed through Tor in the program and you can change the source, you'll need to proxy those requests over SOCKS through Tor so only the relevant HTTP traffic uses Tor and other connections (like database) continue to work as usual.