Localstack on Windows 10 Home giving ERR_CONNECTION_REFUSED - amazon-web-services

I am having issues getting Localstack to work on my Windows 10 Home System. I have been running Docker Toolbox without any issues (for other things).
I have tried invoking Localstack in multiple ways (e.g. via docker-compose.yml or by directly downloading it from Docker Hub) but I am always getting the same result i.e. the Container says that Localstack is ready but when I try to connect to the Localstack services on my browser (e.g. http://localhost:4566) I get the following error:
This site can’t be reached
localhost refused to connect error.
...
ERR_CONNECTION_REFUSED
Reproduced below is one sequence of steps that I have taken to attempt to invoke Localstack (unsuccessfully I must add).
Command invoked: docker run -it --name localstack localstack/localstack:latest
Message trace....
Waiting for all LocalStack services to be ready
2020-05-04 20:02:27,144 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message.
2020-05-04 20:02:27,154 INFO supervisord started with pid 13
2020-05-04 20:02:28,163 INFO spawned: 'dashboard' with pid 19
2020-05-04 20:02:28,173 INFO spawned: 'infra' with pid 20
2020-05-04 20:02:28,242 INFO success: dashboard entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
(. .venv/bin/activate; bin/localstack web)
(. .venv/bin/activate; exec bin/localstack start --host)
2020-05-04 20:02:29,246 INFO success: infra entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
Waiting for all LocalStack services to be ready
LocalStack version: 0.11.0
LocalStack version: 0.11.0
Starting local dev environment. CTRL-C to quit.
!WARNING! - Looks like you have configured $LAMBDA_REMOTE_DOCKER=1 - please make sure to configure $HOST_TMP_FOLDER to point to your host's $TMPDIR
Waiting for all LocalStack services to be ready
2020-05-04T20:02:42:INFO:localstack.utils.common: Unable to store key/cert files for custom SSL certificate: [Errno 13] Permission denied: '/tmp/localstack/server.test.pem.key'
2020-05-04T20:02:42:INFO:localstack.services.install: Downloading and installing local KMS server. This may take some time.
Waiting for all LocalStack services to be ready
Starting edge router (https port 4566)...
Starting mock API Gateway service in http ports 4566 (recommended) and 4567 (deprecated)...
2020-05-04T20:02:48:INFO:localstack.multiserver: Starting multi API server process on port 51492
Starting mock CloudFormation service in http ports 4566 (recommended) and 4581 (deprecated)...
Starting mock CloudWatch service in http ports 4566 (recommended) and 4582 (deprecated)...
Starting mock DynamoDB service in http ports 4566 (recommended) and 4569 (deprecated)...
Starting mock DynamoDB Streams service in http ports 4566 (recommended) and 4570 (deprecated)...
Starting mock EC2 service in http ports 4566 (recommended) and 4597 (deprecated)...
Starting mock ES service in http ports 4566 (recommended) and 4578 (deprecated)...
Starting mock Firehose service in http ports 4566 (recommended) and 4573 (deprecated)...
Starting mock IAM service in http ports 4566 (recommended) and 4593 (deprecated)...
Starting mock STS service in http ports 4566 (recommended) and 4592 (deprecated)...
Starting mock Kinesis service in http ports 4566 (recommended) and 4568 (deprecated)...
Starting mock KMS service in http ports 4566 (recommended) and 4599 (deprecated)...
Starting mock Lambda service in http ports 4566 (recommended) and 4574 (deprecated)...
Starting mock CloudWatch Logs service in http ports 4566 (recommended) and 4586 (deprecated)...
Starting mock Redshift service in http ports 4566 (recommended) and 4577 (deprecated)...
Starting mock Route53 service in http ports 4566 (recommended) and 4580 (deprecated)...
Starting mock S3 service in http ports 4566 (recommended) and 4572 (deprecated)...
Starting mock Secrets Manager service in http ports 4566 (recommended) and 4584 (deprecated)...
Starting mock SES service in http ports 4566 (recommended) and 4579 (deprecated)...
Starting mock SNS service in http ports 4566 (recommended) and 4575 (deprecated)...
Starting mock SQS service in http ports 4566 (recommended) and 4576 (deprecated)...
Starting mock SSM service in http ports 4566 (recommended) and 4583 (deprecated)...
Starting mock Cloudwatch Events service in http ports 4566 (recommended) and 4587 (deprecated)...
Starting mock StepFunctions service in http ports 4566 (recommended) and 4585 (deprecated)...
Waiting for all LocalStack services to be ready
Waiting for all LocalStack services to be ready
Waiting for all LocalStack services to be ready
Ready.
Since I kept getting the ERR_CONNECTION_REFUSED from the browser, I detached the terminal (Ctrl P+Q) and ran the following command in the container:
netstat -a
The output of the command is as follows:
Active Connections
Proto Local Address Foreign Address State
TCP 0.0.0.0:135 Mywinmc:0 LISTENING
TCP 0.0.0.0:445 Mywinmc:0 LISTENING
TCP 0.0.0.0:2425 Mywinmc:0 LISTENING
TCP 0.0.0.0:8092 Mywinmc:0 LISTENING
TCP 0.0.0.0:17500 Mywinmc:0 LISTENING
TCP 0.0.0.0:49664 Mywinmc:0 LISTENING
TCP 0.0.0.0:49665 Mywinmc:0 LISTENING
TCP 0.0.0.0:49666 Mywinmc:0 LISTENING
TCP 0.0.0.0:49667 Mywinmc:0 LISTENING
TCP 0.0.0.0:49668 Mywinmc:0 LISTENING
TCP 0.0.0.0:49673 Mywinmc:0 LISTENING
TCP 0.0.0.0:65530 Mywinmc:0 LISTENING
TCP 127.0.0.1:843 Mywinmc:0 LISTENING
TCP 127.0.0.1:5354 Mywinmc:0 LISTENING
TCP 127.0.0.1:5354 Mywinmc:49669 ESTABLISHED
TCP 127.0.0.1:5354 Mywinmc:49670 ESTABLISHED
TCP 127.0.0.1:17600 Mywinmc:0 LISTENING
TCP 127.0.0.1:27015 Mywinmc:0 LISTENING
TCP 127.0.0.1:27015 Mywinmc:50106 ESTABLISHED
TCP 127.0.0.1:44430 Mywinmc:0 LISTENING
TCP 127.0.0.1:49669 Mywinmc:5354 ESTABLISHED
TCP 127.0.0.1:49670 Mywinmc:5354 ESTABLISHED
TCP 127.0.0.1:50106 Mywinmc:27015 ESTABLISHED
TCP 127.0.0.1:50362 Mywinmc:0 LISTENING
TCP 127.0.0.1:52800 Mywinmc:52801 ESTABLISHED
TCP 127.0.0.1:52801 Mywinmc:52800 ESTABLISHED
TCP 127.0.0.1:52805 Mywinmc:52806 ESTABLISHED
TCP 127.0.0.1:52806 Mywinmc:52805 ESTABLISHED
TCP 192.168.1.13:139 Mywinmc:0 LISTENING
TCP 192.168.1.13:50247 20.185.212.106:https ESTABLISHED
TCP 192.168.1.13:51941 104.22.5.207:https ESTABLISHED
TCP 192.168.1.13:51949 server-13-249-79-178:https ESTABLISHED
TCP 192.168.1.13:51954 104.36.115.111:https ESTABLISHED
TCP 192.168.1.13:51963 server-13-249-75-45:https ESTABLISHED
TCP 192.168.1.13:52483 8.43.72.41:https ESTABLISHED
TCP 192.168.1.13:52486 104.17.119.107:https ESTABLISHED
TCP 192.168.1.13:52490 ip-185-184-8-30:https ESTABLISHED
TCP 192.168.1.13:53474 52.226.111.32:https ESTABLISHED
TCP 192.168.1.13:53665 ec2-34-194-118-104:https CLOSE_WAIT
TCP 192.168.1.13:54028 104.26.8.27:https ESTABLISHED
TCP 192.168.1.13:54104 bam-8:https ESTABLISHED
TCP 192.168.1.13:54228 30:https ESTABLISHED
TCP 192.168.1.13:54261 139:https ESTABLISHED
TCP 192.168.1.13:54265 151.101.49.253:https ESTABLISHED
TCP 192.168.1.13:54266 a-0001:https ESTABLISHED
TCP 192.168.1.13:54269 49:https ESTABLISHED
TCP 192.168.1.13:54277 49:https ESTABLISHED
TCP 192.168.1.13:54281 49:https ESTABLISHED
TCP 192.168.1.13:54289 194:https ESTABLISHED
TCP 192.168.1.13:54355 162.125.35.135:https CLOSE_WAIT
TCP 192.168.1.13:54378 162.125.8.13:https CLOSE_WAIT
TCP 192.168.1.13:54406 20.185.212.106:https ESTABLISHED
TCP 192.168.1.13:54419 162.125.8.7:https CLOSE_WAIT
TCP 192.168.1.13:54421 162.125.19.131:https ESTABLISHED
TCP 192.168.1.13:54422 152.199.6.14:https TIME_WAIT
TCP 192.168.1.13:54424 152.199.5.3:https TIME_WAIT
TCP 192.168.1.13:54425 ec2-3-94-69-170:https TIME_WAIT
TCP 192.168.1.13:54429 server-143-204-160-19:https ESTABLISHED
TCP 192.168.1.13:54430 a23-193-18-78:https ESTABLISHED
TCP 192.168.1.13:54440 a23-193-18-78:https ESTABLISHED
TCP 192.168.1.13:54444 ec2-54-162-73-57:https ESTABLISHED
TCP 192.168.1.13:54447 a23-67-241-31:https ESTABLISHED
TCP 192.168.1.13:54470 server-13-249-79-42:https ESTABLISHED
TCP 192.168.1.13:54474 104.16.68.69:https ESTABLISHED
TCP 192.168.1.13:54478 a23-199-248-26:https ESTABLISHED
TCP 192.168.1.13:54498 185.167.164.39:https TIME_WAIT
TCP 192.168.1.13:54504 93.184.215.201:https ESTABLISHED
TCP 192.168.1.13:54509 lb-140-82-114-3-iad:https TIME_WAIT
TCP 192.168.1.13:54510 151.101.48.133:https TIME_WAIT
TCP 192.168.1.13:54513 s3:https TIME_WAIT
TCP 192.168.1.13:54515 104.16.133.229:https TIME_WAIT
TCP 192.168.1.13:54516 server-13-249-79-31:https TIME_WAIT
TCP 192.168.1.13:54520 ec2-3-224-32-104:https TIME_WAIT
TCP 192.168.1.13:54526 192.184.68.146:https CLOSE_WAIT
TCP 192.168.1.13:54527 185.167.164.39:https TIME_WAIT
TCP 192.168.1.13:54528 ec2-3-217-197-240:https CLOSE_WAIT
TCP 192.168.1.13:54529 ec2-3-217-197-240:https CLOSE_WAIT
TCP 192.168.1.13:54530 ec2-54-69-254-184:https CLOSE_WAIT
TCP 192.168.1.13:54533 54.239.17.112:https ESTABLISHED
TCP 192.168.1.13:54537 232:https ESTABLISHED
TCP 192.168.1.13:54538 r-17-48-62-5:https TIME_WAIT
TCP 192.168.1.13:60684 40.83.21.197:https ESTABLISHED
TCP 192.168.1.13:60695 52.242.211.89:https ESTABLISHED
TCP 192.168.1.13:60696 52.242.211.89:https ESTABLISHED
TCP 192.168.1.13:60780 ec2-3-224-94-60:https ESTABLISHED
TCP 192.168.1.13:61712 whatsapp-cdn-shv-01-dfw5:https ESTABLISHED
TCP 192.168.1.13:63209 9:https ESTABLISHED
TCP 192.168.1.13:63395 Chromecast:8009 ESTABLISHED
TCP 192.168.1.13:63705 on-in-f188:5228 ESTABLISHED
TCP 192.168.1.13:63706 e1:https ESTABLISHED
TCP 192.168.1.13:63720 108-174-10-10:https ESTABLISHED
TCP 192.168.56.1:139 Mywinmc:0 LISTENING
TCP 192.168.99.1:139 Mywinmc:0 LISTENING
TCP [::]:135 Mywinmc:0 LISTENING
TCP [::]:445 Mywinmc:0 LISTENING
TCP [::]:8092 Mywinmc:0 LISTENING
TCP [::]:17500 Mywinmc:0 LISTENING
TCP [::]:49664 Mywinmc:0 LISTENING
TCP [::]:49665 Mywinmc:0 LISTENING
TCP [::]:49666 Mywinmc:0 LISTENING
TCP [::]:49667 Mywinmc:0 LISTENING
TCP [::]:49668 Mywinmc:0 LISTENING
TCP [::]:49673 Mywinmc:0 LISTENING
TCP [::1]:49770 Mywinmc:0 LISTENING
UDP 0.0.0.0:500 *:*
UDP 0.0.0.0:2425 *:*
UDP 0.0.0.0:3702 *:*
UDP 0.0.0.0:3702 *:*
UDP 0.0.0.0:4500 *:*
UDP 0.0.0.0:5050 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:5355 *:*
UDP 0.0.0.0:17500 *:*
UDP 0.0.0.0:49640 *:*
UDP 0.0.0.0:49774 *:*
UDP 0.0.0.0:54925 *:*
UDP 0.0.0.0:55066 *:*
UDP 0.0.0.0:55739 *:*
UDP 0.0.0.0:57602 *:*
UDP 0.0.0.0:57603 *:*
UDP 0.0.0.0:57975 *:*
UDP 0.0.0.0:58140 *:*
UDP 0.0.0.0:58995 *:*
UDP 0.0.0.0:59072 *:*
UDP 0.0.0.0:59303 *:*
UDP 0.0.0.0:59698 *:*
UDP 0.0.0.0:60343 *:*
UDP 0.0.0.0:60813 *:*
UDP 127.0.0.1:1900 *:*
UDP 127.0.0.1:49677 *:*
UDP 127.0.0.1:49678 *:*
UDP 127.0.0.1:50019 *:*
UDP 127.0.0.1:58994 *:*
UDP 127.0.0.1:59070 *:*
UDP 127.0.0.1:62643 *:*
UDP 127.0.0.1:64870 *:*
UDP 127.0.0.1:64871 *:*
UDP 192.168.1.13:137 *:*
UDP 192.168.1.13:138 *:*
UDP 192.168.1.13:1900 *:*
UDP 192.168.1.13:2177 *:*
UDP 192.168.1.13:5353 *:*
UDP 192.168.1.13:50018 *:*
UDP 192.168.56.1:137 *:*
UDP 192.168.56.1:138 *:*
UDP 192.168.56.1:1900 *:*
UDP 192.168.56.1:2177 *:*
UDP 192.168.56.1:5353 *:*
UDP 192.168.56.1:50016 *:*
UDP 192.168.99.1:137 *:*
UDP 192.168.99.1:138 *:*
UDP 192.168.99.1:1900 *:*
UDP 192.168.99.1:2177 *:*
UDP 192.168.99.1:5353 *:*
UDP 192.168.99.1:50017 *:*
UDP [::]:500 *:*
UDP [::]:3702 *:*
UDP [::]:3702 *:*
UDP [::]:4500 *:*
UDP [::]:5353 *:*
UDP [::]:5353 *:*
UDP [::]:5353 *:*
UDP [::]:5353 *:*
UDP [::]:5353 *:*
UDP [::]:5353 *:*
UDP [::]:5353 *:*
UDP [::]:5353 *:*
UDP [::]:5353 *:*
UDP [::]:5355 *:*
UDP [::]:49775 *:*
UDP [::]:59303 *:*
UDP [::]:59699 *:*
UDP [::1]:1900 *:*
UDP [::1]:5353 *:*
UDP [::1]:50015 *:*
UDP [fe80::6c83:b041:8dfb:82dd%6]:1900 *:*
UDP [fe80::6c83:b041:8dfb:82dd%6]:2177 *:*
UDP [fe80::6c83:b041:8dfb:82dd%6]:50014 *:*
UDP [fe80::9cd1:1694:a63e:e0c3%2]:1900 *:*
UDP [fe80::9cd1:1694:a63e:e0c3%2]:2177 *:*
UDP [fe80::9cd1:1694:a63e:e0c3%2]:50013 *:*
UDP [fe80::e8c8:ff57:e70f:27e1%19]:546 *:*
UDP [fe80::e8c8:ff57:e70f:27e1%19]:1900 *:*
UDP [fe80::e8c8:ff57:e70f:27e1%19]:2177 *:*
UDP [fe80::e8c8:ff57:e70f:27e1%19]:50012 *:*
It is clear that mock services are not running in the container, despite what the message trace of docker run -it --name localstack localstack/localstack:latest suggests (as shown above).
Even the following command did not work:
docker run -it --name localstack2 -e HOST_TMP_FOLDER="/tmp" localstack/localstack:latest

Are your ports mapped to the host?
docker run -it --name localstack localstack/localstack:latest -p 4567-4584:4567-4584
try adding the -p param to your docker command

Related

I added port 8080 on ec2 security group but 8080 is not on listening list

webpage is loading on localhost. but not with public IP. I get connection refused. so I checked port is listening but Its not. what can i do?
Add 8080 port Inbound rules
[ec2-user#springboot-webservice ~]$ netstat -ntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:36145 0.0.0.0:* LISTEN
tcp 0 0 :::22 :::* LISTEN
tcp 0 0 :::43675 :::* LISTEN
tcp 0 0 :::111 :::* LISTEN
Are you sure your application is running?
If not, then go to your application directory a un run it.
Gradle
./gradlew bootRun
Maven
./mvnw spring-boot:run
What port you specified for your application to run. If you don't specify any, by default it will run on port 8080.
You can add server.port in your application.properties to change your port if you prefer.
src
main
resources
application.properties
#application.properties content
server.port=8080 #your port
#server.port=80 another port to test
If you have Spring Security in your dependencies, so that's the reason for the login page.
Check What is username and password when starting Spring Boot with Tomcat?
If you only can see you application on localhost, but can't expose your application to the world.
Your EC2 instance is in a private subnet or a public subnet?
Your application can only be seen if it is on a public subnet. Default subnets are always public subnet.
Maybe this tutorial can help you check if any steps are missing. https://www.javacodegeeks.com/2019/10/deploy-spring-boot-application-aws-ec2-instance.html

Remotely connecting to a single node Cassandra clustor (on an EC2 instance)

I'm running a single node Cassandra cluster on a medium Ubuntu EC2 instance. Before making any changes to cassandra.yaml, I can connect to cassandra using cqlsh,
and running netstat -ltn logs:
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:38807 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:7000 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:35835 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:7199 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:9160 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:9042 0.0.0.0:* LISTEN
tcp6 0 0 :::22 :::* LISTEN
And checking Cassandra service status shows it's active (running)
Trying to connect to the instance remotely using cqlsh <instance public IP> times out and I'm assuming that's because it's not listening for clients at the instance public IP.
So far I have tired:
Changing listen_address to my my private instance IP
Setting start_rpc:true, rpc_address to my private IP and broadcast_address to my public IP
Setting rpc_address to 0.0.0.0 and broadcast_rpc_address to my public IP
Note: I am keeping seeds: "127.0.0.1" as is, since I don't have other seeds or nodes.
Making any of the above changes, I am no longer able to access Cassandra using cqlsh or cqlsh <public IP> locally (and remotely still no connecting), even in the instance terminal itself and I would I get connection refused. Also, netstat -ltn now logs:
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:38807 0.0.0.0:* LISTEN
tcp6 0 0 :::22 :::* LISTEN
And Cassandra service status shows it as active (exited)
I would like to be able to connect to the instance remotely, but in making any changes to cassandra.yaml, I am no longer able to connect to it, even locally.
Also, I have the security groups setup on the instance for ports 80, 22, 9042 and 7000.
Any ideas why this is happening or how I can fix it?
For nodes which have both private and public IP addresses, you just need to set:
listen_address: private_ip
rpc_address: public_ip
You only need to set the broadcast_address to the node's public IP if there are nodes in another region so nodes can talk to each other across the WAN on EC2. This means that you need to rollback all the other properties you configured.
The listen_address is used for internode communication (gossip on port 7000) which is why it's set to the private IP.
Apps/clients (cqlsh is just another client) connects to the nodes on the rpc_address so it needs to be set to an IP that is publicly accessible.
I've answered a similar question recently in this post https://community.datastax.com/questions/8867/ if you're interested in a bit more detail. Cheers!

AWS: Failed to connect to port XXXX: Connection refused

I am connected to an AWS server, where I want to host an Elasticsearch application. For that to work, I need to open a set of ports. In my AWS security group, I have opened the ones, which I consider as necessary. In order to check, whether that worked, I tried the following:
While connected to AWS via ssh, I typed curl localhost:3002, which outputs:
<html><body>You are being redirected.</body></html>
When I try the same over my local machine, i.e. curl http://ec2-xxxxx.eu-central-1.compute.amazonaws.com:3002, I receive:
curl: (7) Failed to connect to ec2-xxxxx.eu-central-1.compute.amazonaws.com port 3002: Connection refused
Does that mean, that the port 3002 is not open, or could there be another explanation?
Thank you for your help!
Edit:
The configuration in the security group looks as follows:
Ingoing:
80 TCP 0.0.0.0/0 launch-wizard-7
80 TCP ::/0 launch-wizard-7
22 TCP 0.0.0.0/0 launch-wizard-7
5000 TCP 0.0.0.0/0 launch-wizard-7
5000 TCP ::/0 launch-wizard-7
3002 TCP 0.0.0.0/0 launch-wizard-7
3002 TCP ::/0 launch-wizard-7
3000 TCP 0.0.0.0/0 launch-wizard-7
3000 TCP ::/0 launch-wizard-7
443 TCP 0.0.0.0/0 launch-wizard-7
443 TCP ::/0 launch-wizard-7
Outgoing:
All All 0.0.0.0/0 launch-wizard-7

Can't seem to open port 8787 or 3939 on an Ubuntu EC2 instance but 22 and 80 opens fine

I've read through this answer but for the life of me, I can't figure out this one out.
I have an Ubuntu 18 EC2 instance running RStudio Server and RStudio Connect, both using default configuration and listening on ports 8787 and 3939 respectively.
Here are my config files:
ubuntu#EC2:~$ cat /etc/rstudio/rserver.conf
# Server Configuration File
#
#
ubuntu#EC2:~$ sudo cat /etc/rstudio-connect/rstudio-connect.gcfg
; RStudio Connect configuration file
[Server]
; SenderEmail is an email address used by RStudio Connect to send outbound
; email. The system will not be able to send administrative email until this
; setting is configured.
;
; SenderEmail = account#company.com
SenderEmail =
; Address is a public URL for this RStudio Connect server. Must be configured
; to enable features like including links to your content in emails. If
; Connect is deployed behind an HTTP proxy, this should be the URL for Connect
; in terms of that proxy.
;
; Address = https://rstudio-connect.company.com
Address =
[HTTP]
; RStudio Connect will listen on this network address for HTTP connections.
Listen = :3939
[Authentication]
; Specifies the type of user authentication.
Provider = password
Here's what I've tried:
Created inbound rules for ports 8787, 3939 and all TCP ports in my security group.
Checked the Network ACL for the subnet the instance is on
Ensured that rstudio-server and rstudio-connect are running and listening on all interfaces and not just localhost
ubuntu#EC2:~$ netstat -ltpn
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8787 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp6 0 0 :::8787 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 :::3939 :::* LISTEN -
Checked that ufw is inactive
ubuntu#EC2:~$ sudo ufw status
Status: inactive
Created an iptables rule for port 8787
ubuntu#EC2:~$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:8787
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
I still can't access port 8787 or 3939 externally. However I can access them both on the host using Lynx.
If I change RStudio Server's configuration to have it use port 80 instead, I can access it externally but it doesn't work for ports 8787 or 3939.
Any ideas why and how to fix this?
I just figured out the answer myself. There was absolutely nothing wrong with my configuration. Opening up all the TCP ports in my security group was a bit overkill maybe and entirely unnecessary, so don't do that.
The issue was that the corporate network I am connected to blocks outbound traffic to external hosts on certain non-standard ports.
If you're in the same boat as me and need to host 2 services on the same EC2 instance but don't know which ports are unavailable/blocked by your organization then you could use nmap and portquiz.net to figure it out.
nmap is a port scanner and portquiz.net is a service that listens for connections on all TCP ports. You could scan the host using nmap over a range of TCP ports you're interested in using and see which ports show up as open
nmap -v -p0-8000 portquiz.net
Starting Nmap 7.70 ( https://nmap.org ) at 2019-04-02 16:47 IST
Initiating Ping Scan at 16:47
Scanning portquiz.net (5.196.70.86) [2 ports]
Completed Ping Scan at 16:47, 0.13s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 16:47
Completed Parallel DNS resolution of 1 host. at 16:47, 0.14s elapsed
Initiating Connect Scan at 16:47
Scanning portquiz.net (5.196.70.86) [8001 ports]
Discovered open port 22/tcp on 5.196.70.86
Discovered open port 80/tcp on 5.196.70.86
Discovered open port 443/tcp on 5.196.70.86
Discovered open port 21/tcp on 5.196.70.86
Discovered open port 4080/tcp on 5.196.70.86
Completed Connect Scan at 16:48, 84.98s elapsed (8001 total ports)
Nmap scan report for portquiz.net (5.196.70.86)
Host is up (0.13s latency).
rDNS record for 5.196.70.86: electron.positon.org
Not shown: 7996 filtered ports
PORT STATE SERVICE
21/tcp open ftp
22/tcp open ssh
80/tcp open http
443/tcp open https
4080/tcp open lorica-in
Here, I have 4080 and 80 open so that means the corporate firewall isn't blocking outbound traffic to these ports. After configuring RStudio Server and RStudio Connect to listen on ports 80 and 4080 respectively, I'm now able to access both services externally.

UDP MITM by adding rules to iptables

In C++ UDP Socket port multiplexing, I found that using DNAT PREROUTING, I can redirect the packets for a particular UDP port and listen to packets being received on it.
iptables -t nat -A PREROUTING -i <iface> -p <proto> --dport <dport>
-j REDIRECT --to-port <newport>
Unfortunately this works ONLY for packets received at this port. How can I get the packets being sent from this port?