OperationalError, connecting to another Django/DB project - django

I'm trying to connect to another database (project-B) that also uses Django. I would like to ask for help on how to resolve the following error?
Here's the error from Django debug:
could not connect to server: Connection refused Is the server running
on host "111.222.333.444" and accepting TCP/IP connections on port
5432?
Here's the firewall from project-B
Status: active Logging: on (low) Default: deny (incoming), allow
(outgoing), disabled (routed) New profiles: skip
To Action From 5432
ALLOW IN 111.222.333.444
I also put it in the allowed host
ALLOWED_HOSTS = [ '111.222.333.444']
Other than that, I have not modified anything from project-B.

The firewall allows requests from 111.222.333.444, which is effectively blocking all hosts other than same host connection.

Related

GCP ProxySQL and BasicDataSource connection pool

I have an issue with a java BasicDataSource connection pool.
My ProxySql is correctly configured on all my DataProc Compute engine, if I try to connect to my CloudSql instance with sqlclient it works correctly.
When I try to connect to my CloudSql from my connection pool, configured with this connection string: pooljdbc:mysql://127.0.0.1/my_db?serverTimezone=UTC, I get this error:
Cannot create PoolableConnectionFactory (Access denied for user 'myuser'#'localhost' (using password: YES))
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'myuser'#'localhost' (using password: YES))
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
And is correct because the proxySQL tcp connection is on 127.0.0.1 and not on localhost (unix socket).
I don't understand why the BasicDataSource try to connect on localhost and not on 127.0.0.1 as I have configured in the connection string.
Any help is really appreciated.
The string 'myuser'#'localhost' is referring to your login identity, not the server connection string; if you ran your connection attempt from a machine called foo-instance, for example, even if you use a connection string specifying a remote IP address, your login would be 'myuser'#'foo-instance'. While direct connections using your sqlclient will resolve the source hostname differently based on the server hostname specified, this is a quirk that shouldn't be relied on. In particular, in your case the ProxySQL service will be acting on your behalf, so the source hostname will come from the ProxySQL instance, not from your connection string.
You may want to share more details on your ProxySQL configuration, but if you're using defaults, your PROXYSQL_HOSTNAME would be set to localhost; you could try ensuring your PROXYSQL_HOSTNAME is set to 127.0.0.1 instead.
Interestingly, based on cursory testing, it appears creating user grants identified by 127.0.0.1 is more restrictive to login host, while creating the grant for localhost allows both 127.0.0.1 and localhost for connection hostnames:
MariaDB [(none)]> create user 'dhuo'#'127.0.0.1' identified by 'dhuopass';
...
$ mysql -h localhost -pdhuopass
ERROR 1045 (28000): Access denied for user 'dhuo'#'localhost' (using password: YES)
$ mysql -h 127.0.0.1 -pdhuopass
Welcome to the MariaDB monitor. Commands end with ; or \g.
...
MariaDB [(none)]> drop user dhuo#127.0.0.1
MariaDB [(none)]> create user 'dhuo'#'localhost' identified by 'dhuopass';
...
$ mysql -h localhost -pdhuopass
Welcome to the MariaDB monitor. Commands end with ; or \g.
$ mysql -h 127.0.0.1 -pdhuopass
Welcome to the MariaDB monitor. Commands end with ; or \g.
Generally it'd probably work best to configure your user grants to be identified as coming from localhost instead of 127.0.0.1 to have the best chance of supporting either inbound hostname.

Connecting to a Akamai website - actually not connecting

I'm trying to connect to a domain that seems to have Akamai tech.
I can't connect and nor does curl - but the browser does.
So I assume the IP address is not blocked.
Reading up - it seems that Akamai runs some algorithms and doesn't allow connections sometimes.
But since a web browser works (from same pc) - I assume it can be made to work.
Any tip?
Your question is quite wage. Akami WAF will not allow curl unless you have white-listed your IP address. Browser connect is just TCP connection on port 80, 443. Which http method did you try to access and is that method allowed? By default i believe only GET and POST are allowed.

socket io not working with https ;switching back to polling

I have Node.JS app running in Elastic Bean Stalk. I have Elastic Load Balancer set up and SSL is set up in that.
I did socket.io in my Node.JS. I had trouble accessing it because of Nginx configurations. I fixed them by using .ebextensions .
Now when i access my socket io using my HTTP URL , it works good and it uses WebSocket protocol itself. But When i use HTTPS, it switches back to polling. How can i fix this?
Is it some configuration I have to do to make it work in HTTPS?
Update : After adding {transports: ['websocket'], upgrade: false} ,its sending only websokcet requests. But still I get error as
WebSocket connection to 'wss://myurl.ca/socket.io/?EIO=3&transport=websocket' failed: WebSocket is closed before the connection is established.
The problem was with certificates.HTTPS certificates were set up for www.myurl.ca .And websocket calls were without www . It was just wss://myurl.ca.
It was a minor mistake.But changing the certificate to myurl.ca solved the issue.

Trying to set up a data source in ColdFusion

I'm trying to create a data source for my local sql server using the server name (local). But I keep getting the following error
Connection verification failed for data source: sqlserver
java.sql.SQLNonTransientConnectionException: [Macromedia][SQLServer JDBC Driver]Error establishing socket. Unknown host: (local)
The root cause was that: java.sql.SQLNonTransientConnectionException: [Macromedia][SQLServer JDBC Driver]Error establishing socket. Unknown host: (local)
On the reporting services I'm using (local) as the server name and it is working fine,
Ted
Have you enabled external TCP connections on your sql server?
Try using localhost instead of local. (or add 127.0.0.1 local to your hosts file)
You can't use (local) this is a Microsoft ONLY term and won't be understood by anything external.
You need to specify the servername as the name of the server.
If the SQL Server is the same server as ColdFusion you can then use localhost
If not use the DNS or local IP name of the sever, ie sql.local or 192.168.1.22
If the server is external to your You will need TCP/IP configured and port 1433 open also. But by default this should be setup, you may just need to open your firewall to allow access through port 1433.
In a network environment, you would normally use local IP to get LAN access to your DB, but if database is really external you need a real IP / domain

WebService timeout

I have a problem with deploying my web service in our Web server. In my
development machine (inside of our LAN), everything works fine. When I move
the application into our Web server (public addressed), I always get the
timeout exception. while i connecting the web service through my web browser it works fine with no issues, but through application am getting the timeout error. My app connects to our database server (inside of our LAN) to get statistical data in form of datasets. can i know the issue about this point.
That is most likely a firewall/port forwarding issue.
Did I understand you correctly: Your client application connects to the database server directly?
You should check which port you are using to connect to the database server.
Then check if the web server has an active firewall and if so, configure it properly to accept connections on that port.
You can always easily check if a port is open and reachable by using telnet:
On the command line type telnet MY_IP MY_PORT.
If a connection can be established the port is open.