serve icon indicating copy to clipboard operation
serve copied to clipboard

Failed to bind to address: http://127.0.0.1:8080 [Troubleshooting]

Open skyprince999 opened this issue 6 years ago • 8 comments

This is wrt to the steps provided in the Readme doc. I am trying to serve the tutorial model

Please provide following details -

Context torchserve version: 0.0.1b20200409 torch version: 1.5.0 torchvision version [if any]: Na torchtext version [if any]: Na torchaudio version [if any]: Na java version: openjdk 11.0.6 2020-01-14 Operating System and version: Debian GNU/Linux 9.12 (stretch)

Your Environment Installed using source? [yes/no]: No Are you planning deploy it using docker container? [yes/no]: No Is it a CPU or GPU environment?: Both (CPU/ and GPU) Using a default/custom handler? [If possible upload/share custom handler/model]: Na What kind of model is it e.g. vision, text, audio?: vision Are you planning to use local models from model-store or public url being used e.g. from S3 bucket etc.? local [If public url then provide link.]: Provide config.properties, logs [ts.log] and parameters used for model registration/update APIs: Link to your project [if any]: Same as the one provided in the Readme tutorial Also, provide the output for following command :

grep 8080 /etc/services

http-alt 8080/tcp webcache # WWW caching service

http-alt 8080/udp

Get the same error for both CPU & GPU version of torchserve

This should probably be in common errors & troubleshooting document.

FYI - Port 8080 is not being used, output of ss command is provided below

After starting the server. I get the following error:

main org.pytorch.serve.ModelServer - Torchserve stopped
java.io.IOException: Failed to bind to address: http://127.0.0.1:8080
        at org.pytorch.serve.ModelServer.initializeServer(ModelServer.java:258)
        at org.pytorch.serve.ModelServer.start(ModelServer.java:318)
        at org.pytorch.serve.ModelServer.startAndWait(ModelServer.java:102)
        at org.pytorch.serve.ModelServer.main(ModelServer.java:83)
Caused by: io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Address already in use
        at io.netty.channel.unix.Errors.newIOException(Errors.java:122)
        at io.netty.channel.unix.Socket.bind(Socket.java:287)
        at io.netty.channel.epoll.AbstractEpollChannel.doBind(AbstractEpollChannel.java:688)
        at io.netty.channel.epoll.EpollServerSocketChannel.doBind(EpollServerSocketChannel.java:70)
        at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:558)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1358)
        at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:501)
        at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:486)
        at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:1019)
        at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:254)
        at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:366)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:309)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:834)

Output of ss command. Shows ports which are in use.

(torchserve-cpu) jupyter@tensorflow-3-vm:~$ ss -tulw
Netid  State      Recv-Q Send-Q                    Local Address:Port                                     Peer Address:Port                
udp    UNCONN     0      0                                     *:bootpc                                              *:*                    
udp    UNCONN     0      0                            10.164.0.8:ntp                                                 *:*                    
udp    UNCONN     0      0                             127.0.0.1:ntp                                                 *:*                    
udp    UNCONN     0      0                                     *:ntp                                                 *:*                    
udp    UNCONN     0      0            fe80::4001:aff:fea4:8%eth0:ntp                                                :::*                    
udp    UNCONN     0      0                                   ::1:ntp                                                :::*                    
udp    UNCONN     0      0                                    :::ntp                                                :::*                    
tcp    LISTEN     0      100                           127.0.0.1:44397                                               *:*                    
tcp    LISTEN     0      128                           127.0.0.1:http-alt                                            *:*                    
tcp    LISTEN     0      100                           127.0.0.1:44211                                               *:*                    
tcp    LISTEN     0      100                           127.0.0.1:53907                                               *:*                    
tcp    LISTEN     0      100                           127.0.0.1:48885                                               *:*                    
tcp    LISTEN     0      128                                   *:ssh                                                 *:*                    
tcp    LISTEN     0      100                           127.0.0.1:49751                                               *:*                    
tcp    LISTEN     0      100                           127.0.0.1:48185                                               *:*                    
tcp    LISTEN     0      128                                 ::1:http-alt                                           :::*                    
tcp    LISTEN     0      128                                  :::ssh                                                :::*                    

skyprince999 avatar May 06 '20 16:05 skyprince999

Better option would be to handle this exception and output a graceful message that the port is in use etc. and ask the user to refer troubleshooting guide for details if any.

codinnvrends avatar May 07 '20 06:05 codinnvrends

@dhaniram-kshirsagar I don't think the port is in use. I have shared the output of the ss command in my message above.

Can you also share the link to the troubleshooting guide.

skyprince999 avatar May 07 '20 08:05 skyprince999

@skyprince999 : Are you running on Debian OS?

Please provide following details -

Context

  • torchserve version:
  • torch version:
  • torchvision version [if any]:
  • torchtext version [if any]:
  • torchaudio version [if any]:
  • java version:
  • Operating System and version:

Your Environment

  • Installed using source? [yes/no]:
  • Are you planning deploy it using docker container? [yes/no]:
  • Is it a CPU or GPU environment?:
  • Using a default/custom handler? [If possible upload/share custom handler/model]:
  • What kind of model is it e.g. vision, text, audio?:
  • Are you planning to use local models from model-store or public url being used e.g. from S3 bucket etc.? [If public url then provide link.]:
  • Provide config.properties, logs [ts.log] and parameters used for model registration/update APIs:
  • Link to your project [if any]:

Also, provide the output for following command :

grep 8080 /etc/services

harshbafna avatar May 07 '20 11:05 harshbafna

yes using debian. Updated the other details in the first comment. I am running the tutorial provided in the Readme file.

>>lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 9.12 (stretch)
Release:        9.12
Codename:       stretch`

skyprince999 avatar May 07 '20 14:05 skyprince999

grep 8080 /etc/services

http-alt 8080/tcp webcache # WWW caching service

http-alt 8080/udp

The port 8080 is being occupied by some proxy service or other web-server running on your machine.

Please provide the output of following command :

ss -ntl | grep 8080

harshbafna avatar May 07 '20 14:05 harshbafna

Is it possible to change the port ? (in torchserve)

skyprince999 avatar May 07 '20 17:05 skyprince999

Yes, you can set custom IP/Port for TorchServe's inference and management APIs using config.properties file.

For more details refer : https://github.com/pytorch/serve/blob/master/docs/configuration.md

harshbafna avatar May 07 '20 17:05 harshbafna

This should be addressed via #215

codinnvrends avatar May 12 '20 10:05 codinnvrends