Xavier Arias
Xavier Arias

Reputation: 164

Cannot connect to an EC2 instance through web sockets

I am running an Akka HTTP service on port 8080 in my EC2 instance. It expects web socket connections, but normal HTTP should return 400 bad request.

I use this code to start Akka service:

Http().bindAndHandle(route, "localhost", 8080)

From the remote terminal I have this expected behavior, but not from outside.

$ wget ec2-XX-XXX-XX-XXX.compute-1.amazonaws.com:8080
--2017-10-01 15:27:31--  http://ec2-XX-XXX-XX-XXX.compute-1.amazonaws.com:8080/
Resolving ec2-XX-XXX-XX-XXX.compute-1.amazonaws.com... XX.XXX.XX.XXX
Connecting to ec2-XX-XXX-XX-XXX.compute-1.amazonaws.com|XX.XXX.XX.XXX|:8080... failed: Connection refused.

Here is my inbound rules configuration:

Security group

If I do netstat --listen -p the port 8080 does not appear.

Thanks!

Upvotes: 1

Views: 668

Answers (1)

Xavier Arias
Xavier Arias

Reputation: 164

I found out the problem. I should be binding the service to the private IP address of the EC2 instance.

Upvotes: 2

Related Questions