Can't connect to a Oracle db instance via SQLDeveloper When I set the connecting information on the GUI in SQLDeveloper I get the following error (everytime!)

Status : Failure -Test failed: IO Error: The Network Adapter could not establish the connection

Connection information:

user: hr
pass: hr
Conn. type: basic / Role: default
hostname: localhost
port: 1521
SID: xe

I couldn't connect with the sys user either.
Previously I successfully unlocked the HR user through SQLPLUS command line
(as described here:
and set the port=localhost in the tnsnames.ora and listener.ora, the OracleXETNSListener service is up and running as well as the OracleServiceXE)
Sadly I'm still getting this error message...
I'm on a laptop (with wireless wifi connection only), under Windows 7.
What might be the problem?
Thank you for your help.
In the meantime I figured it out myself.

The connection couldn't be established from SQL Developer because I was logged into my company's VPN and so "localhost" was resolved somehow as an IPV6 address.

When I closed the VPN connection and tried to connect with the same connection information it worked, localhost was resolved as normal IPV4 address then.