You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在1核1GB Ubuntu Droplet上SpringBoot端点无法访问求助

Hey Nickknack, let's break down why your Spring Boot app is timing out even though Tomcat says it's up and running. I’ve run into this exact scenario on DigitalOcean Droplets a handful of times, so here’s a step-by-step checklist to diagnose and fix the issue:

1. First, check your Droplet’s firewall rules

DigitalOcean Droplets come with ufw enabled by default, and it’s super common to forget to open the port your Spring Boot app is using.

  • Run this command to see current firewall rules: sudo ufw status
  • If your target port (like 8080, or whatever you configured) isn’t listed under "ALLOW", add it: sudo ufw allow <your-port>/tcp
  • Reload the firewall to apply changes: sudo ufw reload

2. Make sure Spring Boot is binding to all network interfaces

By default, some Spring Boot setups only bind to localhost (127.0.0.1), which means the app is only accessible from inside the Droplet, not from the internet.

  • Check your app’s startup logs for a line like: Tomcat started on port(s): <port> (http) with context path ''
    • If you see (address=0.0.0.0) at the end, great— it’s listening on all interfaces.
    • If it says (address=127.0.0.1), you need to update your config:
      • In application.properties: add server.address=0.0.0.0
      • In application.yml: add
        server:
          address: 0.0.0.0
        
  • Restart your Spring Boot app and verify the log line shows the correct binding address.

3. Verify the port is actually being listened on

Sometimes Tomcat logs say it’s started, but the port isn’t actually open. Let’s confirm:

  • Run this command to check active listeners: sudo ss -tulpn | grep <your-port>
  • You should see output that looks like this: LISTEN 0 100 0.0.0.0:<port> 0.0.0.0:* users:(("java",pid=<XXXX>,fd=<XX>))
    • If you get no output, either the app didn’t start properly, or the port is taken by another process.
  • To find what’s using the port: sudo lsof -i :<your-port>, then kill that process with sudo kill -9 <PID> before restarting your app.

4. Test network connectivity to your Droplet

Sometimes the issue isn’t with your app or firewall, but with network routing or DNS.

  • Ping your Droplet’s IP to confirm it’s reachable: ping <your-droplet-ip>
  • If your domain isn’t working, check DNS resolution: nslookup <your-domain>— make sure it points to your Droplet’s correct IP.
  • Test if the port is accessible from outside: use telnet <your-droplet-ip> <your-port> (or a port-checking tool if you don’t have telnet). If it can’t connect, go back to step 1 to double-check the firewall.

5. Check if the app itself is functional

Even if Tomcat starts, your app might be stuck during initialization (like waiting for a MySQL connection that’s failing) which makes endpoints unresponsive.

  • Access the app locally on the Droplet: curl http://localhost:<your-port>/<your-endpoint>
    • If this fails, look through your app’s full logs for errors— things like database connection timeouts, missing beans, or misconfigured endpoints are common culprits.
    • If this works, then the problem is definitely with external access (firewall or network binding).

内容的提问来源于stack exchange,提问作者Nickknack

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 08:06:52