Servname not supported for ai_socktype
Asked Answered
C

4

18

I'm running a Centos virtual machine using Vagrant. The machine seems to run properly, but when I try to sync Perforce I can see the following error:

[vagrant@vagrant-c5-x86_64 ~]$ /perforce/p4 sync -f ...  
Perforce client error:  
Connect to server failed; check $P4PORT.  
failed.TCP connect to perforce.xxx.com:1666  
Servname not supported for ai_socktype

I have read this http://www.ducea.com/2006/09/11/error-servname-not-supported-for-ai_socktype/ and tried to set the ports in /etc/services, but it didn't work. I am not even sure if the problem is Perforce or OS related.

Any hints?

Cheetah answered 15/4, 2014 at 9:0 Comment(5)
Have you set P4PORT correctly?Sather
Yes, that was my first guess. It was correctly set from the beginning. Also, I changed P4CHARSET to 'utf8' and 'none'. No results so far...Cheetah
Does "telnet perforce.xxx.com 1666" work? (i.e. establish a connection)Sather
It does work. The machines can see each other.Cheetah
See #43600739 for a similar question, with an answer, although in that case the answer involved a syntax error in a Perl script. Still, maybe it gives a clue to the answer to this question.Wisniewski
D
22

I had this problem with a Tornado/Python app. Apparently, this can be caused by the port being interpreted as a string instead of an integer. So in my case, I needed to change my startup script to force it to be interpreted as an integer.

application = tornado.web.Application(...)
application.listen(int(port))
Depilatory answered 30/10, 2014 at 23:54 Comment(1)
Completely different library (Kafka-Python) but this resolved my problem! ThanksStupe
B
2

Are you able to enter your client ? before trying to sync the files, try to create a perforce client:

p4 client

Maybe it's not the host:port that is the issue, but other flags in the connection string that interrupt.

I personally received the exact same error, but it was a Perforce issue.

The reason is, Perforce has its own priority when it's looking for its P4USER/P4PORT/... configuration.

  1. ENV variables ( run export )
  2. if a P4CONFIG variable was specified somewhere it can search in a file ( like .perforce in the current/upper directory )

Problem was, even though it first search for an ENV variable - the P4CONFIG file might override it.

So my $P4PORT ENV variable had a connection string X, but the .perforce file had a connection string Y.

Removing the P4PORT from my local .perforce file - solved this issue. in example:

$~] echo $P4PORT; 
rsh:ssh -2 -q -a -x -l p4ssh perforce.mydomain.com

$~] cat .perforce
# P4PORT="rsh:ssh -q -a -x -l perforce.mydomain.com /bin/true"
P4USER="my_user"

Also remember that Perforce will search for the $P4CONFIG file ( if configured one ) in the entire directory hierarchy upwards, so even if you don't have the file in the current directory - it might be found in an upper directory, and there - you might have a $P4PORT configuration that you didn't expect..

Blade answered 11/8, 2015 at 9:0 Comment(0)
M
1

Put trailing slash, e.g.:

http://perforce.xxx.com:1666/

Instead of:

http://perforce.xxx.com:1666
Marigraph answered 8/5, 2021 at 16:11 Comment(0)
A
0

In my case I got like this error in golang language, i changed my port type from string to int and works fine

Abeyant answered 22/8, 2022 at 11:44 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.