java.net.SocketException: 权限不够
java.net.SocketException: 权限不够
一切问题的根源都是缺乏常识 0.0.....
背景:今天部署一个spring cloud服务,tanainaide 服务的端口为80,然后我建了个tomcat用户来启动,但是死活起不来,搞了好久还以为是环境问题都重新建了台新机子,还是不行,然后换root用户起来可以,很奇怪。报错如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | 12 - 12 19 : 44 : 58.792 |INFO|c.netflix.discovery.DiscoveryClient: 813 |DiscoveryClient - InstanceInfoReplicator - 0 ||DiscoveryClient_TPP - ZUUL - PRE / 10.90 . 6.95 : 80 - registration status: 204 12 - 12 19 : 44 : 58.795 |INFO|o.s.b.a.e.jmx.EndpointMBeanExporter: 678 |main||Located managed bean 'configurationPropertiesReportEndpoint' : registering with JMX server as MBean [org.springframework.boot: type = Endpoint,name = configurationPropertiesReportEndpoint] 12 - 12 19 : 44 : 58.797 |INFO|o.s.c.s.DefaultLifecycleProcessor: 343 |main||Starting beans in phase 2147483647 12 - 12 19 : 44 : 58.801 |INFO|o.s.c.n.h.HystrixCircuitBreakerConfiguration$HystrixMetricsPollerConfiguration: 138 |main||Starting poller 12 - 12 19 : 44 : 58.816 |INFO|o.s.s.a.ScheduledAnnotationBeanPostProcessor: 262 |main||No TaskScheduler / ScheduledExecutorService bean found for scheduled processing 12 - 12 19 : 44 : 58.825 |INFO|o.a.coyote.http11.Http11NioProtocol: 179 |main||Initializing ProtocolHandler [ "http-nio-80" ] 12 - 12 19 : 44 : 58.836 |INFO|o.a.coyote.http11.Http11NioProtocol: 179 |main||Starting ProtocolHandler [ "http-nio-80" ] 12 - 12 19 : 44 : 58.839 |ERROR|o.a.coyote.http11.Http11NioProtocol: 181 |main||Failed to start end point associated with ProtocolHandler [ "http-nio-80" ] java.net.SocketException: 权限不够 at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Net.java: 433 ) at sun.nio.ch.Net.bind(Net.java: 425 ) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java: 223 ) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java: 74 ) at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java: 210 ) at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java: 990 ) at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java: 635 ) at org.apache.catalina.connector.Connector.startInternal(Connector.java: 1022 ) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java: 150 ) at org.apache.catalina.core.StandardService.addConnector(StandardService.java: 225 ) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.addPreviouslyRemovedConnectors(TomcatEmbeddedServletContainer.java: 250 ) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java: 193 ) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java: 297 ) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java: 145 ) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java: 546 ) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java: 122 ) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java: 693 ) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java: 360 ) at org.springframework.boot.SpringApplication.run(SpringApplication.java: 303 ) at com.pci.tpp.gateway.GatewayApplication.main(GatewayApplication.java: 22 ) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 62 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 43 ) at java.lang.reflect.Method.invoke(Method.java: 498 ) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java: 48 ) at org.springframework.boot.loader.Launcher.launch(Launcher.java: 87 ) at org.springframework.boot.loader.Launcher.launch(Launcher.java: 50 ) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java: 51 ) 12 - 12 19 : 44 : 58.840 |ERROR|o.a.catalina.core.StandardService: 181 |main||Failed to start connector [Connector[HTTP / 1.1 - 80 ]] org.apache.catalina.LifecycleException: Failed to start component [Connector[HTTP / 1.1 - 80 ]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java: 167 ) at org.apache.catalina.core.StandardService.addConnector(StandardService.java: 225 ) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.addPreviouslyRemovedConnectors(TomcatEmbeddedServletContainer.java: 250 ) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java: 193 ) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java: 297 ) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java: 145 ) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java: 546 ) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java: 122 ) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java: 693 ) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java: 360 ) at org.springframework.boot.SpringApplication.run(SpringApplication.java: 303 ) at com.pci.tpp.gateway.GatewayApplication.main(GatewayApplication.java: 22 ) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 62 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 43 ) at java.lang.reflect.Method.invoke(Method.java: 498 ) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java: 48 ) at org.springframework.boot.loader.Launcher.launch(Launcher.java: 87 ) at org.springframework.boot.loader.Launcher.launch(Launcher.java: 50 ) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java: 51 ) Caused by: org.apache.catalina.LifecycleException: service.getName(): "Tomcat" ; Protocol handler start failed at org.apache.catalina.connector.Connector.startInternal(Connector.java: 1031 ) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java: 150 ) ... 19 common frames omitted Caused by: java.net.SocketException: 权限不够 at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Net.java: 433 ) at sun.nio.ch.Net.bind(Net.java: 425 ) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java: 223 ) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java: 74 ) at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java: 210 ) at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java: 990 ) at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java: 635 ) at org.apache.catalina.connector.Connector.startInternal(Connector.java: 1022 ) ... 20 common frames omitted 12 - 12 19 : 44 : 58.847 |INFO|o.a.coyote.http11.Http11NioProtocol: 179 |main||Pausing ProtocolHandler [ "http-nio-80" ] 12 - 12 19 : 44 : 58.848 |INFO|o.a.catalina.core.StandardService: 179 |main||Stopping service [Tomcat] 12 - 12 19 : 44 : 58.852 |WARN|o.a.c.loader.WebappClassLoaderBase: 179 |localhost - startStop - 1 ||The web application [ROOT] appears to have started a thread named [spring.cloud.inetutils] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: sun.misc.Unsafe.park(Native Method) java.util.concurrent.locks.LockSupport.park(LockSupport.java: 175 ) java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java: 2039 ) java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java: 442 ) java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java: 1074 ) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java: 1134 ) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java: 624 ) java.lang.Thread.run(Thread.java: 748 ) 12 - 12 19 : 44 : 58.855 |INFO|o.apache.catalina.util.LifecycleBase: 179 |main||The stop() method was called on component [StandardServer[ - 1 ]] after stop() had already been called. The second call will be ignored. 12 - 12 19 : 44 : 58.855 |INFO|o.a.coyote.http11.Http11NioProtocol: 179 |main||Stopping ProtocolHandler [ "http-nio-80" ] 12 - 12 19 : 44 : 58.855 |INFO|o.a.coyote.http11.Http11NioProtocol: 179 |main||Destroying ProtocolHandler [ "http-nio-80" ] 12 - 12 19 : 44 : 58.857 |INFO|o.s.b.a.l.AutoConfigurationReportLoggingInitializer: 101 |main|| Error starting ApplicationContext. To display the auto - configuration report re - run your application with 'debug' enabled. 12 - 12 19 : 44 : 58.860 |ERROR|o.s.b.d.LoggingFailureAnalysisReporter: 42 |main|| |
原因其实是因为在linux下,如果使用1024以下的端口则需要root权限,所以因为我当前使用的不是root权限,所以权限不足而无法使用80端口,所以会报权限不够异常。把服务端口改为非80端口且大于1024的端口,比如8080即可。
在配置文件中修改端口号。
如对您有帮助,支持下呗!
微信
支付宝
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
· DeepSeek火爆全网,官网宕机?本地部署一个随便玩「LLM探索」
· 开发者新选择:用DeepSeek实现Cursor级智能编程的免费方案
· 【译】.NET 升级助手现在支持升级到集中式包管理
· 独立开发经验谈:如何通过 Docker 让潜在客户快速体验你的系统
· 并发编程 - 线程同步(二)