Laravel: connecting the AWS ElasticCache Redis is timing out - laravel

I am working on a Laravel application. I using Redis and I am using AWS ElasticCache service for that. I am trying to connect to the Redis from my Laravel application. But it is timing out. This is what I have done.
I installed the Predis library by running the following command.
composer require predis/predis
Then I created a Redis instance in the ElastiCache service console enabling AUTH setting my password token.
Then I set the variables in the .env files.
CACHE_DRIVER=redis
REDIS_CLIENT=predis
REDIS_HOST=master.laravelredistest.8sm3xo.euw1.cache.amazonaws.com
REDIS_PASSWORD=mypassword
REDIS_PORT=6379
When I run the code to connect to the Redis, I got the following error.
Operation timed out [tcp://master.laravelredistest.8sm3xo.euw1.cache.amazonaws.com:6379]
What is missing with my configuration and how can I fix it?
I also updated the security group of Redis to allow the EC2 instance's security group in the inbound rules as follows:
I am getting this error this time:
I edited the SG of Redis to add the following inbound rule too.
The security groups are in the same VPC too as you can see in the screenshot:

This sounds like a security group issue causing the timeout.
Elasticache clusters are always private so if you're using a public ip address, this will need to be updated to be the private ip address range of your instance/subnet/VPC.
An Elasticache cluster is a resource in your VPC, therefore network transit needs to be allowed for the cluster to be accessible.
More information is available in the Accessing Your Cluster page.
Additional Configuration
This is the issue. I also needed to delete the existing Redis instance and create another one without AUTH token enabled.

Related

Connecting to Aurora AWS Serverless

I’ve now tried to create a serverless Aurora (MySQL compatible) database and connect to it for two days, and I just can’t seem to get it to work. Supposedly I should have been able to get it up and running in five minutes.
In any case, I created am Aurora Serverless database in the US East (N. Virginia) region (us-east-1), and have been able to connect to it with the AWS Query Editor. I also have an EC2 server in the same region, and have given the Aurora database the same security group (under RDS > Security Group), and in the security group I have opened for MYSQL/Aurora (TCP, 3306) from all sources. When I click the modify button on the database, there is also another (VPC) Security Group listed (rds-launch-wizard-4), which was created automatically. This one I also located under my EC2 dashboard and gave access to all ports from all sources (inbound), and to all ports (outbound). And there is a networking VPC & subnet group, which I don’t know what to do with, if anything.
I try to connect to the database, using this command line command:
mysql -h hest2.cluster-xxxxx.us-east-1.rds.amazonaws.com -P 3306 -u root –p
It generates an error “ERROR 2003 (HY000): Can't connect to MySQL server on” on both my EC2 instance, my local computer and on other online servers.
From the EC2 instance, try doing a telnet on the DB port to test if all your security group settings are applied correctly.
telnet hest2.cluster-xxxxx.us-east-1.rds.amazonaws.com 3306
If the connection does go through, then the issue is with your client code. Cross check that you have wired the right endpoint in your code.
If the telnet connection does not group (I'm guessing that it would not), then it is guaranteed that your security group settings are not set correctly. In order to debug this further, we would need more details on:
The list of vpc security groups associated with your cluster.
The details of each of these vpc security groups (You've mentioned that
you've opened up everything, but I'd like to see the exact rules in
place)
As for laptop and other servers - If they are outside the VPC, then it would not work. Aurora Serverless is accessible only from within the VPC as of now.

Connecting to instance using putty

I launched a spot instance using this official cloud formation template provided by AWS labs.
https://github.com/awslabs/ec2-spot-labs/blob/master/ec2-spot-fleet-launch-templates/ec2-spot-fleet-launch-templates.yaml
I can see the instance is created but not able to connect it using putty.
Does it mean the template creates route tables without internet access?
In the template, I can see internet gateway is attached. Can you please check security group if port 22 is allowed from 0.0.0.0 or your IP.

Laravel: cannot use php artisan migrate with Amazon RDS

I followed every tutorial from Amazon to set up the RDS Database then to set up the VPC, the subnet, and the Security Groups but I still can't connect to the Database using Laravel command.
However, I can connect to the Database using MySQLWorkbench...
This is the error I got when I use the command "php artisan migrate"
Every help will be more than appreciate, thank you Guys.
I'm taking these settings right out of my RDS instance and the Laravel application that uses it.
The first thing you have to do after setting up your RDS database is to allow the database instance to be accessed publicly. This can be done from your AWS console by going to RDS > DB Instances > your database instance > Modify (top left corner). Then scroll down to the Network and Security section and select 'Yes' for public accessibility.
Also double check your Security groups to make sure there is a rule allowing incoming connections to port 3306.
In your Laravel application's .env file and update the database values.
DB_HOST should contain the endpoint specified on the Connectivity and security section of the RDS dashboard. DB_PORT should remain at 3306. Then specify the database name in DB_DATABASE and the database credentials in DB_USERNAME and DB_PASSWORD.
These are the settings I'm using to connect my Laravel application to an RDS MySQL database.
It's difficult to say but it looks like you have the incorrect DB name.
Double check your RDS db name and the environment variable DB_DATABASE

Oracle installation failed on AWS redhat EC2 instance

I'm trying to install oracle on AWS redhat instance. Follow the steps given on this url: http://www.davidghedini.com/pg/entry/install_oracle_11g_xe_on And when I run config command as follows
/etc/init.d/oracle-xe configure
It gives following error.
Database Configuration failed. Look into
/u01/app/oracle/product/11.2.0/xe/config/log for details
When I check the log files it shows following errors.
ORA-01034: ORACLE not available Process ID: 0 Session ID: 0 Serial
number: 0
It seems specific issue on AWS cloud instance.
Is it because of swap memory?
Or is it because of port issue?
I'm using micro instance on it.
How can I get through?
this might be an EC2 security group issue and outbound access to the network on some port being used by the installer (license check, maybe?).
if your EC2 instance is very tightly locked down, you could test if it's a security group issue by adding a new Outbound security group rule to allow all TCP traffic out to anywhere on the internet (0.0.0.0/0)
for example, the install might be trying to hit a remote licensing server endpoint via HTTP or HTTPS but your security group doesn't allow that traffic out.
perhaps there's a 'verbose' flag that you can run the installer with that can give you more info about what it's failing on? HTH

Connecting to RDS Instance from Elastic Beanstalk

This has been killing me all day.
I've set up Elastic Beanstalk, working fine.
Set up RDS, working fine and can access from my laptop.
But when i try to connect to the RDS from my ES application i get a timeout error.
Extra info is that i'm using a Laravel application, connecting to a MYSQL database. All of my environment variables have been loaded and accepted fine.
I'm almost certain it's a security groups setting, but the docs are so tremendously bad for AWS that i haven't got a clue what to do!
Any help?
Answer was to go to Services > VPC
Under the Security section, click Security groups.
Click the RDS group, then Inbound Rules.
Edit, then add a rule:
Select MYSQL, change the port, then the IP should be custom IP and type in the ID of your Elastic Beanstalk security group / groups (No idea why i have 2)

Resources