
{"id":70,"date":"2025-06-04T21:08:05","date_gmt":"2025-06-04T20:08:05","guid":{"rendered":"https:\/\/blog.mkcloudai.com\/?p=70"},"modified":"2025-06-04T21:08:05","modified_gmt":"2025-06-04T20:08:05","slug":"step-by-step-aws-lightsail-ubuntu-access-troubleshooting","status":"publish","type":"post","link":"https:\/\/blog.mkcloudai.com\/?p=70","title":{"rendered":"Step-by-Step AWS Lightsail\/ubuntu Access  Troubleshooting"},"content":{"rendered":"\n<p>Scenario: Let\u2019s troubleshoot your AWS Lightsail instance step by step. Since <strong>WordPress<\/strong>, a <strong>Python app (on port 5000)<\/strong>, and <strong>SSH access (port 22 is off)<\/strong> are all not working, it seems likely your instance is either down, misconfigured, or blocked by the firewall.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Check if the Instance is Running<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Log in to the <a class=\"\" href=\"https:\/\/lightsail.aws.amazon.com\/\">Lightsail Console<\/a>.<\/li>\n\n\n\n<li>Look at the <strong>state of the instance<\/strong> \u2013 is it <code>Running<\/code>?\n<ul class=\"wp-block-list\">\n<li>\u2705 Yes? Proceed to Step 2.<\/li>\n\n\n\n<li>\u274c No? Start the instance and retry access.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Use Lightsail\u2019s Web SSH to Get In<\/strong><\/h3>\n\n\n\n<p>If port 22 is disabled, <strong>you won\u2019t be able to SSH from your computer<\/strong>.<\/p>\n\n\n\n<p>Instead:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to your instance on the Lightsail dashboard.<\/li>\n\n\n\n<li>Click the <strong>&#8220;Connect using SSH&#8221;<\/strong> option in the browser.<\/li>\n\n\n\n<li>You should now be in the terminal directly.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 3: Check Firewall Rules (Networking Tab)<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>In the Lightsail dashboard, click the <strong>Networking<\/strong> tab for your instance.<\/li>\n\n\n\n<li>Ensure the following <strong>Firewall rules (public ports)<\/strong> are added:\n<ul class=\"wp-block-list\">\n<li>TCP <strong>80<\/strong> \u2013 HTTP (for WordPress)<\/li>\n\n\n\n<li>TCP <strong>443<\/strong> \u2013 HTTPS (if SSL enabled)<\/li>\n\n\n\n<li>TCP <strong>5000<\/strong> \u2013 for Python app<\/li>\n\n\n\n<li>TCP <strong>22<\/strong> \u2013 for SSH (you can temporarily re-enable for testing)<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>If port 22 is missing, re-add it temporarily for external SSH testing.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 4: Check Services Are Running<\/strong><\/h3>\n\n\n\n<p>In the browser SSH terminal, run:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code># Check system resource usage<br>top<br><br># Is Apache or Nginx running for WordPress?<br>sudo systemctl status apache2<br>sudo systemctl status nginx<br><br># Is your Python app running? If you use Flask:<br>ps aux | grep flask<br><br># Or check if anything is using port 5000:<br>sudo lsof -i:5000<\/code><\/pre>\n\n\n\n<p>If services are inactive, restart them:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code># Example for Apache<br>sudo systemctl restart apache2<br><br># For your Python app (if Flask)<br>python3 yourapp.py<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 5: Check if Ports Are Listening<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo netstat -tuln | grep LISTEN<br><\/code><\/pre>\n\n\n\n<p>Look for lines like:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>0.0.0.0:80<\/code> \u2014 WordPress<\/li>\n\n\n\n<li><code>0.0.0.0:5000<\/code> \u2014 Python app<\/li>\n<\/ul>\n\n\n\n<p>If you don\u2019t see port 5000, your app may not be running or is bound to <code>localhost<\/code> instead of <code>0.0.0.0<\/code>.<\/p>\n\n\n\n<p>Update Flask code:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>app.run(host=\"0.0.0.0\", port=5000)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 6: Check UFW (Ubuntu Firewall, if enabled)<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo ufw status<br><\/code><\/pre>\n\n\n\n<p>Make sure these rules exist:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Allow 80<\/code><\/li>\n\n\n\n<li><code>Allow 5000<\/code><\/li>\n\n\n\n<li><code>Allow 22<\/code> (if you&#8217;re still using SSH)<\/li>\n<\/ul>\n\n\n\n<p>If needed, allow ports:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo ufw allow 80<br>sudo ufw allow 5000<br>sudo ufw allow 22<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 7: Check Public IP and Security Group<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Double-check that you&#8217;re using the <strong>public IP<\/strong> of the Lightsail instance.<\/li>\n\n\n\n<li>Make sure <strong>Lightsail\u2019s networking firewall rules<\/strong> allow traffic from <strong>anywhere (0.0.0.0\/0)<\/strong> for needed ports.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Optional: Restore SSH Access (If Needed)<\/h3>\n\n\n\n<p>If you\u2019ve disabled port 22 but are locked out:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use <strong>Web SSH<\/strong>, and:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\"><code># Re-enable SSH temporarily<br>sudo ufw allow 22<br><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u2705 STEP-BY-STEP: Python App on Port 5000 Not Working<\/h3>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Is the Python App Running?<\/strong><\/h3>\n\n\n\n<p>SSH into the instance, then run:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ps aux | grep python<br><\/code><\/pre>\n\n\n\n<p>If your app is not listed, it\u2019s not running. If it is listed, verify it\u2019s bound to the right interface.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Run It Manually<\/strong><\/h3>\n\n\n\n<p>If it\u2019s a Flask or FastAPI app, try running it manually:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cd \/path\/to\/your\/app<br><br># Flask example<br>python3 app.py<br><\/code><\/pre>\n\n\n\n<p>Make sure your app includes:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>app.run(host=\"0.0.0.0\", port=5000)<br><\/code><\/pre>\n\n\n\n<p>If it says <code>host='127.0.0.1'<\/code>, it will only be available <strong>internally<\/strong>, not to the public.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 3: Check If Port 5000 is Listening<\/strong><\/h3>\n\n\n\n<p>Run:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo lsof -i:5000<br><\/code><\/pre>\n\n\n\n<p>or<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo netstat -tuln | grep 5000<br><\/code><\/pre>\n\n\n\n<p>You should see something like:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>tcp    0   0 0.0.0.0:5000   0.0.0.0:*   LISTEN<br><\/code><\/pre>\n\n\n\n<p>If not, the app isn\u2019t running or is bound to localhost.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 4: Firewall Check (UFW + Lightsail)<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">1. <strong>UFW Rules (if enabled)<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo ufw status<br><\/code><\/pre>\n\n\n\n<p>You should see:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>5000                      ALLOW       Anywhere<br><\/code><\/pre>\n\n\n\n<p>If not:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo ufw allow 5000<br><\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\ud83d\udd27 To Remove That Specific IP Rule on Port 5000<\/h4>\n\n\n\n<p>Run this to list numbered UFW rules:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo ufw status numbered<br><\/code><\/pre>\n\n\n\n<p>You&#8217;ll see something like:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>[ 1] 5000\/tcp                   ALLOW IN    84.65.107.114<br>[ 2] 22\/tcp                     ALLOW IN    Anywhere<br>...<br><\/code><\/pre>\n\n\n\n<p>Now remove the rule for your old IP (e.g., rule <code>[ 1 ]<\/code>):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo ufw delete 1<br><\/code><\/pre>\n\n\n\n<p>\ud83d\udc49 Note: The number might change depending on your list \u2014 <strong>use the number shown in your actual list<\/strong>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\">\u2705 Then Add a New Rule to Open Port 5000 to Everyone (or Your New IP)<\/h4>\n\n\n\n<h3 class=\"wp-block-heading\">Option A: Allow from any IP (good for public testing)<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo ufw allow 5000<br><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Option B: Allow from your current IP only (for security)<\/h3>\n\n\n\n<p>First, get your current IP:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>curl ifconfig.me<br><\/code><\/pre>\n\n\n\n<p>Then allow:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo ufw allow from YOUR.NEW.IP.ADDR to any port 5000<br><\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">2. <strong>Lightsail Networking Rules<\/strong><\/h4>\n\n\n\n<p>Go to <strong>Lightsail Console &gt; Networking tab<\/strong> for your instance:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Make sure there\u2019s a rule like:\n<ul class=\"wp-block-list\">\n<li><strong>Application<\/strong>: Custom<\/li>\n\n\n\n<li><strong>Port<\/strong>: 5000<\/li>\n\n\n\n<li><strong>Source Type<\/strong>: Anywhere (or your IP)<\/li>\n\n\n\n<li><strong>Source IP<\/strong>: <code>0.0.0.0\/0<\/code> or your IP<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 5: Use a Process Manager for Auto-Restart (Optional)<\/strong><\/h3>\n\n\n\n<p>If you want it to survive after terminal logout or reboot:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Option A: <code>nohup<\/code><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>nohup python3 app.py &amp;<br><\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Option B: Use <code>systemd<\/code> to create a service:<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo nano \/etc\/systemd\/system\/myapp.service<br><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>[Unit]<br>Description=My Python App<br>After=network.target<br><br>[Service]<br>User=ubuntu<br>WorkingDirectory=\/home\/ubuntu\/myapp<br>ExecStart=\/usr\/bin\/python3 \/home\/ubuntu\/myapp\/app.py<br>Restart=always<br><br>[Install]<br>WantedBy=multi-user.target<br><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo systemctl daemon-reexec<br>sudo systemctl daemon-reload<br>sudo systemctl start myapp<br>sudo systemctl enable myapp<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 6: Test from Browser<\/strong><\/h3>\n\n\n\n<p>Try:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>http:\/\/&lt;your-public-ip>:5000<br><\/code><\/pre>\n\n\n\n<p>If it doesn\u2019t load:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Confirm again <code>sudo lsof -i:5000<\/code><\/li>\n\n\n\n<li>Check <code>ufw<\/code> and Lightsail firewall<\/li>\n\n\n\n<li>Check app logs for crash\/errors<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Scenario: Let\u2019s troubleshoot your AWS Lightsail instance step by step. Since WordPress, a Python app (on port 5000), and SSH [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[9],"tags":[],"class_list":["post-70","post","type-post","status-publish","format-standard","hentry","category-tutorial"],"_links":{"self":[{"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=\/wp\/v2\/posts\/70","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=70"}],"version-history":[{"count":1,"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=\/wp\/v2\/posts\/70\/revisions"}],"predecessor-version":[{"id":71,"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=\/wp\/v2\/posts\/70\/revisions\/71"}],"wp:attachment":[{"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=70"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=70"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=70"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}