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?

5
  • 1
    Have you set P4PORT correctly?
    – pitseeker
    Apr 15, 2014 at 13:00
  • 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...
    – Tavo
    Apr 16, 2014 at 11:19
  • Does "telnet perforce.xxx.com 1666" work? (i.e. establish a connection)
    – pitseeker
    Apr 16, 2014 at 12:21
  • It does work. The machines can see each other.
    – Tavo
    Apr 17, 2014 at 8:18
  • See stackoverflow.com/questions/43600239/… 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. Apr 25, 2017 at 13:37

4 Answers 4

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))
1
  • 1
    Completely different library (Kafka-Python) but this resolved my problem! Thanks Mar 12, 2020 at 13:50
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..

1

Put trailing slash, e.g.:

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

Instead of:

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

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

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.