Warning: mysqli_connect(): (HY000/2002): No connection could be made because the target machine actively refused it - mysqli

I'm only trying to connect my website to a database using xampp, but this error keeps appearing.
$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
Warning: mysqli_connect(): (HY000/2002): No connection could be made
because the target machine actively refused it.
I tried alot of things but the problem still persists.
please help.

Are you trying to connect from local-machine? If is it, try to change value of DB_HOST to localhost or 127.0.0.1.

Related

How can I connect to server when trying to use postgresql?

I get this error message (see below) and do not know what to do about it.
Error message:
"psql: error: connection to server at "localhost" (::1), port 5432 failed: Connection refused (0x0000274D/10061) Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused (0x0000274D/10061) Is the server running on that host and accepting TCP/IP connections? "
I am using Windows 10 (64bit) and have tried the same thing on Kali and Ubuntu and still was not able to use postgresql.
Does anyone have a suggestion what do to? However, please use "language" that I can understand or at least look up simply because I am new to programming (in general). Thank you
P. S. I tried various different things such as using pgAdmin to change ports but cannot solve a problem. I do not know if this is important but I istalled postgresql via Binaries because regular Installer was giving an error message telling me that comspec does not point to cmd.exe even though it actually did...
If you
properly set up your db (installation and initialization using initdb), and if you
have your data directory containing your postgresql.conf and pg_hba.conf among other things, and you
properly started the postgresql service,
then I can assume your problem is in the connection string.
Try to include the superusername and/or db name, your error maybe due to psql connecting to user localhost which does not exist inside your db.
Try to run psql with -U and -d options:
psql -U postgres -d postgres

Unable to connect successfully to a local Postgres db using Vscode mssconnect extension

Whenever I try to add a connection profile using msconnect, I run into the issue shown below.
I've followed these instructions to no avail. It's worth noting that I have no issue querying the database with other IDEs like Pycharm or Datagrip.
For more information,
OS is macOS Monterey
it's a locally running Postgres container on port 5434 so I specify localhost,5434 as the server name when creating the connection
username & password were double-checked
mssql: Error 203: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - 17735680)

How to set up localhost server and database for PostgreSQL?

I am new to PostgreSQL, and I want to use it on my personal laptop for personal projects. I use SQL Server and SQL Server Management Studio at work, coding-wise I'm ok but I need some help with setting up the localhost on my laptop.
So I downloaded PostgreSQL and installed it along with pgAdmin that came with the package.
During installation, it asked me to create a PostgreSQL superuser password, which I did.
Then I tried creating a new server using pgAdmin as follows:
General Tab:
Name: localhost
Server Group: Servers
Connect Now?: check
Connection Tab:
Host name/address: localhost Port: 5432
Maintenance database: postgres
Username: postgres
Password: [blank]
But when I click save I'm getting an error message:
Unable to connect to server: could not connect to server: Connection
refused (0x0000274D/10061) Is the server running on host
"localhost"(::1) and accepting TCP/IP connections on port 5432? could
not connect to server: Connection refused (0x0000274D/10061) Is the
server running on host "localhost"(127.0.0.1) and accepting TCP/IP
connections on port 5432?
Also tried replacing the password field with the Superuser password, getting the same error message.
Would greatly appreciate it if anyone offers any insights into this problem, I might just be a noob when it comes to server setups...
Thanks,
Mike
Update:
I believe there's a service I need to start as suggested by #Scott Moniz. I went into services.msc, tried to start the service postgresql-x64-10 - PostgreSQL Servier 10, and I got this error message:
"The postgresql-x64-10 - PostgreSQL Server 10 service on Local
Computer started and then stopped. Some services stop automatically if
they are not in use by other services or programs".
I then tried editing the property of the service, by changing the Log on as option to Local System Account and tried starting the service again, still got the same error message.
I'm using Windows 10 Home edition, it this helps to resolve the issues in anyway
Thanks,
Mike
Are you sure the database service is running and listening?
CLick Start>Run> type services.msc
Look for a postgresql service - if it does not say started right click it and click Start.
Alternatively you can restart your computer and the service should start if it is set to 'Automatic'

can not connect to to Postgres in heroku through pgAdmin

I am trying to connect from my office network to the database that create in heroku (Postgres). I am using Pgadmin but the connection fail:
could not connect to server:Connection timed out is the server running on host "ec2-54-204-43-200.compute-1.amazonaws.com" and accepting TCP/IP connections on port 5432?
but when I connect from my home this error doesn't exist so I think is a network issue that I have to resolve but I dont know what to see, just I disable my firewall but even that is not working .
Someone can know what can i do ?
Ok, I got the solution. I talk with the Networking departmment and the problem was to able the ip and port where I needed to connect it in the firewall.

strange svn problem in eclipse

I have installed Subclipse inside my Eclipse. I can successfully connect to http://svn.python.org/projects/peps/trunk, but when I tried to connect to svn://svn/appwork.org/utils, I got an error saying:
No connection could be made because the target machine actively
refused it. svn: Can't connect to host 'svn': No connection could be
made because the target machine actively refused it.
Does anyone knows the answer to this question? Thanks a lot!
Edit
I actually overlooked the error in the svn address. Even if I tried with "svn://svn.appwork.org/utils", I still got another error:
A socket operation was attempted to an unreachable host.
svn: Can't connect to host 'svn.appwork.org': A socket operation was attempted to an unreachable host.
You need svn://svn.appwork.org/utils instead of svn://svn/appwork.org/utils. With a dot, not slash.