Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled exception. Npgsql.NpgsqlException (0x80004005): Failed to connect to 127.0.0.1:39383 #406

Open
FAlejandroValencia opened this issue Feb 13, 2023 · 12 comments

Comments

@FAlejandroValencia
Copy link

I am getting this error when running the project, can someone help me with this?

info: Configuration: Data Directory: C:\Users\Alejandro Valencia\AppData\Roaming\NBXplorer\Main
info: Configuration: Configuration File: C:\Users\Alejandro Valencia\AppData\Roaming\NBXplorer\Main\settings.config
info: Configuration: Network: Mainnet
info: Configuration: Supported chains: BTC
info: Configuration: DBCache: 50 MB
info: Configuration: Network: Mainnet
info: Configuration: Supported chains: BTC
info: Configuration: DBCache: 50 MB
info: NBXplorer.DatabaseSetup: Postgres services activated
Unhandled exception. Npgsql.NpgsqlException (0x80004005): Failed to connect to 127.0.0.1:39383
---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Net.Sockets.Socket.g__WaitForConnectWithCancellation|277_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
at Npgsql.TaskExtensions.ExecuteWithTimeout(Func2 func, NpgsqlTimeout timeout, CancellationToken cancellationToken) at Npgsql.Internal.NpgsqlConnector.ConnectAsync(NpgsqlTimeout timeout, CancellationToken cancellationToken) at Npgsql.Internal.NpgsqlConnector.ConnectAsync(NpgsqlTimeout timeout, CancellationToken cancellationToken) at Npgsql.Internal.NpgsqlConnector.RawOpen(SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken, Boolean isFirstAttempt) at Npgsql.Internal.NpgsqlConnector.<Open>g__OpenCore|195_1(NpgsqlConnector conn, SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken, Boolean isFirstAttempt) at Npgsql.Internal.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken) at Npgsql.ConnectorPool.OpenNewConnector(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken) at Npgsql.ConnectorPool.<Get>g__RentAsync|28_0(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken) at Npgsql.NpgsqlConnection.<Open>g__OpenAsync|45_0(Boolean async, CancellationToken cancellationToken) at NBXplorer.Backends.Postgres.DbConnectionFactory.CreateConnection(Action1 action) in C:\Users\Alejandro Valencia\Desktop\BTCPay\NBXplorer\NBXplorer\Backends\Postgres\DbConnectionFactory.cs:line 54
at NBXplorer.HostedServices.DatabaseSetupHostedService.StartAsync(CancellationToken cancellationToken) in C:\Users\Alejandro Valencia\Desktop\BTCPay\NBXplorer\NBXplorer\HostedServices\DatabaseSetupHostedService.cs:line 33
at Microsoft.AspNetCore.Hosting.HostedServiceExecutor.ExecuteAsync(Func`2 callback, Boolean throwOnFirstFailure)
at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
at NBXplorer.Program.Main(String[] args) in C:\Users\Alejandro Valencia\Desktop\BTCPay\NBXplorer\NBXplorer\Program.cs:line 60
PS C:\Users\Alejandro Valencia\Desktop\BTCPay\NBXplorer>

@mjlamb
Copy link

mjlamb commented Feb 13, 2023

Do you have your postgres instance running at port 39383 ?

@FAlejandroValencia
Copy link
Author

no, it is running on its default port (5432)

@FAlejandroValencia
Copy link
Author

Do you have your postgres instance running at port 39383 ?

no, it is running on its default port (5432)

@mjlamb
Copy link

mjlamb commented Feb 13, 2023

Yeah so update your configuration file, as you have it pointing to 39383 according to the error message.

@FAlejandroValencia
Copy link
Author

Yeah so update your configuration file, as you have it pointing to 39383 according to the error message.

ok, thanks for your help, i changed the port of postgres and now i am getting this error, how can i pass the password? i am using this command to execute it "dotnet run --project NBXplorer"

info: Configuration: Data Directory: C:\Users\Alejandro Valencia\AppData\Roaming\NBXplorer\Main
info: Configuration: Configuration File: C:\Users\Alejandro Valencia\AppData\Roaming\NBXplorer\Main\settings.config
info: Configuration: Network: Mainnet
info: Configuration: Supported chains: BTC
info: Configuration: DBCache: 50 MB
info: Configuration: Network: Mainnet
info: Configuration: Supported chains: BTC
info: Configuration: DBCache: 50 MB
info: NBXplorer.DatabaseSetup: Postgres services activated
Unhandled exception. Npgsql.NpgsqlException (0x80004005): No password has been provided but the backend requires one (in SASL/SCRAM-SHA-256)
at Npgsql.Internal.NpgsqlConnector.AuthenticateSASL(List1 mechanisms, String username, Boolean async, CancellationToken cancellationToken) at Npgsql.Internal.NpgsqlConnector.Authenticate(String username, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken) at Npgsql.Internal.NpgsqlConnector.<Open>g__OpenCore|195_1(NpgsqlConnector conn, SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken, Boolean isFirstAttempt) at Npgsql.Internal.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken) at Npgsql.ConnectorPool.OpenNewConnector(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken) at Npgsql.ConnectorPool.<Get>g__RentAsync|28_0(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken) at Npgsql.NpgsqlConnection.<Open>g__OpenAsync|45_0(Boolean async, CancellationToken cancellationToken) at NBXplorer.Backends.Postgres.DbConnectionFactory.CreateConnection(Action1 action) in C:\Users\Alejandro Valencia\Desktop\BTCPay\NBXplorer\NBXplorer\Backends\Postgres\DbConnectionFactory.cs:line 54
at NBXplorer.HostedServices.DatabaseSetupHostedService.StartAsync(CancellationToken cancellationToken) in C:\Users\Alejandro Valencia\Desktop\BTCPay\NBXplorer\NBXplorer\HostedServices\DatabaseSetupHostedService.cs:line 33
at Microsoft.AspNetCore.Hosting.HostedServiceExecutor.ExecuteAsync(Func`2 callback, Boolean throwOnFirstFailure)
at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
at NBXplorer.Program.Main(String[] args) in C:\Users\Alejandro Valencia\Desktop\BTCPay\NBXplorer\NBXplorer\Program.cs:line 60

@mjlamb
Copy link

mjlamb commented Feb 14, 2023

The configuration file should have the username and password added. In this format...
postgres="User ID=postgres;Password=????;Host=127.0.0.1;Port=5432;Database=nbxplorer"

@FAlejandroValencia
Copy link
Author

The configuration file should have the username and password added. In this format... postgres="User ID=postgres;Password=????;Host=127.0.0.1;Port=5432;Database=nbxplorer"

do you mean the config file on this url "C:\UsersAlejandro Valencia\AppData\Roaming\NBXplorer\Main\settings.config"?

because in that file I don't see the postgres configuration data, I only see this

####Common Commands####
####If Bitcoin Core is running with default settings, you should not need to modify this file####
####All those options can be passed by through command like arguments (ie -port=19382)####

This is the RPC Connection to your node

#agm.rpc.url=http://127.0.0.1:9899/
#By user name and password
#agm.rpc.user=bitcoinuser
#agm.rpc.password=bitcoinpassword
#By cookie file
#agm.rpc.cookiefile=yourbitcoinfolder/.cookie
#By raw authentication string
#agm.rpc.auth=walletuser:password

This is the connection to your node through P2P

#agm.node.endpoint=127.0.0.1:AGM

minutxovalue defines the minimum value allowed for a utxo to be tracked

#agm.minutxovalue=1

startheight defines from which block you will start scanning, if -1 is set, it will use current blockchain height

#agm.startheight=-1

rescan forces a rescan from startheight

#agm.rescan=0

rescaniftimebefore only lets rescan occur if current unix timestamp (seconds) is less than the given value

requires agm.rescan to be true

#agm.rescaniftimebefore=1635210000

This is the RPC Connection to your node

#btc.rpc.url=http://127.0.0.1:8332/
#By user name and password
#btc.rpc.user=bitcoinuser
#btc.rpc.password=bitcoinpassword
#By cookie file
#btc.rpc.cookiefile=yourbitcoinfolder/.cookie
#By raw authentication string
#btc.rpc.auth=walletuser:password

@FAlejandroValencia
Copy link
Author

The configuration file should have the username and password added. In this format... postgres="User ID=postgres;Password=????;Host=127.0.0.1;Port=5432;Database=nbxplorer"

I was able to run it with this command "dotnet run --no-launch-profile --no-build -c Release --project .\NBXplorer\NBXplorer.csproj --postgres="host=127.0.0.1;password=postgres;port=5432;database=nbxplorer;User Id=postgres"", sending the postgres data in the command, but now I am getting this error with the RPC, any ideas?

info: Configuration: Configuration File: C:\Users\Alejandro Valencia\AppData\Roaming\NBXplorer\Main\settings.config
info: Configuration: Network: Mainnet
info: Configuration: Supported chains: BTC
info: Configuration: DBCache: 50 MB
info: Configuration: Network: Mainnet
info: Configuration: Supported chains: BTC
info: Configuration: DBCache: 50 MB
info: NBXplorer.DatabaseSetup: Postgres services activated
info: NBXplorer.Indexer.BTC: TCP Connection succeed, handshaking...
info: NBXplorer.Indexer.BTC: Handshaked
info: NBXplorer.Indexer.BTC: Testing RPC connection to http://localhost:8332/
Hosting environment: Production
Content root path: C:\Users\Alejandro Valencia\Desktop\BTCPay\NBXplorer\NBXplorer\bin\Release\net6.0
Now listening on: http://127.0.0.1:24444
Application started. Press Ctrl+C to shut down.
fail: NBXplorer.Indexer.BTC: Error connecting to RPC server No connection could be made because the target machine actively refused it. (localhost:8332)
fail: NBXplorer.Indexer.BTC: Unhandled exception in the indexer, retrying in 0 seconds
NBXplorer.Configuration.ConfigException
at NBXplorer.Configuration.RPCArgs.TestRPCAsync(NBXplorerNetwork networkInfo, RPCClient rpcClient, CancellationToken cancellation, ILogger logger) in C:\Users\Alejandro Valencia\Desktop\BTCPay\NBXplorer\NBXplorer\Configuration\RPCArgs.cs:line 137
at NBXplorer.Backends.Postgres.PostgresIndexers.PostgresIndexer.ConnectNode(CancellationToken token, Boolean forceRestart) in C:\Users\Alejandro Valencia\Desktop\BTCPay\NBXplorer\NBXplorer\Backends\Postgres\PostgresIndexers.cs:line 221
at NBXplorer.Backends.Postgres.PostgresIndexers.PostgresIndexer.IndexerLoopCore(CancellationToken token) in C:\Users\Alejandro Valencia\Desktop\BTCPay\NBXplorer\NBXplorer\Backends\Postgres\PostgresIndexers.cs:line 77
at NBXplorer.Backends.Postgres.PostgresIndexers.PostgresIndexer.IndexerLoop() in C:\Users\Alejandro Valencia\Desktop\BTCPay\NBXplorer\NBXplorer\Backends\Postgres\PostgresIndexers.cs:line 56
info: NBXplorer.Indexer.BTC: TCP Connection succeed, handshaking...
info: NBXplorer.Indexer.BTC: Handshaked
info: NBXplorer.Indexer.BTC: Testing RPC connection to http://localhost:8332/
fail: NBXplorer.Indexer.BTC: Error connecting to RPC server No connection could be made because the target machine actively refused it. (localhost:8332)
fail: NBXplorer.Indexer.BTC: Unhandled exception in the indexer, retrying in 5 seconds
NBXplorer.Configuration.ConfigException
at NBXplorer.Configuration.RPCArgs.TestRPCAsync(NBXplorerNetwork networkInfo, RPCClient rpcClient, CancellationToken cancellation, ILogger logger) in C:\Users\Alejandro Valencia\Desktop\BTCPay\NBXplorer\NBXplorer\Configuration\RPCArgs.cs:line 137
at NBXplorer.Backends.Postgres.PostgresIndexers.PostgresIndexer.ConnectNode(CancellationToken token, Boolean forceRestart) in C:\Users\Alejandro Valencia\Desktop\BTCPay\NBXplorer\NBXplorer\Backends\Postgres\PostgresIndexers.cs:line 221
at NBXplorer.Backends.Postgres.PostgresIndexers.PostgresIndexer.IndexerLoopCore(CancellationToken token) in C:\Users\Alejandro Valencia\Desktop\BTCPay\NBXplorer\NBXplorer\Backends\Postgres\PostgresIndexers.cs:line 77
at NBXplorer.Backends.Postgres.PostgresIndexers.PostgresIndexer.IndexerLoop() in C:\Users\Alejandro Valencia\Desktop\BTCPay\NBXplorer\NBXplorer\Backends\Postgres\PostgresIndexers.cs:line 56
info: NBXplorer.Indexer.BTC: TCP Connection succeed, handshaking...
info: NBXplorer.Indexer.BTC: Handshaked

@mjlamb
Copy link

mjlamb commented Feb 14, 2023

Yep so you need to be able to connect to your bitcoin node now via rpc. Have you got a bitcoin node running locally ?

@mjlamb
Copy link

mjlamb commented Feb 14, 2023

The postgres command is ok as you have it in the command line also, either command line or config file works.

@mjlamb
Copy link

mjlamb commented Feb 14, 2023

So my settings.config file has the following config values for the bitcoin node rpc.

btc.rpc.url=http://127.0.0.1:8332/
btc.rpc.user=xxx
btc.rpc.password=xxx

@FAlejandroValencia
Copy link
Author

So my settings.config file has the following config values for the bitcoin node rpc.

btc.rpc.url=http://127.0.0.1:8332/ btc.rpc.user=xxx btc.rpc.password=xxx

hey, sorry for the delay, I was really busy, this is what my settings file looks like, how can I pass the bitcoin node settings through a command?

####Common Commands####
####If Bitcoin Core is running with default settings, you should not need to modify this file####
####All those options can be passed by through command like arguments (ie -port=19382)####

This is the RPC Connection to your node

#agm.rpc.url=http://127.0.0.1:9899/
#By user name and password
#agm.rpc.user=bitcoinuser
#agm.rpc.password=bitcoinpassword
#By cookie file
#agm.rpc.cookiefile=yourbitcoinfolder/.cookie
#By raw authentication string
#agm.rpc.auth=walletuser:password

This is the connection to your node through P2P

#agm.node.endpoint=127.0.0.1:AGM

minutxovalue defines the minimum value allowed for a utxo to be tracked

#agm.minutxovalue=1

startheight defines from which block you will start scanning, if -1 is set, it will use current blockchain height

#agm.startheight=-1

rescan forces a rescan from startheight

#agm.rescan=0

rescaniftimebefore only lets rescan occur if current unix timestamp (seconds) is less than the given value

requires agm.rescan to be true

#agm.rescaniftimebefore=1635210000

This is the RPC Connection to your node

#btc.rpc.url=http://127.0.0.1:8332/
#By user name and password
#btc.rpc.user=bitcoinuser
#btc.rpc.password=bitcoinpassword
#By cookie file
#btc.rpc.cookiefile=yourbitcoinfolder/.cookie
#By raw authentication string
#btc.rpc.auth=walletuser:password

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants